Newsgroups: fj.unix,fj.sys.sun
Path: galaxy.trc.rwcp.or.jp!coconuts.jaist!wnoc-tyo-news!sinfony-news01!news.kddnet.ad.jp!news.dvlp.kddnet.ad.jp!news.cs.ritsumei.ac.jp!odins-suita!chiba-ns!hagi!is.tsukuba.ac.jp!kaburagi
From: kaburagi@darwin.esys.tsukuba.ac.jp (Yasuhiro Kaburagi)
Subject: About kill()
Date: Sat, 8 Feb 1997 18:00:13 GMT
Mime-Version: 1.0
Nntp-Posting-Host: darwin.esys.tsukuba.ac.jp
X-Newsreader: mnews [version 1.19PL2] 1996-01/26(Fri)
Content-Type: text/plain; charset=ISO-2022-JP
Organization: Institute of Engineering Mechanics, University of Tsukuba, Japan
Sender: news@is.tsukuba.ac.jp (News Manager)
Message-ID: <1997Feb8.180013.28193@is.tsukuba.ac.jp>
Lines: 52
Xref: galaxy.trc.rwcp.or.jp fj.unix:4663 fj.sys.sun:8899
X-originally-archived-at: http://galaxy.rwcp.or.jp/text/cgi-bin/newsarticle2?ng=fj.unix&nb=4663&hd=a
X-reformat-date: Mon, 18 Oct 2004 15:18:22 +0900
X-reformat-comment: Tabs were expanded into 4 column tabstops by the Galaxy's archiver. See http://katsu.watanabe.name/ancientfj/galaxy-format.html for more info.


    $BE-LZ!wC^GHBg3X$H?=$7$^$9!#(B
 
    $B:#!"(Bkill()$B$H$$$&%7%9%F%`%3!<%k$r;H$C$F!"(Bfork()$B$7$?;R%W%m%;%9$,(B
  $B?tIC0JFb$K=*N;$7$F$$$l$P$J$K$b$7$J$$!"=*N;$7$F$$$J$1$l$P!"$=$l$r(B
  $B;&$9$H$$$&%W%m%0%i%`$r=q$$$F$$$^$9!#(B

    $B$=$3$G(Bkill()$B$r8F$s$@$"$H!"(Berrno$B$H(BESRCH$B$rHf3S$7$F=hM}$9$k$h$&$K(B
  $B$7$F$$$k$N$G$9$,!"0J2<$N%W%m%0%i%`$G$O>o$K(Belse$B$NJ}$K$$$C$F$7$^$$(B
  $B$^$9!#K\Mh$J$i!"(Bkill$B$KM?$($?0z?t(Bpid$B$NCM$r;}$D%W%m%;%9$O#2IC8e$K$O(B
  $BB8:_$7$J$$$O$:$J$N$G!"!V(Bchild already done$B!W$H=P$F=*$o$k$H;W$&$N(B
  $B$G$9$,!#!#!#(B

   $B$I$&$7$?$i$$$$$N$+65$($F$$$?$@$1$J$$$G$7$g$&$+!)!#(B

   $B;HMQ$7$F$$$k(BOS$B$O(BSolaris2.5.*$B$G!"%3%s%Q%$%i$OIUB0$N$b$N$G$9!#(B

-----------------------------------------------------------------------

#include <stdio.h>
#include <sys/types.h>
#include <signal.h>
#include <sys/time.h>
#include <errno.h>
#include <unistd.h>

void  main( int argc , char **argv)
{
  pid_t          pid; 

  pid = fork();

  if( pid == 0 )//------$B;R%W%m%;%9(B--------
    {
      exit(0);
    }
  else//----------$B?F%W%m%;%9(B------------
    {
      sleep( 2 );
      kill( pid, SIGTERM );

      if( ESRCH == errno )
{
  printf( "child already done\n");
}
      else
{
  printf( "Never Return\n" );
}
    }
  
}
