Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kill thinks it killed a nonexistant pid #193

Closed
p5pRT opened this issue Jul 14, 1999 · 1 comment
Closed

kill thinks it killed a nonexistant pid #193

p5pRT opened this issue Jul 14, 1999 · 1 comment

Comments

@p5pRT
Copy link

@p5pRT p5pRT commented Jul 14, 1999

Migrated from rt.perl.org#999 (status was 'resolved')

Searchable as RT999$

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jul 14, 1999

From dhoover@cadence.com

The kill function seems to think it killed a pid even when it hasn't. I've
looked up the usage of the kill command in both O'Reily's Programming Perl
and the perlipc man page. There's even a chunk of code in that man page
that says pretty much the same thing as this example​:

#!/usr/bin/perl

if(!defined($kid_pid = fork())) {
  die "Unforkable? Well THAT ruins story time! $!\n";
} elsif($kid_pid == 0) {
  print "\"Yay! I'm the child!\" exclaims child $kid_pid.\n";
  print "The child goes to sleep, oblivious of its short future.\n\n";
  sleep(500);
  exit(0);
} else {
  sleep(1);
  print "\"Buwahahaha, child! I will brutally murder you while you ";
  print "peacefully sleep!\" cackles the homicidal parent!\n";
  sleep(3);
  print "The parent sneaks upstairs!\n";
  sleep(1);
  $temp = kill('TERM', $kid_pid);
  printf "The parent attacks!!!! He kills %d child%s!!!\n",
  $temp, ($temp == 1) ? "" : "ren";
  sleep(1);
  $temp2 = kill(0, $kid_pid);
  printf "He decides that isn't enough, and dices %d more poor child%s to pieces!!!\n",
  $temp2, ($temp2 == 1) ? "" : "ren";
}

When I run this program, it says that it's killed 1 child in each of
its messages. I made it sleep in all those places on the off chance that the
problem was that things were executing too quickly & tripping all over each
other.

Am I doing something stupidly wrong?

Thanks,
David Hoover

Perl Info


Site configuration information for perl 5.00404:

Configured by artchan at Sun Dec 21 11:52:30 PST 1997.

Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration:
  Platform:
    osname=solaris, osvers=2.6, archname=sun4-solaris
    uname='sunos despair 5.6 generic sun4m sparc sunw,sparcstation-5 '
    hint=recommended, useposix=true, d_sigaction=define
    bincompat3=y useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-O', gccversion=egcs-2.91.02 971216 (gcc-2.8.0)
    cppflags='-I/usr/local/include'
    ccflags ='-I/usr/local/include'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    voidflags=15, castflags=0, d_casti32=define, d_castneg=define
    intsize=4, alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =''
    libpth=/lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc -lcrypt
    libc=/lib/libc.so, so=so
    useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fpic', lddlflags='-G'

Locally applied patches:
	


@INC for perl 5.00404:
	/usr/local/perl5.004_04/lib/sun4-solaris/5.00404
	/usr/local/perl5.004_04/lib
	/usr/local/perl5.004_04/lib/site_perl/sun4-solaris
	/usr/local/perl5.004_04/lib/site_perl
	.


Environment for perl 5.00404:
    HOME=/mnt/dhoover
    LANG=C
    LD_LIBRARY_PATH=/usr/lib:/usr/openwin/lib:/usr/lib/X11:/usr/local/lib
    LOGDIR (unset)
    PATH=/sbin:/usr/sbin:/usr/local/bin:/bin:/usr/ucb:/usr/bin:/usr/local:/usr/hosts:/etc:/usr/etc:/opt/SUNWspro/v4.2/bin:/opt/SUNWspro/v4.2/bin:/usr/ccs/bin:/mnt/dhoover/bin:/cds/bin:/usr/openwin/bin:/usr/openwin/demo:/usr/openwin/bin/xview:/usr/openwin/fonts:/usr/X11R5/bin:/net/cds317/usr2/mnt2/starb/pvt:/net/cds317/usr2/mnt2/starb/pvt/qaTools/bin:/net/fire/usr1/XFrame5.1/bin:/usr/local/xemacs-19.10/bin:/usr/local/ispell/bin:/opt/netscape:/mnt/dhoover/cmds:/net/snow/usr2/cds/4.4/red/tools/dfII/bin/:.
    PERL_BADLANG (unset)
    SHELL=/bin/csh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant