mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Halesh S <halesh.s@india.com>
To: linux-kernel@vger.kernel.org
Subject: parent process behaviour to signal after vfork()
Date: Tue, 28 Oct 2008 06:43:19 +0000 (UTC)	[thread overview]
Message-ID: <loom.20081028T062822-852@post.gmane.org> (raw)

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











             reply	other threads:[~2008-10-28  6:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-28  6:43 Halesh S [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=loom.20081028T062822-852@post.gmane.org \
    --to=halesh.s@india.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®