Bug 3383 - ssh can not exit when a command is running in backgroup
Summary: ssh can not exit when a command is running in backgroup
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: ssh (show other bugs)
Version: 8.8p1
Hardware: amd64 Linux
: P5 normal
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_8_9
  Show dependency treegraph
 
Reported: 2022-01-21 01:45 AEDT by John
Modified: 2022-02-25 13:56 AEDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John 2022-01-21 01:45:54 AEDT
Openssh version: 8.8p1-git2e5cfed513e84444483baf1d8b31c40072b05103

ssh -vv ip

#situation 1:
# hanging
[root@localhost ~]# sleep 30 >/dev/null 2>&1 & exit
[1] 15494
logout
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug2: channel 0: rcvd eow
debug2: chan_shutdown_read: channel 0: (i0 o0 sock -1 wfd 4 efd 6 [write])
debug2: channel 0: input open -> closed

#situation 2:
# hanging
[root@localhost ~]# sleep 30 >/dev/null 2>&1 &
[1] 15556
[root@localhost ~]# exit 
logout
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug2: channel 0: rcvd eow
debug2: chan_shutdown_read: channel 0: (i0 o0 sock -1 wfd 4 efd 6 [write])
debug2: channel 0: input open -> closed

#situation 3:
# This is a normal exit
[root@localhost ~]# exit 
logout
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug2: channel 0: obuf empty
debug2: chan_shutdown_write: channel 0: (i0 o1 sock -1 wfd 5 efd 6 [write])
debug2: channel 0: output drain -> closed
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug2: channel 0: rcvd eow
debug2: chan_shutdown_read: channel 0: (i0 o3 sock -1 wfd 4 efd 6 [write])
debug2: channel 0: input open -> closed
debug2: channel 0: rcvd close
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
Connection to 45.77.159.33 closed.
Transferred: sent 2992, received 4408 bytes, in 6.0 seconds
Bytes per second: sent 500.1, received 736.8
debug1: Exit status 0
Comment 1 Damien Miller 2022-01-21 15:02:11 AEDT
But it does exit after 30 seconds, right?

If so, then this is completely intentional. Use nohup if you want to disown background processes.
Comment 2 John 2022-01-21 18:03:13 AEDT
commit  5c79952dfe1aa36105c93b3f383ce9be04dee384
upstream: prepare for conversion of ssh, sshd mainloop from

From this commit, ssh will be hanging.

But before this commit, ssh will exit immediately.

This conversion is not completed, not ready for use yet?
Comment 3 Damien Miller 2022-01-22 11:41:44 AEDT
Thanks for finding the commit that caused this - it was a great help. That commit accidentally disabled a hack for Linux to handle this condition on sessions with ttys. I just pushed a fix in e204b343
Comment 4 Damien Miller 2022-02-25 13:56:43 AEDT
closing bugs resolved before openssh-8.9