[pve-devel] [PATCH common v2 1/3] fork_worker: refactor passing $upid to parent for sync

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Dec 15 17:00:29 CET 2017


STDOUT and $psync[1] are the same here, so no need to differ.
Also we do this only for letting the parent know tha we're ready, the
parent knows the UPID already as it was generated before forking.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---

no changes since v1

 src/PVE/RESTEnvironment.pm | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/PVE/RESTEnvironment.pm b/src/PVE/RESTEnvironment.pm
index bab4a2e..0ad6dba 100644
--- a/src/PVE/RESTEnvironment.pm
+++ b/src/PVE/RESTEnvironment.pm
@@ -482,12 +482,8 @@ sub fork_worker {
 	}
 
 	# sync with parent (signal that we are ready)
-	if ($sync) {
-	    print "$upid\n";
-	} else {
-	    POSIX::write($psync[1], $upid, length ($upid));
-	    POSIX::close($psync[1]);
-	}
+	POSIX::write($psync[1], $upid, length ($upid));
+	POSIX::close($psync[1]) if !$sync; # don't need output pipe if async
 
 	my $readbuf = '';
 	# sync with parent (wait until parent is ready)
-- 
2.11.0





More information about the pve-devel mailing list