#!/usr/bin/perl

# Copyright (C) 2000 NEC Corporation
# All Rights Reserved.

# RCS: $Id: wbmc_dc_pid,v 1.1 2006/12/22 05:33:58 shodai Exp $

require "/opt/nec/wbmc/lib/wbmc.pl";

# タイマ監視を行う
{
  my($pid) = $ARGV[0];
  my($i,$j,@lines,@line,$flg);
  local(*IN);

  for ($i=0; $i<30; $i++){
    sleep 1;
    # プロセス一覧を読み取る
    open(IN, "/bin/ps -efwwwww |");
    <IN>;
    @lines = <IN>;
    close(IN);

    $flg = 0;
    for ($j = 0; $j <= $#lines; $j++) {
       @line = split(/ +/, $lines[$j]);
       if ($line[1] eq $pid) {
         $flg = 1;
         last;
       }
    }
    if ($flg eq 0) {
       exit(0);
    }
  }
  kill(9, $pid);
  exit(1);
}
