[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

signal problem

Hi all,

I don't understand what's happening with signal() function.
This is a simple example:

#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>

void handler(int n) {
  printf("received signal %s (%d)\n", sys_siglist[n], n);

int main(int argc, char **argv) {
  pid_t pid;
  int status;
  signal(SIGCHLD, handler);
  if((pid = fork()) == 0) {
    printf("%d: child start\n", getpid());
    printf("%d: child end\n", getpid());
  printf("%d: father start\n", getpid());
  waitpid(pid, &status, 0);
  printf("%d: father end\n", getpid());

gcc-cris -mlinux -static -s -O2 -o sigchld sigchld.c

When I run it on devboard_lx, I obtain:

1: father start
8: child start
8: child end
received signal Floating point exception (8)
1: father end

Instead of receiving n=SIGCHLD, I receive n=(child pid) !!!
I use cris-dist-1.13-1.i386.rpm and linux-2.4.3.

Any ideas ? Thanks

Jerome Lefranc

Jerome LEFRANC           jerome.lefranc@xxxxxxx.com
XCell Technology         http://www.xcell.com
DECISION Europe, 75-85 rue Richelieu
85170 les Lucs sur Boulogne, FRANCE
Voice: +33 2 51 31 38 38,  Fax: +33 2 51 46 59 66