Linux,fcntl,F_SETLEASE和信号 [英] Linux, fcntl, F_SETLEASE and signals

查看:90
本文介绍了Linux,fcntl,F_SETLEASE和信号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,


无论如何,python中的信号处理程序从3参数信号处理程序获取信息

而不仅仅是信号数字

和堆栈框架?


我有一个应用程序,我必须检查文件上的F_SETLEASE

在Linux 2.4上的python中。这样做是告诉内核通过SIGIO通知

当前进程,特定文件描述符是由另一个进程修改的

Hey folks,

Is there anyway for a signal handler in python to get the information
from a 3 argument signal handler rather than just the signal number
and stack frame?

I''ve got an application where I have to check for F_SETLEASE on a file
in python on Linux 2.4. What this does is tells the kernel to notify
the current process with SIGIO that a particular file descriptor is being
modified by another process.

import fcntl
f = open(" .zshrc"," r +")
fcntl.fcntl (f,fcntl.F_SETLEASE,fcntl.F_WRLCK)
import fcntl
f = open(".zshrc", "r+")
fcntl.fcntl(f, fcntl.F_SETLEASE, fcntl.F_WRLCK)



0


现在,当另一个流程打开时.zshrc,我收到一封SIGIO说

发生了什么事。内核在siginfo_t的si_fd字段中提供了有关

描述符更改的信息。


无论如何都可以从python中获取它?


谢谢,

Chris

-

Chris Green< cm*@dok.org>

现在你有14分钟到达最小安全距离。


0

Now, when another process opens ".zshrc", I get a SIGIO saying
something happened. The kernel provides the information on what
descriptor changed in a siginfo_t''s si_fd field.

Is there anyway to get this from python?

Thanks,
Chris
--
Chris Green <cm*@dok.org>
You now have 14 minutes to reach minimum safe distance.

推荐答案

Chris Green< cm*@dok.org>写道:
Chris Green <cm*@dok.org> writes:
嘿伙计们,

无论如何,python中的信号处理程序从3参数信号处理程序获取信息而不是只是信号编号和堆栈框架?


No.

我有一个应用程序,我必须在Linux 2.4上的python中检查文件上的F_SETLEASE。这样做是告诉内核用SIGIO通知当前进程特定文件描述符被另一个进程修改。
Hey folks,

Is there anyway for a signal handler in python to get the information
from a 3 argument signal handler rather than just the signal number
and stack frame?
No.
I''ve got an application where I have to check for F_SETLEASE on a file
in python on Linux 2.4. What this does is tells the kernel to notify
the current process with SIGIO that a particular file descriptor is being
modified by another process.
import fcntl
f = open(" .zshrc"," r +")
fcntl.fcntl(f,fcntl.F_SETLEASE,fcntl.F_WRLCK)
import fcntl
f = open(".zshrc", "r+")
fcntl.fcntl(f, fcntl.F_SETLEASE, fcntl.F_WRLCK)


0
现在,当另一个进程打开.zshrc时,我得到一个SIGIO说
发生了什么事。内核在siginfo_t的si_fd字段中提供了有关
描述符更改的信息。

无论如何从python获取此内容?


0

Now, when another process opens ".zshrc", I get a SIGIO saying
something happened. The kernel provides the information on what
descriptor changed in a siginfo_t''s si_fd field.

Is there anyway to get this from python?



多么棒的界面。我想你必须写一些C给

这个...


干杯,

mwh

-

< Erwin>我用gcc 3.2-beta-from-cvs用-O42

和-march-pentium4-800Mhz重新编译了XFree 4.2,我相信MOUSE

CURSOR正在移动5 %FASTER!

- 来自Twisted.Quotes



What a wonderful interface. I think you''ll have to write some C for
this...

Cheers,
mwh

--
<Erwin> I recompiled XFree 4.2 with gcc 3.2-beta-from-cvs with -O42
and -march-pentium4-800Mhz and I am sure that the MOUSE
CURSOR is moving 5 % FASTER!
-- from Twisted.Quotes


我不知道如何在没有扩展模块的情况下做到这一点。不过,应该可以使用扩展模块来实现
。模块

将使用sigaction()为SIGIO安装自己的处理程序,并从某个地方的siginfo_t参数中隐藏

所需的字段。使用

Py_AddPendingCall()(未记录?但是使用公共API名称)运行

回调,其中隐藏的信息在void * arg中,后者回调

到Python或做你需要的任何其他事情。


杰夫


-----开始PGP签名--- -

版本:GnuPG v1.2.1(GNU / Linux)

iD8DBQFA / p61Jd01MZaTXX0RAjKJAKCXL47MW0LwZJyKcjqObHwtq1cxYAC fZgRB

0yObNIGu / VE3Bk8cwVRE / hI =

= Ye8Y

-----结束PGP SIGNATURE -----

I don''t know of a way to do this without an extension module. It should
be possible to do it with an extension module, though. The module
would use sigaction() to install its own handler for SIGIO, and stash
the desired fields from the siginfo_t parameter somewhere. Use
Py_AddPendingCall() (undocumented? but with a public API name) to run a
callback with the stashed information in the void* arg, which calls back
into Python or does whatever else you need.

Jeff

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFA/p61Jd01MZaTXX0RAjKJAKCXL47MW0LwZJyKcjqObHwtq1cxYAC fZgRB
0yObNIGu/VE3Bk8cwVRE/hI=
=Ye8Y
-----END PGP SIGNATURE-----


2004年7月21日星期三12:27:57 -0400,Chris Green< cm*@dok.org>写道:
On Wed, 21 Jul 2004 12:27:57 -0400, Chris Green <cm*@dok.org> wrote:
嘿伙计们,

无论如何,python中的信号处理程序从3参数信号处理程序获取信息而不仅仅是信号编号
和堆栈框架?

我有一个应用程序,我必须在Linux 2.4上的python中检查文件上的F_SETLEASE。这样做是告诉内核用SIGIO通知当前进程特定文件描述符被另一个进程修改。
Hey folks,

Is there anyway for a signal handler in python to get the information
from a 3 argument signal handler rather than just the signal number
and stack frame?

I''ve got an application where I have to check for F_SETLEASE on a file
in python on Linux 2.4. What this does is tells the kernel to notify
the current process with SIGIO that a particular file descriptor is being
modified by another process.
import fcntl
f = open(" .zshrc"," r +")
fcntl.fcntl(f,fcntl.F_SETLEASE,fcntl.F_WRLCK)0
import fcntl
f = open(".zshrc", "r+")
fcntl.fcntl(f, fcntl.F_SETLEASE, fcntl.F_WRLCK) 0




这会足够接近吗?


Python 2.3.4(#2,2004年7月5日,09:15:05)

[GCC 3.3.4(Debian 1:3.3.4-2)] on linux2

输入help,copyright,credit等等。或许可证或有关详细信息。



would this be close enough?

Python 2.3.4 (#2, Jul 5 2004, 09:15:05)
[GCC 3.3.4 (Debian 1:3.3.4-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import fcntl
import ctypes
libc = ctypes.cdll.LoadLibrary(''/ lib / libc.so.6'')
f = open(" /home/john/.bashrc")
libc.fcntl(f.fileno(),fcntl.F_SETLEASE,fcntl.F_WRLCK)
0
#now now cats。 bashrc
import fcntl
import ctypes
libc = ctypes.cdll.LoadLibrary(''/lib/libc.so.6'')
f = open("/home/john/.bashrc")
libc.fcntl(f.fileno(), fcntl.F_SETLEASE, fcntl.F_WRLCK) 0
# now someone cats .bashrc



.... I / O可能


-

John Lenton(jl*****@gmail.com) - 随机财富:

bash:fortune:命令未找到


.... I/O possible

--
John Lenton (jl*****@gmail.com) -- Random fortune:
bash: fortune: command not found


这篇关于Linux,fcntl,F_SETLEASE和信号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆