문제

I'm running some C++ code (8 independent processes running on Ubuntu with 8 cores).

I'm launching the C processes using python:

def runC():
    numThreads = multiprocessing.cpu_count()
    threads = []
    for i in range(numThreads):
        args = ("./cprogram", arg1,arg2,arg3)
        popen = subprocess.Popen(args, stdout=subprocess.PIPE,stderr=subprocess.PIPE)
        threads.append(popen)

    for t in threads:
       t.wait()
       output = t.stdout.read()
       err = t.stderr.read()
       if len(output) > 0:
          print "output: " + output
       if len(err) > 0:
          print "err: " + err

I keep getting "defunct" processes. What does that mean? Why did this happen to me?

도움이 되었습니까?

해결책

Turns out it's the t.wait() that is causing the zombie process. Depending on the order that the jobs finish, there will be some in a zombie state until the t.wait() gets around to them. It's not really a problem, which is what I wanted to be sure of.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top