You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Socat's documentation states that when the listen timeout is reached, socat will return an error code.
I'm seeing return code 0 for VSOCK-LISTEN and TCP-LISTEN after timeout, which is incorrect.
Steps To Reproduce
Steps to reproduce the behavior:
Run command socat -d4 TCP-LISTEN:22222,accept-timeout=1 /dev/null in shell with socat
Verify return status behaviour with echo $?
Expected behavior
The value returned from step 2 should not be 0, but it is 0.
Additional context
click here to view socat debug output from my run
2024/06/30 14:30:40 socat[13611] D getpid()
2024/06/30 14:30:40 socat[13611] D getpid() -> 13611
2024/06/30 14:30:40 socat[13611] D setenv("SOCAT_PID", "13611", 1)
2024/06/30 14:30:40 socat[13611] D setenv() -> 0
2024/06/30 14:30:40 socat[13611] D setenv("SOCAT_PPID", "13611", 1)
2024/06/30 14:30:40 socat[13611] D setenv() -> 0
2024/06/30 14:30:40 socat[13611] I socat by Gerhard Rieger and contributors - see www.dest-unreach.org
2024/06/30 14:30:40 socat[13611] I This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org/)
2024/06/30 14:30:40 socat[13611] I This product includes software written by Tim Hudson ([email protected])
2024/06/30 14:30:40 socat[13611] D socat version 1.8.0.0 on 13 Nov 2023 19:31:09
2024/06/30 14:30:40 socat[13611] D setenv("SOCAT_VERSION", "1.8.0.0", 1)
2024/06/30 14:30:40 socat[13611] D setenv() -> 0
2024/06/30 14:30:40 socat[13611] D running on Linux version #1-NixOS SMP PREEMPT_DYNAMIC Thu May 2 14:32:50 UTC 2024, release 6.6.30, machine x86_64
2024/06/30 14:30:40 socat[13611] D argv[0]: "/nix/store/lxppfi8r56w5sjgvidsf9j5mi0584bak-socat-1.8.0.0/bin/socat"
2024/06/30 14:30:40 socat[13611] D argv[1]: "-d4"
2024/06/30 14:30:40 socat[13611] D argv[2]: "TCP-LISTEN:22222,accept-timeout=1"
2024/06/30 14:30:40 socat[13611] D argv[3]: "/dev/null"
2024/06/30 14:30:40 socat[13611] D sigaction(1, 0x7ffc3ab9b9e0, 0x0)
2024/06/30 14:30:40 socat[13611] D sigaction() -> 0
2024/06/30 14:30:40 socat[13611] D sigaction(2, 0x7ffc3ab9b9e0, 0x0)
2024/06/30 14:30:40 socat[13611] D sigaction() -> 0
2024/06/30 14:30:40 socat[13611] D sigaction(3, 0x7ffc3ab9b9e0, 0x0)
2024/06/30 14:30:40 socat[13611] D sigaction() -> 0
2024/06/30 14:30:40 socat[13611] D sigaction(4, 0x7ffc3ab9b9e0, 0x0)
2024/06/30 14:30:40 socat[13611] D sigaction() -> 0
2024/06/30 14:30:40 socat[13611] D sigaction(6, 0x7ffc3ab9b9e0, 0x0)
2024/06/30 14:30:40 socat[13611] D sigaction() -> 0
2024/06/30 14:30:40 socat[13611] D sigaction(7, 0x7ffc3ab9b9e0, 0x0)
2024/06/30 14:30:40 socat[13611] D sigaction() -> 0
2024/06/30 14:30:40 socat[13611] D sigaction(8, 0x7ffc3ab9b9e0, 0x0)
2024/06/30 14:30:40 socat[13611] D sigaction() -> 0
2024/06/30 14:30:40 socat[13611] D sigaction(11, 0x7ffc3ab9b9e0, 0x0)
2024/06/30 14:30:40 socat[13611] D sigaction() -> 0
2024/06/30 14:30:40 socat[13611] D sigaction(15, 0x7ffc3ab9b9e0, 0x0)
2024/06/30 14:30:40 socat[13611] D sigaction() -> 0
2024/06/30 14:30:40 socat[13611] D sigaction(10, 0x7ffc3ab9b9e0, 0x0)
2024/06/30 14:30:40 socat[13611] D sigaction() -> 0
2024/06/30 14:30:40 socat[13611] D signal(13, 0x1)
2024/06/30 14:30:40 socat[13611] D signal() -> 0x0
2024/06/30 14:30:40 socat[13611] D atexit(0x5591fd2de718)
2024/06/30 14:30:40 socat[13611] D atexit() -> 0
2024/06/30 14:30:40 socat[13611] D xioopen("TCP-LISTEN:22222,accept-timeout=1")
2024/06/30 14:30:40 socat[13611] D calloc(1, 928)
2024/06/30 14:30:40 socat[13611] D calloc() -> 0x5591febfbdb0
2024/06/30 14:30:40 socat[13611] D malloc(448)
2024/06/30 14:30:40 socat[13611] D malloc() -> 0x5591febfc1a0
2024/06/30 14:30:40 socat[13611] D getaddrinfo(NULL, "22222", {0x21,0,1,6,0,0x0,0x0,0x0}, 0x7ffc3ab9b4c0)
2024/06/30 14:30:40 socat[13611] D getaddrinfo(,,,{{AF=2 0.0.0.0:22222, }) -> 0
2024/06/30 14:30:40 socat[13611] D getaddrinfo() -> flags=0x21 family=2 socktype=1 protocol=6 addr=AF=2 0.0.0.0:22222
2024/06/30 14:30:40 socat[13611] D getaddrinfo() -> flags=0x21 family=10 socktype=1 protocol=6 addr=AF=10 [0000:0000:0000:0000:0000:0000:0000:0000]:22222
2024/06/30 14:30:40 socat[13611] I xioresolve(node="NULL", service="22222", ...): More than one address found
2024/06/30 14:30:40 socat[13611] D malloc(112)
2024/06/30 14:30:40 socat[13611] D malloc() -> 0x5591febfca40
2024/06/30 14:30:40 socat[13611] D socket(10, 1, 6)
2024/06/30 14:30:40 socat[13611] I socket(10, 1, 6) -> 5
2024/06/30 14:30:40 socat[13611] D fcntl(5, 2, 0x1)
2024/06/30 14:30:40 socat[13611] D fcntl() -> 0x0
2024/06/30 14:30:40 socat[13611] D setsockopt(5, 1, 2, {0x1}, 4)
2024/06/30 14:30:40 socat[13611] D setsockopt() -> 0
2024/06/30 14:30:40 socat[13611] D bind(5, AF=10 [0000:0000:0000:0000:0000:0000:0000:0000]:22222, 28)
2024/06/30 14:30:40 socat[13611] D bind() -> 0
2024/06/30 14:30:40 socat[13611] D listen(5, 5)
2024/06/30 14:30:40 socat[13611] D listen() -> 0
2024/06/30 14:30:40 socat[13611] D getsockname(5, 0x7ffc3ab9b5c0, 0x7ffc3ab9ad04{28})
2024/06/30 14:30:40 socat[13611] D getsockname(, {AF=10 [0000:0000:0000:0000:0000:0000:0000:0000]:22222}, {28}) -> 0
2024/06/30 14:30:40 socat[13611] I starting accept loop
2024/06/30 14:30:40 socat[13611] N listening on AF=10 [0000:0000:0000:0000:0000:0000:0000:0000]:22222
2024/06/30 14:30:40 socat[13611] D select(6, &0x20, &0x0, &0x0, &1.000000)
2024/06/30 14:30:41 socat[13611] D select -> (, 0x0, 0x0, 0x0, &0.000000), 0
2024/06/30 14:30:41 socat[13611] W accept: Connection timed out
2024/06/30 14:30:41 socat[13611] I close(5)
2024/06/30 14:30:41 socat[13611] D close() -> 0
2024/06/30 14:30:41 socat[13611] N Waiting for child processes to terminate
2024/06/30 14:30:41 socat[13611] D sigaction(17, 0x7ffc3ab9aeb0, 0x0)
2024/06/30 14:30:41 socat[13611] D sigaction() -> 0
2024/06/30 14:30:41 socat[13611] D exit(0)
2024/06/30 14:30:41 socat[13611] D starting xioexit()
2024/06/30 14:30:41 socat[13611] I shutdown(5, 2)
2024/06/30 14:30:41 socat[13611] D shutdown() -> -1
2024/06/30 14:30:41 socat[13611] I shutdown(5, 2): Bad file descriptor
2024/06/30 14:30:41 socat[13611] D finished xioexit()
Looking at file xio-listen.c:278-302, from latest release (tag tag-1.8.0.0), there is an exit(0) call after signalling child processes.
That looks like an upstream issue, but I'm gonna leave that triage to more experienced developers.
code fragment
int_xioopen_accept_fd(
structsingle*sfd,
intxioflags,
structsockaddr*us,
socklen_tuslen,
structopt*opts,
intpf,
intproto,
intlevel)
{
// [...]if (!FD_ISSET(sfd->fd, &rfd)) {
structsigactionact;
Warn1("accept: %s", strerror(ETIMEDOUT));
Close(sfd->fd);
Notice("Waiting for child processes to terminate");
memset(&act, 0, sizeof(structsigaction));
act.sa_flags=SA_NOCLDSTOP/*|SA_RESTART*/#ifdefSA_SIGINFO/* not on Linux 2.0(.33) */
|SA_SIGINFO#endif#ifdefSA_NOMASK
|SA_NOMASK#endif
;
#ifHAVE_STRUCT_SIGACTION_SA_SIGACTION&& defined(SA_SIGINFO)
act.sa_sigaction=0;
#else/* Linux 2.0(.33) does not have sigaction.sa_sigaction */act.sa_handler=0;
#endifsigemptyset(&act.sa_mask);
Sigaction(SIGCHLD, &act, NULL);
wait(NULL);
Exit(0);
}
}
// [...]
}
Describe the bug
Socat's documentation states that when the listen timeout is reached, socat will return an error code.
I'm seeing return code 0 for VSOCK-LISTEN and TCP-LISTEN after timeout, which is incorrect.
Steps To Reproduce
Steps to reproduce the behavior:
socat -d4 TCP-LISTEN:22222,accept-timeout=1 /dev/null
in shell with socatecho $?
Expected behavior
The value returned from step 2 should not be 0, but it is 0.
Additional context
click here to view socat debug output from my run
Looking at file xio-listen.c:278-302, from latest release (tag tag-1.8.0.0), there is an exit(0) call after signalling child processes.
That looks like an upstream issue, but I'm gonna leave that triage to more experienced developers.
code fragment
Notify maintainers
@edolstra, as package maintainer
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result.Add a 👍 reaction to issues you find important.
The text was updated successfully, but these errors were encountered: