mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* parent process behaviour to signal after vfork()
@ 2008-10-28  6:43 Halesh S
  2008-10-28  8:24 ` Halesh S
  2008-10-29 13:17 ` Michael Kerrisk
  0 siblings, 2 replies; 6+ messages in thread
From: Halesh S @ 2008-10-28  6:43 UTC (permalink / raw)
  To: linux-kernel

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











^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-10-30 13:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-28  6:43 parent process behaviour to signal after vfork() Halesh S
2008-10-28  8:24 ` Halesh S
2008-10-29 13:17 ` Michael Kerrisk
2008-10-30  5:38   ` Valdis.Kletnieks
2008-10-30 13:24     ` Michael Kerrisk
2008-10-30 13:26       ` Michael Kerrisk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®