[Freeipa-devel] [PATCH] 71 Propagate SIGINT to child process in ipautil.run

Martin Kosek mkosek at redhat.com
Thu Mar 22 15:35:07 UTC 2012


On Tue, 2012-03-20 at 17:48 +0100, Jan Cholasta wrote:
> Propagate SIGINT to child process in ipautil.run.
> 
> Wait for the child process to terminate before continuing.
> 
> Do cleanup on KeyboardInterrupt rather than in custom SIGINT handler in 
> ipa-replica-conncheck.
> 
> https://fedorahosted.org/freeipa/ticket/2127
> 
> Honza

This looks and works OK, I have just one minor issue. Isn't the extra
p.wait() you added to the standard run() path redundant? p.communicate()
should do the job of waiting until the child process terminates.

+    try:
+        p = subprocess.Popen(args, stdin=p_in, stdout=p_out,
stderr=p_err,
+                             close_fds=True, env=env)
+        stdout,stderr = p.communicate(stdin)
+        stdout,stderr = str(stdout), str(stderr)    # Make pylint happy
+        p.wait()
+    except KeyboardInterrupt:

Martin




More information about the Freeipa-devel mailing list