Hi, while running some NetBSD syscall tests I noticed that listen(2) returns the wrong errno when a socket is already connected. man 2 listen already mentions EINVAL.
NetBSD bug: http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=46150 NetBSD patch: http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/uipc_socket.c.diff?r1=1.209&r2=1.210&only_with_tag=MAIN Spec: https://pubs.opengroup.org/onlinepubs/9699919799/ patch attached, mbuhl Index: sys/kern/uipc_socket.c =================================================================== RCS file: /mount/openbsd/cvs/src/sys/kern/uipc_socket.c,v retrieving revision 1.232 diff -u -p -r1.232 uipc_socket.c --- sys/kern/uipc_socket.c 4 Jul 2019 17:42:17 -0000 1.232 +++ sys/kern/uipc_socket.c 9 Jul 2019 16:31:50 -0000 @@ -172,7 +172,7 @@ solisten(struct socket *so, int backlog) int s, error; if (so->so_state & (SS_ISCONNECTED|SS_ISCONNECTING|SS_ISDISCONNECTING)) - return (EOPNOTSUPP); + return (EINVAL); #ifdef SOCKET_SPLICE if (isspliced(so) || issplicedback(so)) return (EOPNOTSUPP);
