lkml.org 
[lkml]   [2008]   [Oct]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subjectparent process behaviour to signal after vfork()
Date
Hi,

Please find the below test code...

#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
int x = 0;
typedef void (*sighandler_t)(int);
void fun()
{
printf("SIGNAL CAUGHT\n");
}

int main()
{
int pid;

signal(SIGINT, (sighandler_t)fun);
signal(SIGSEGV, (sighandler_t)fun);
pid = vfork();

if ( pid == 0 ) {
printf(" I am child - %d \n", pid);
x++;
raise(SIGINT);
printf("x = %d\n", x);
exit(0);
}
else {
printf(" I am parent - %d\n", pid);
raise(SIGSEGV);
printf("x = %d\n", x);
}
}

Why the parent process is not able to handle/respond the signals, when a child
once handles the signal, child is created using vfork().

In vfork() man page -
"Signals to the parent arrive after the child releases the parent's
memory."

How to make sure that child has released the parent memory..??

Thanks,
Halesh












\
 
 \ /
  Last update: 2008-10-28 07:47    [W:0.062 / U:0.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site