mirror of
https://github.com/curl/curl.git
synced 2025-03-07 15:27:17 +08:00
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
124 lines
3.2 KiB
Perl
Executable File
124 lines
3.2 KiB
Perl
Executable File
#!/usr/bin/env perl
|
|
#***************************************************************************
|
|
# _ _ ____ _
|
|
# Project ___| | | | _ \| |
|
|
# / __| | | | |_) | |
|
|
# | (__| |_| | _ <| |___
|
|
# \___|\___/|_| \_\_____|
|
|
#
|
|
# Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
|
#
|
|
# This software is licensed as described in the file COPYING, which
|
|
# you should have received as part of this distribution. The terms
|
|
# are also available at https://curl.se/docs/copyright.html.
|
|
#
|
|
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
# copies of the Software, and permit persons to whom the Software is
|
|
# furnished to do so, under the terms of the COPYING file.
|
|
#
|
|
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
# KIND, either express or implied.
|
|
#
|
|
#***************************************************************************
|
|
|
|
BEGIN {
|
|
push(@INC, $ENV{'srcdir'}) if(defined $ENV{'srcdir'});
|
|
push(@INC, ".");
|
|
}
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use serverhelp qw(
|
|
server_pidfilename
|
|
server_logfilename
|
|
);
|
|
|
|
use sshhelp qw(
|
|
exe_ext
|
|
);
|
|
|
|
my $verbose = 0; # set to 1 for debugging
|
|
my $port = 8990; # just a default
|
|
my $ipvnum = 4; # default IP version of rtsp server
|
|
my $idnum = 1; # default rtsp server instance number
|
|
my $proto = 'rtsp'; # protocol the rtsp server speaks
|
|
my $pidfile; # rtsp server pid file
|
|
my $portfile;
|
|
my $logfile; # rtsp server log file
|
|
my $srcdir;
|
|
|
|
my $flags = "";
|
|
my $path = '.';
|
|
my $logdir = $path .'/log';
|
|
|
|
while(@ARGV) {
|
|
if($ARGV[0] eq '--pidfile') {
|
|
if($ARGV[1]) {
|
|
$pidfile = $ARGV[1];
|
|
shift @ARGV;
|
|
}
|
|
}
|
|
elsif($ARGV[0] eq '--portfile') {
|
|
if($ARGV[1]) {
|
|
$portfile = $ARGV[1];
|
|
shift @ARGV;
|
|
}
|
|
}
|
|
elsif($ARGV[0] eq '--logfile') {
|
|
if($ARGV[1]) {
|
|
$logfile = $ARGV[1];
|
|
shift @ARGV;
|
|
}
|
|
}
|
|
elsif($ARGV[0] eq '--srcdir') {
|
|
if($ARGV[1]) {
|
|
$srcdir = $ARGV[1];
|
|
shift @ARGV;
|
|
}
|
|
}
|
|
elsif($ARGV[0] eq '--ipv4') {
|
|
$ipvnum = 4;
|
|
}
|
|
elsif($ARGV[0] eq '--ipv6') {
|
|
$ipvnum = 6;
|
|
}
|
|
elsif($ARGV[0] eq '--port') {
|
|
if($ARGV[1] =~ /^(\d+)$/) {
|
|
$port = $1;
|
|
shift @ARGV;
|
|
}
|
|
}
|
|
elsif($ARGV[0] eq '--id') {
|
|
if($ARGV[1] =~ /^(\d+)$/) {
|
|
$idnum = $1 if($1 > 0);
|
|
shift @ARGV;
|
|
}
|
|
}
|
|
elsif($ARGV[0] eq '--verbose') {
|
|
$verbose = 1;
|
|
}
|
|
else {
|
|
print STDERR "\nWarning: rtspserver.pl unknown parameter: $ARGV[0]\n";
|
|
}
|
|
shift @ARGV;
|
|
}
|
|
|
|
if(!$srcdir) {
|
|
$srcdir = $ENV{'srcdir'} || '.';
|
|
}
|
|
if(!$pidfile) {
|
|
$pidfile = "$path/". server_pidfilename($proto, $ipvnum, $idnum);
|
|
}
|
|
if(!$logfile) {
|
|
$logfile = server_logfilename($logdir, $proto, $ipvnum, $idnum);
|
|
}
|
|
|
|
$flags .= "--pidfile \"$pidfile\" ".
|
|
"--portfile \"$portfile\" ".
|
|
"--logfile \"$logfile\" ";
|
|
$flags .= "--ipv$ipvnum --port $port --srcdir \"$srcdir\"";
|
|
|
|
$| = 1;
|
|
exec("exec server/rtspd".exe_ext('SRV')." $flags");
|