Re: strange sigaction ()

2 messages, 2 authors, 2001-03-07 · open the first message on its own page

Re: strange sigaction ()

From: <hidden>
Date: 2001-03-07 12:40:48

It did not work for me !!
Is the problem with kernel or it is elsewhere ?
Which kernel patch will fix this ?



Try the following, it works for me:

#include <stdlib.h>
#include <stdio.h>
#include <signal.h>

static struct sigaction act;
static void handler (int,siginfo_t *,void *);

int
main ()
{
  act.sa_sigaction=handler;
  act.sa_flags=SA_SIGINFO;
  sigaction (SIGALRM,&act,NULL);
  alarm (1);
  sleep (2);
}

void handler (int x, siginfo_t *s,void *v)
{
    printf ("si_signo   = %d, si_code  = %d, si_errno  = %d\n",s->si_signo,
s->si_code, s->si_errno);
}

[kbhend@localhost kbhend]$ gcc -otest test.c
[kbhend@localhost kbhend]$ ./test
si_signo   = 14, si_code  = 0, si_errno  = 0
[kbhend@localhost kbhend]$


On Tuesday 06 March 2001 06:04, pnilesh@in.ibm.com wrote:
I am seeing a strange problem with sigaction on powerpc.

static struct sigaction act;
static void handler (int,siginfo_t *,void *);
main ()
{
sigaction (SIGALRM,&act,NULL);
alarm (1);
sleep (2);
}

void handler (int x, siginfo_t *s,void *v)
{
    printf ("si_signo   = %d, si_code  = %d, si_errno  =
%d\n",s->si_signo,
s->si_code, s->si_errno);
}

This program gives meaningful values on Linux Intel Redhat.
On Apple Dual G4 PowerPC I am getting junk values
si_signo = 805464356
si_errno = 805464640
si_code = 21

I dont know what is happening.
Please educate me.

Nilesh


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

Re: strange sigaction ()

From: Kevin B. Hendricks <hidden>
Date: 2001-03-07 13:36:49

Hi,
It did not work for me !!
Is the problem with kernel or it is elsewhere ?
Which kernel patch will fix this ?
What kernel are you using?
What version of glibc are you using?

The patch to support siginfo and rt signals was added during the 2.2.14
series someplace and should be in both 2.2.16 and higher and 2.4.X.

For example, my kernel is 2.2.17-pre10 and it has the necessary support. The
glibc I am using is 2.1.3 latest from Franz Sirl.

If you are using a 2.2.1X series kernel you may want to see if this patch is
present in your kernel sources (see attached patch).

p.s. I don't know how your previous code worked on Intel RedHat since it
never loaded the SA_SIGINFO and handler into the sigaction structure before
calling sigaction.  If it worked, you were lucky.  Technically without the
handler being specified in the sigaction structure and without the SA_SIGINFO
flag you should have been playing with a zero'd out act structure.

Kevin

Try the following, it works for me:

#include <stdlib.h>
#include <stdio.h>
#include <signal.h>

static struct sigaction act;
static void handler (int,siginfo_t *,void *);

int
main ()
{
  act.sa_sigaction=handler;
  act.sa_flags=SA_SIGINFO;
  sigaction (SIGALRM,&act,NULL);
  alarm (1);
  sleep (2);
}

void handler (int x, siginfo_t *s,void *v)
{
    printf ("si_signo   = %d, si_code  = %d, si_errno  = %d\n",s->si_signo,
s->si_code, s->si_errno);
}

[kbhend@localhost kbhend]$ gcc -otest test.c
[kbhend@localhost kbhend]$ ./test
si_signo   = 14, si_code  = 0, si_errno  = 0
[kbhend@localhost kbhend]$
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help