lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 28 Oct 2008 08:24:21 +0000 (UTC)
From:	Halesh S <halesh.s@...ia.com>
To:	linux-kernel@...r.kernel.org
Subject:  Re: parent process behaviour to signal after vfork()


Hi,

Check this test


#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;
  char *s = "HELLO";

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

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


Just little analysis

If I use kill() to send the signal,it works fine, but not with raise().

O/p with raise()
 I am child - 15014
SIGNAL CAUGHT
x = 1
 I am parent - 15014         (** Child pid o/p in parent getpid)
x = 1


O/p with kill()
 I am child - 15016
SIGNAL CAUGHT
x = 1
 I am parent - 15015
SIGNAL CAUGHT
x = 1


checked that getpid() function is not working fine when used after raise().
It is still getting its child's pid in parent.

Is it a expected behaviour...Please let me know.

Thanks,
Halesh

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ