spawn: assert that fork returns int type
authorZac Medico <zmedico@gentoo.org>
Mon, 6 Feb 2012 17:20:05 +0000 (09:20 -0800)
committerZac Medico <zmedico@gentoo.org>
Mon, 6 Feb 2012 17:20:05 +0000 (09:20 -0800)
pym/portage/process.py

index 1ee5b9ae6cd951d82dc49d3c6f02363798e54a34..47b0a214705f937f33c01e1e1572865dd5b7922a 100644 (file)
@@ -244,7 +244,7 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
 
        pid = os.fork()
 
-       if not pid:
+       if pid == 0:
                try:
                        _exec(binary, mycommand, opt_name, fd_pipes,
                              env, gid, groups, uid, umask, pre_exec)
@@ -259,6 +259,9 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
                        sys.stderr.flush()
                        os._exit(1)
 
+       if not isinstance(pid, int):
+               raise AssertionError("fork returned non-integer: %s" % (repr(pid),))
+
        # Add the pid to our local and the global pid lists.
        mypids.append(pid)
        spawned_pids.append(pid)