fcntl and siginfo_t in python

ma mabdelkader at gmail.com
Mon May 4 12:03:42 EDT 2009


Ok! So, I decided to write a C-extension instead of using ctypes. So
far, I create a module called dnotifier and the handler callback
receives two arguments, the signal number and the respective file
descriptor that was modified.

This works beautifully. Now, I want to release this to the public, so
I'm thinking of making a bit of code cleanup. Should I just pack the
entire siginfo_t struct, right now I just use the fd, into a
dictionary and pass it to the python callback handler function? Maybe
there might be some more suggestions to what data structures to use,
so I'm open right now to any of them.

The siginfo_t structure is defined as follows in C:

union sigval {
	int sival_int;
	void *sival_ptr;
};

typedef struct {
	int si_signo;
	int si_code;
	union sigval si_value;
	int si_errno;
	pid_t si_pid;
	uid_t si_uid;
	void *si_addr;
	int si_status;
	int si_band;
} siginfo_t;

Thanks,
Mahmoud



On Fri, May 1, 2009 at 3:08 PM, ma <mabdelkader at gmail.com> wrote:
>
> According to man signal,
> "The default action for an unhandled real-time signal is to terminate
> the receiving process."
>
> This means that my registered callback and sigaction does not work. I
> think the only solution would be to try this with a C-extension. Has
> anyone had any experience with this before?
>
> I attached my latest copy. Any insight is appreciated.
>
> On Thu, Apr 30, 2009 at 7:37 PM, ma <mabdelkader at gmail.com> wrote:
> > I attached a clean copy of the .py file in case others couldn't read
> > it in their emails.
> > I'll try that and let you know how SIGRTMIN+1 goes!
> > What about this part?
> >
> > #sigemptyset(&act.sa_mask);
> > #python2.6 has byref(act, offset),how can i port this over?
> > #maybe addressof(act)+sizeof(sigaction.sa_mask)*(position_in_sigaction)
> > rc = __clib.sigemptyset(byref(act))
> >
> > Thanks!
> > Mahmoud
> >
> >
> >
> > On Thu, Apr 30, 2009 at 7:33 PM, Philip <philip at subaru.naoj.org> wrote:
> >>
> >> ma <mabdelkader <at> gmail.com> writes:
> >>
> >> >
> >> >
> >> >
> >> >
> >> > Here's something that I came up with so far, I'm having some issues with
> >> segfaulting, if I want to pass a struct member by ref in ctypes(see below), if
> >> not, I just get a
> >> > "Real-time signal 0" sent back to me.
> >> >
> >> >
> >> > Any ideas?
> >>
> >> Try "SIGRTMIN+1", per http://souptonuts.sourceforge.net/code/dnotify.c.html
> >>
> >> Philip
> >>
> >>
> >>
> >> --
> >> http://mail.python.org/mailman/listinfo/python-list
> >



More information about the Python-list mailing list