Hi.

I'll try to produce a full reproducer tomorrow, but the issue we had was when 
the commands were being executed from sshd, the command that was put into the 
background would still have the files open from sshd, so sshd would think that 
it's commands were still running.  The below is untested, but shows the general 
idea.


z1.sh
=====
z2.sh </dev/null >/dev/null 2>/dev/null &
echo Ok

z2.sh
=====
ls -l /proc/$$/fd   >z2.out1 2>&1
ls -l /proc/self/fd >z2.out2 2>&1
sleep 60


If the two above files are on the machine test, doing

  ssh user@test "z1.sh"

should return before the 60 second sleep has expired.  It does with busybox 
1.24, it doesn't with busybox 1.28.


Regards,

Mark


________________________________
From: Denys Vlasenko <vda.li...@googlemail.com>
Sent: March 28, 2018 17:06
To: Mark Marshall
Cc: busybox
Subject: Re: [PATCH 1/2] ash: Set the CLOEXEC bit in fcntl_F_DUPFD

On Mon, Mar 19, 2018 at 10:31 AM,  <mark.marsh...@omicronenergy.com> wrote:
> 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+).

Please provide a reproducer. I tried this:

z1
==
./busybox ash z2 </dev/null >/dev/null 2>/dev/null &
echo Ok

z2
==
ls -l /proc/$$/fd   >z2.out1 2>&1
ls -l /proc/self/fd >z2.out2 2>&1

I do see some extra fds.

The thing is, when I try it, there is no difference before
and after commit 035486c7500c09616a6c1040d8e70923532a5c2d.
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to