この python スクリプトを試してください:
#!/usr/bin/python
# -*- coding: utf8 -*-
import subprocess
import time
import threading
# Create 100 subprocesses
proc = {}
for i in xrange(0,1000):
proc[i] = subprocess.Popen(['ls','-l'])
# create zombies from this processes, observe one minute zombies
time.sleep(60)
# Zombies dead
proc.communicate()
time.sleep(5)
その後、ゾンビをチェックします。
# ps -A | grep defunc
14711 pts/49 00:00:00 ls <defunct>
14713 pts/49 00:00:00 ls <defunct>
14716 pts/49 00:00:00 ls <defunct>
....
14740 pts/49 00:00:00 ls <defunct>
14741 pts/49 00:00:00 ls <defunct>
14742 pts/49 00:00:00 ls <defunct>
14743 pts/49 00:00:00 ls <defunct>
14746 pts/49 00:00:00 ls <defunct>
14749 pts/49 00:00:00 ls <defunct>
....
14805 pts/49 00:00:00 ls <defunct>
14806 pts/49 00:00:00 ls <defunct>
または C:
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int main ()
{
pid_t child_pid;
child_pid = fork ();
if (child_pid > 0) {
sleep (60);
}
else {
exit (0);
}
return 0;
}
透き通った純粋なハイチのブードゥーのように、魅力のように機能するはずです。