I work in Unix, and I have a "general tool" that loads another process (GUI utility) on the background, and exits. I call my "general tool" from a Python script, using Popen and municate() method. My "general tool" runs for ~1 second, loads the GUI process on the background and exits immediately. The problem is that municate() continues waiting to the process, although it's already terminated. I have to manually close the GUI (which is a subprocess that runs on the BG), so municate() returns. I need municate() to return once the main process is terminated, and not to wait for the subprocesses that run on the background. My "General Tool" last Main lines (Written in Perl): if ($args->'.format(exit_code, stdout) Print 'This line is printed only when the GUI process is terminated.'ĭon't use communicate. Presumably perl is not closing stdout as it's leaving it open for it's own subprocess to write to.Ĭommunicate is explicitly designed to wait until the stdout of the process has closed. You also don't really need to use Popen as you're not really using its features. That is, you create pipes, and then just reprint to stdout with your own message. And it doesn't look like you need a shell at all.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |