need help with sigaction and siginfo_t

Tijl Coosemans tijl at ulyssis.org
Sun Nov 18 07:21:35 PST 2007


On Sunday 18 November 2007 14:39:41 kozlov_n at epitech.net wrote:
> Tijl Coosemans <tijl at ulyssis.org> a écrit :
>> On Saturday 17 November 2007 17:03:51 nikita kozlov wrote:
>>> I'm a student and we are working on FreeBSD.
>>> My problem is i don't understand how to use SA_SIGINFO and
>>> siginfo_t. The following code caught my SIGUSR1 with a "kill -30
>>> my_server_pid" from my shell.
>>> but siginfo_t is empty when i'm debugging my program with gdb.
>>> my output is :
>>> > pid 0
>>> and in gdb i have :
>>> {
>>> si_signo = 30,
>>> si_errno = 0,
>>> si_code = 0,
>>> si_pid = 0,
>>> si_uid = 0,
>>> si_status = 0,
>>> si_addr = 0x2,
>>> si_value = {sigval_int = 0,sigval_ptr = 0x0},
>>> si_band = 0,
>>> __spare__ = {0, 0, 0, 0, 0, 0, 0}
>>> }
>>>
>>> anyone have an idea why my siginfo_t is empty please ?
>>
>> Well, it isn't empty. It's just that the si_pid field usually isn't
>> set. It probably should be, but either way, your code should work if
>> you send signals with sigqueue(2) instead of kill(2).
> 
> Thank you for the reply,
> i have tried to use sigqueue but after a "undefined reference to
> `sigqueue'" compilation error i have opened signal.h and found this
> define : 
> 
> #if 0
> /*
>   * PR: 35924
>   * XXX we don't actually have these.  We set _POSIX_REALTIME_SIGNALS to 
>   * -1 to show that we don't have them, but this symbol is not necessarily
>   * in scope (in the current implementation), so we can't use it here.
>   */
> int     sigqueue(__pid_t, int, const union sigval);
> #endif
> 
> I'm working on FreeBSD 5.5-RELEASE-p14, do you have any idea ?

Hmm, looks like it has only been added in FreeBSD 7. If you can't
upgrade, you'll have to use some more advanced IPC mechanism I'm
afraid.


More information about the freebsd-hackers mailing list