fork, exec를 사용하여 perl에서 android emulator를 실행하려고합니다. 나중에 나는 그것을 죽일 필요가 있지만 그것을 죽이면 배경에서 실행되는 에뮬레이터로 좀비 프로세스가된다.Perl fork(), exec() 그리고 좀비 프로세스 생성을 중단하십시오.
나는 kill -1
과 kill -9
및 killall -v emulator
을 사용하여 살인을 시도했습니다. 또한 명시 적 exec ("exec 명령 ...")을 추가하여 exec'ing을 시도했지만 perl 스크립트가 실행될 때까지 좀비 프로세스를 얻습니다. 나는 과정 I는 좀비 프로세스를 제거하려면 어떻게
------ Processes after killing -----
qureshi 10561 30.0 0.0 0 0 pts/5 R+ 13:28 0:01 [emulator64-arm]
qureshi 10619 0.0 0.0 4396 612 pts/5 S+ 13:28 0:00 sh -c ps aux | grep emulator
qureshi 10621 0.0 0.0 13580 932 pts/5 S+ 13:28 0:00 grep emulator
을 죽이고
------ Processes before killing -----
qureshi 10561 0.0 0.0 3556 980 pts/5 S+ 13:28 0:00 emulator -avd audit -no-snapshot-save
qureshi 10562 0.0 0.0 4396 616 pts/5 S+ 13:28 0:00 sh -c ps aux | grep emulator
qureshi 10564 0.0 0.0 13580 928 pts/5 S+ 13:28 0:00 grep emulator
및
를 참조 출력에서 my $CMD;
my $PID;
sub waitkey()
{
local($|) = (1);
print "Press <Enter> or <Return> to continue: ";
my $resp = <STDIN>;
}
$|++;
$CMD = "emulator -avd audit -no-snapshot-save";
# $CMD = "exec emulator -avd audit -no-snapshot-save";
$PID = fork();
if ($PID==0)
{
print "forked!\n\n";
sleep(1);
exec("$CMD");
die "Unable to execute";
}
print "PID: $PID\n\n";
sleep(1);
print "------ Processes before killing -----\n";
print `ps aux | grep emulator`;
print "------ Press a key to kill -----\n\n"
&waitkey;
# `kill -1 $PID`;
`kill -9 $PID`;
print "------ Processes after killing -----\n";
sleep(1);
print `ps aux | grep emulator`;
print "----- waiting ... -----\n";
#-- do somehing here with assumption that emulator has been killed --
&waitkey;
: 여기
내 코드?