mirror of
https://github.com/nmap/nmap.git
synced 2026-10-21 11:22:05 +00:00
Consolidate code to close stdin
Some checks failed
nmap multiplatform autobuilds / build (arm64, gcc, ubuntu-latest-gcc-arm64, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, freebsd-15-clang, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, macos-15-clang, macos-15) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, macos-26-clang, macos-26) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, netbsd-10-clang, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, openbsd-7-clang, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, solaris-11-clang, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, ubuntu-latest-clang, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (egcc, openbsd-7-gcc, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (gcc, freebsd-15-gcc, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (gcc, netbsd-10-gcc, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (gcc, solaris-11-gcc, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (gcc, ubuntu-latest-gcc, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (msvc, windows-latest-msvc, windows-latest) (push) Has been cancelled
Some checks failed
nmap multiplatform autobuilds / build (arm64, gcc, ubuntu-latest-gcc-arm64, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, freebsd-15-clang, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, macos-15-clang, macos-15) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, macos-26-clang, macos-26) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, netbsd-10-clang, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, openbsd-7-clang, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, solaris-11-clang, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, ubuntu-latest-clang, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (egcc, openbsd-7-gcc, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (gcc, freebsd-15-gcc, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (gcc, netbsd-10-gcc, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (gcc, solaris-11-gcc, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (gcc, ubuntu-latest-gcc, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (msvc, windows-latest-msvc, windows-latest) (push) Has been cancelled
This commit is contained in:
parent
5ca93f7762
commit
ddd1494462
1 changed files with 15 additions and 21 deletions
|
|
@ -671,6 +671,19 @@ static void close_fd(struct fdinfo *fdn, int eof) {
|
|||
chat_announce_disconnect(fd);
|
||||
}
|
||||
|
||||
static void close_stdin(int rc) {
|
||||
if (rc < 0 && o.verbose)
|
||||
READ_STDIN_ERR();
|
||||
if (rc == 0 && o.debug)
|
||||
logdebug("EOF on stdin\n");
|
||||
|
||||
/* Don't close the file because that allows a socket to be fd 0. */
|
||||
checked_fd_clr(STDIN_FILENO, &master_readfds);
|
||||
/* Buf mark that we've seen EOF so it doesn't get re-added to the
|
||||
select list. */
|
||||
stdin_eof = 1;
|
||||
}
|
||||
|
||||
/* Read from stdin and broadcast to all client sockets. Return the number of
|
||||
bytes read, or -1 on error. */
|
||||
int read_stdin(struct timeval *qtv)
|
||||
|
|
@ -681,21 +694,13 @@ int read_stdin(struct timeval *qtv)
|
|||
|
||||
nbytes = READ_STDIN(buf, sizeof(buf));
|
||||
if (nbytes <= 0) {
|
||||
if (nbytes < 0 && o.verbose)
|
||||
READ_STDIN_ERR();
|
||||
if (nbytes == 0 && o.debug)
|
||||
logdebug("EOF on stdin\n");
|
||||
close_stdin(nbytes);
|
||||
|
||||
if (o.quitafter > 0) {
|
||||
struct timeval when;
|
||||
gettimeofday(&when, 0);
|
||||
TIMEVAL_MSEC_ADD(*qtv, when, o.quitafter);
|
||||
}
|
||||
/* Don't close the file because that allows a socket to be fd 0. */
|
||||
checked_fd_clr(STDIN_FILENO, &master_readfds);
|
||||
/* Buf mark that we've seen EOF so it doesn't get re-added to the
|
||||
select list. */
|
||||
stdin_eof = 1;
|
||||
|
||||
return nbytes;
|
||||
}
|
||||
|
|
@ -779,18 +784,7 @@ static void read_and_broadcast(int recv_fd)
|
|||
if (recv_fd == STDIN_FILENO) {
|
||||
n = READ_STDIN(buf, sizeof(buf));
|
||||
if (n <= 0) {
|
||||
if (n < 0 && o.verbose)
|
||||
READ_STDIN_ERR();
|
||||
if (n == 0 && o.debug)
|
||||
logdebug("EOF on stdin\n");
|
||||
|
||||
/* Don't close the file because that allows a socket to be
|
||||
fd 0. */
|
||||
checked_fd_clr(recv_fd, &master_readfds);
|
||||
/* But mark that we've seen EOF so it doesn't get re-added to
|
||||
the select list. */
|
||||
stdin_eof = 1;
|
||||
|
||||
close_stdin(n);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue