Note that there are some explanatory texts on larger screens.

plurals
  1. POPython Process hangs until child process terminate using tee scheme
    text
    copied!<p>I have a following problem related to process synchronization.</p> <p>There is a python script startup.py, an executable maestro, and an executable tee. My python script startup.py starts maestro program and pipes the stderr/stdout of maestro into the log file using tee as well write into the console.</p> <p>I achieved this using following code:</p> <pre><code>cmd = "maestro" mae_err_log = "output.txt" maestro = subprocess.Popen(cmd, stderr = subprocess.STDOUT, stdout=subprocess.PIPE) tee = subprocess.Popen(['tee', mae_err_log], stdin = maestro.stdout) maestro.stdout.close() tee.communicate() maestro_status = maestro.returncode sys.exit(maestro_status) </code></pre> <p>My maestro program is a gui program when I exit from the maestro program, it internally call posix system("maestro_cleanup &amp;") api and immediately exit. I noticed that my maestro program does not release the console until maestro_cleanup program terminate although I am running maestro_cleanup in the background. I need to run maestro_cleanup in the background as it takes time and I do not want to hold the console for the period until maestro_cleanup finishes. Using above code, maestro program does not terminate until maestro_cleanup finishes.</p> <p>I see "ps -elf" shows following:</p> <pre><code>0 S j 16876 6678 0 75 0 - 65307 wait 18:56 pts/53 00:00:00 python startup.py 0 Z j 17230 16876 4 76 0 - 0 exit 18:56 pts/53 00:00:04 [maestro] &lt;defunct&gt; 0 S j 17231 16876 0 77 0 - 948 pipe_w 18:56 pts/53 00:00:00 /usr/bin/tee output.txt 0 S j 17424 1 0 77 0 - 948 - 18:57 pts/53 00:00:00 maestro_cleanup </code></pre> <p>You can see the maestro_cleanup parent process is session process id instead maestro because I started maestro_cleanup using system api in background.</p> <p>Any idea why maestro does not terminate until maestro_cleanup finishes?</p> <p>Any help would be appreciated.</p> <p>-Vipin</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload