mirror of
https://github.com/webmin/webmin.git
synced 2026-06-19 02:40:32 +01:00
Use proper function to read a line of input
This commit is contained in:
19
miniserv.pl
19
miniserv.pl
@@ -988,8 +988,7 @@ while(1) {
|
||||
# this sub-process is asking about a password
|
||||
local $infd = $passin[$i];
|
||||
local $outfd = $passout[$i];
|
||||
#local $inline = <$infd>;
|
||||
local $inline = &sysread_line($infd);
|
||||
local $inline = <$infd>;
|
||||
if ($inline) {
|
||||
print DEBUG "main: inline $inline";
|
||||
}
|
||||
@@ -3086,22 +3085,6 @@ else {
|
||||
}
|
||||
}
|
||||
|
||||
# sysread_line(fh)
|
||||
# Read a line from a file handle, using sysread to get a byte at a time
|
||||
sub sysread_line
|
||||
{
|
||||
local ($fh) = @_;
|
||||
local $line;
|
||||
while(1) {
|
||||
local ($buf, $got);
|
||||
$got = sysread($fh, $buf, 1);
|
||||
last if ($got <= 0);
|
||||
$line .= $buf;
|
||||
last if ($buf eq "\n");
|
||||
}
|
||||
return $line;
|
||||
}
|
||||
|
||||
# wait_for_data(secs)
|
||||
# Waits at most the given amount of time for some data on SOCK, returning
|
||||
# 0 if not found, 1 if some arrived.
|
||||
|
||||
Reference in New Issue
Block a user