]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests/*server.pl: flush output before executing subprocess
authorMarc Hoersken <info@marc-hoersken.de>
Tue, 17 Aug 2021 19:16:41 +0000 (21:16 +0200)
committerMarc Hoersken <info@marc-hoersken.de>
Wed, 18 Aug 2021 18:59:36 +0000 (20:59 +0200)
Also avoid shell processes staying around by using exec.
This is necessary to avoid output data being buffering
inside the process chain of Perl, Bash/Shell and our
test server binaries. On non-Windows systems the exec
will also make the subprocess replace the intermediate
shell, but on Windows it will at least bind the processes
together since there is no real fork or exec available.

See: https://cygwin.com/cygwin-ug-net/highlights.html
and: https://docs.microsoft.com/cpp/c-runtime-library/exec-wexec-functions
Ref: https://github.com/curl/curl/pull/7530#issuecomment-900949010

Reviewed-by: Daniel Stenberg
Reviewed-by: Jay Satiro
Closes #7530

tests/httpserver.pl
tests/rtspserver.pl
tests/runtests.pl
tests/secureserver.pl
tests/sshserver.pl
tests/tftpserver.pl

index fbdb6752cd9c321796c828aba1b1bd4355f478f5..9c50e02d59aa5b58a806f02be8980fcbf6c61d47 100755 (executable)
@@ -152,4 +152,5 @@ if($verbose) {
     print STDERR "RUN: server/sws".exe_ext('SRV')." $flags\n";
 }
 
-exec("server/sws".exe_ext('SRV')." $flags");
+$| = 1;
+exec("exec server/sws".exe_ext('SRV')." $flags");
index bb4bef40d051e78aa1ba81547b422fe2e9b76ac5..471bcbd5e60037e9e575e2f4a0f11ccf354bdfce 100755 (executable)
@@ -119,4 +119,5 @@ $flags .= "--pidfile \"$pidfile\" ".
     "--logfile \"$logfile\" ";
 $flags .= "--ipv$ipvnum --port $port --srcdir \"$srcdir\"";
 
-exec("server/rtspd".exe_ext('SRV')." $flags");
+$| = 1;
+exec("exec server/rtspd".exe_ext('SRV')." $flags");
index 30ae0b34981485e3f74e93c4acee20ce529d356b..577f23467ebd879e369dfb2f0019bf449f6f2c3c 100755 (executable)
@@ -496,6 +496,9 @@ sub startnew {
     if(0 == $child) {
         # Here we are the child. Run the given command.
 
+        # Flush output.
+        $| = 1;
+
         # Put an "exec" in front of the command so that the child process
         # keeps this child's process ID.
         exec("exec $cmd") || die "Can't exec() $cmd: $!";
@@ -4108,6 +4111,9 @@ sub singletest {
         close(GDBCMD);
     }
 
+    # Flush output.
+    $| = 1;
+
     # timestamp starting of test command
     $timetoolini{$testnum} = Time::HiRes::time();
 
index be1de0566329fffc100e0e634044f164a7291688..fb1c4df82bd37c97fd3b256c53076c55726c8e24 100755 (executable)
@@ -341,6 +341,9 @@ if($tstunnel_windows) {
         close(OUT);
     }
 
+    # Flush output.
+    $| = 1;
+
     # Put an "exec" in front of the command so that the child process
     # keeps this child's process ID by being tied to the spawned shell.
     exec("exec $cmd") || die "Can't exec() $cmd: $!";
index 94419390773b5b9467dd78035a34e19b0265b974..90281eb400543b9786fb9fc1c0ed6ebc904457f1 100644 (file)
@@ -1122,6 +1122,9 @@ if ($sshdid =~ /OpenSSH-Windows/) {
         close(OUT);
     }
 
+    # Flush output.
+    $| = 1;
+
     # Put an "exec" in front of the command so that the child process
     # keeps this child's process ID by being tied to the spawned shell.
     exec("exec $cmd") || die "Can't exec() $cmd: $!";
index f9fbbe9bc69c739be7904d284292f5ebd55872d4..d582b5fb68c5e275d7bbaa7f57a645d27124d5c3 100755 (executable)
@@ -120,4 +120,5 @@ $flags .= "--pidfile \"$pidfile\" ".
     "--logfile \"$logfile\" ";
 $flags .= "--ipv$ipvnum --port $port --srcdir \"$srcdir\"";
 
-exec("server/tftpd".exe_ext('SRV')." $flags");
+$| = 1;
+exec("exec server/tftpd".exe_ext('SRV')." $flags");