Hi.
Could someone please have a look at my patches, especially this one, as it's quite a nasty bug, I think. If you need more information, please give me a shout. Thanks, Mark ________________________________ From: Mark Marshall Sent: March 19, 2018 10:31:30 To: busybox@busybox.net Cc: markmarshal...@gmail.com; Mark Marshall Subject: [PATCH 1/2] ash: Set the CLOEXEC bit in fcntl_F_DUPFD From: Mark Marshall <mark.marsh...@omicronenergy.com> The function fcntl_F_DUPFD was introduced as some re-factoring at commit 035486c7500c09616a6c1040d8e70923532a5c2d "ash: significant overhaul of redirect saving logic". The old code used to set the CLOEXEC bit, but this got lost in the re-factoring, so this change makes the new code do the same. This was found because if a script was run via ssh, and this script ran a second script, redirecting its stdin and stdout, and putting it into the background, the ssh would hang waiting for the backgrounded script to terminate. From /proc/999/fd it can be seen that the background script still has the stdin pipe from sshd open (at file handle 10+). Signed-off-by: Mark Marshall <mark.marsh...@omicronenergy.com> --- shell/ash.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/shell/ash.c b/shell/ash.c index 5e281b5..6cf980c 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -5452,13 +5452,20 @@ fcntl_F_DUPFD(int fd, int avoid_fd) { int newfd; repeat: +#if defined(F_DUPFD_CLOEXEC) + newfd = fcntl(fd, F_DUPFD_CLOEXEC, avoid_fd + 1); +#else newfd = fcntl(fd, F_DUPFD, avoid_fd + 1); +#endif if (newfd < 0) { if (errno == EBUSY) goto repeat; if (errno == EINTR) goto repeat; } +#if !defined(F_DUPFD_CLOEXEC) + close_on_exec_on(newfd); +#endif return newfd; } static int -- 2.7.4
_______________________________________________ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox