lkml.org 
[lkml]   [2008]   [Jan]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subject[HELP]Problem with exit(0) and _exit(0) on RHEL x86
Date

I thought the effects of exit(0) and _exit(0) should be different.

----
int main(void)
{
int var = 0;
pid_t pid;

printf("before vfork\n");
if ( (pid = vfork()) < 0 )
printf("error\n");
else if ( pid == 0 )
{
var++;
exit(0); /* Clear parent's IO */
}

printf("%d\n",var);
return 0;
}

----

int main(void)
{
int var = 0;
pid_t pid;

printf("before vfork\n");
if ( (pid = vfork()) < 0 )
printf("error\n");
else if ( pid == 0 )
{
var++;
_exit(0); /* Do not clear parent's IO */
}

printf("%d\n",var);
return 0;
}

----

But the actual results on RHEL5 x86 were beyond my ken. The outputs of the
above two are the same.

$./a.out
before vfork
1

Could anyone help me with this? Thanks.





\
 
 \ /
  Last update: 2008-01-21 09:51    [W:0.061 / U:1.484 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site