Skip to contentSkip to conversation

system() return different value under 2.4.23 and 2.6.0-test11

DISCUSSION fengxj 2 participants 2 messages Dec 4, 2003

lore
Share & tools
lore

fengxj

author
#0 lore raw

Hi, everyone

I just found a simple program:

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

int main(void)

{
        int ret;

        signal(SIGCHLD, SIG_IGN);

        ret = system("/bin/date 1>/dev/null");
        printf("%d\n", ret);

        return 0;
}

----------------------------

runs under 2.4.23 with ret = 0,
but under 2.6.0-test11, ret = -1.

Why?

And when i remove

    signal(...)

it returns the same value 0.

I use Slackware 9.1 with GCC 3.2.3 and libc 2.3.2

Regards.

#1 lore raw
Quoted 18 lines · fengxj

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

int main(void)

{
       int ret;

       signal(SIGCHLD, SIG_IGN);

       ret = system("/bin/date 1>/dev/null");
       printf("%d\n", ret);

       return 0;
}

----------------------------

Quoted 10 lines

runs under 2.4.23 with ret = 0,
but under 2.6.0-test11, ret = -1.

Why?

And when i remove
signal(...)
it returns the same value 0.

It's happening because of the return values of wait4(). wait4() is returning -1 in test11 whene SIGCHLD is SIG_IGN'ed. /Raj