[
https://issues.apache.org/jira/browse/SSHD-1275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17566420#comment-17566420
]
dgü commented on SSHD-1275:
---------------------------
Hello!
I did some tests about signaling to remote process.
The test runs "/usr/bin/more /tmp/sigtest". After it is invoked, it waits for
user interaction to show the next page. Since there will be no user
interaction, this simulates the remote process sleep.
+When ChannelExec is closed by gracefully+
No remote process is running
{quote}[ubdev@ubdev ~]$ ps -ef|grep more
ubdev 15073 5960 0 18:36 pts/10 00:00:00 grep --color=auto more
{quote}
The remote process is created.
{quote}[ubdev@ubdev ~]$ ps -ef|grep more
ubdev 15156 15147 0 18:36 ? 00:00:00 /usr/bin/more /tmp/sigtest
ubdev 15181 5960 0 18:36 pts/10 00:00:00 grep --color=auto more
{quote}
The remote process called _rt_sigprocmask()_ system call that means a signal
operation occured and then exited with 0.
{quote}[ubdev@ubdev ~]$ strace -ft -p 15156
strace: Process 15156 attached
18:36:32 read(0, "", 4096) = 0
18:37:14 stat("/tmp/sigtest", \{st_mode=S_IFREG|0664, st_size=3528, ...}) = 0
18:37:14 open("/tmp/sigtest", O_RDONLY) = 3
18:37:14 fstat(3, \{st_mode=S_IFREG|0664, st_size=3528, ...}) = 0
18:37:14 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x7fcd46ee9000
18:37:14 lseek(3, 0, SEEK_SET) = 0
18:37:14 read(3, "\0a\0n\0t\0 \0-\0f\0 \0/\0h\0o\0m\0e\0/\0u\0b\0d"..., 4096) =
3528
18:37:14 lseek(3, 3528, SEEK_SET) = 3528
18:37:14 fcntl(3, F_SETFD, FD_CLOEXEC) = 0
18:37:14 fstat(1, \{st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
18:37:14 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x7fcd46ee8000
18:37:14 read(3, "", 4096) = 0
18:37:14 {color:#de350b}rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0{color}
18:37:14 write(1, "::::::::::::::\n/tmp/sigtest\n::::"..., 3571) = 3571
18:37:14 close(3) = 0
18:37:14 munmap(0x7fcd46ee9000, 4096) = 0
18:37:14 close(1) = 0
18:37:14 munmap(0x7fcd46ee8000, 4096) = 0
18:37:14 close(2) = 0
18:37:14 exit_group(0) = ?
18:37:14 {color:#de350b}+++ exited with 0 +++{color}
[ubdev@ubdev ~]$
{quote}
No remote process is running.
{quote}[ubdev@ubdev ~]$ ps -ef|grep more
ubdev 15364 5960 0 18:37 pts/10 00:00:00 grep --color=auto more
[ubdev@ubdev ~]$
{quote}
+When ChannelExec is closed by immediately+
No remote process is running
{quote}[ubdev@ubdev ~]$ ps -ef|grep more
ubdev 16631 5960 0 18:48 pts/10 00:00:00 grep --color=auto more
[ubdev@ubdev ~]$
{quote}
The remote process is created.
{quote}[ubdev@ubdev ~]$ ps -ef|grep more
ubdev 16712 16703 0 18:49 ? 00:00:00 /usr/bin/more /tmp/sigtest
ubdev 16742 5960 0 18:49 pts/10 00:00:00 grep --color=auto more
[ubdev@ubdev ~]$
{quote}
There is no system call activity in the remote process. It sleeps.
{quote}[ubdev@ubdev ~]$ strace -ft -p 16712
strace: Process 16712 attached
18:49:22 read(0,
{quote}
The remote process is still available after channel is closed immediately.
{quote}[ubdev@ubdev tmp]$ ps -ef|grep more
ubdev 16712 16703 0 18:49 ? 00:00:00 /usr/bin/more /tmp/sigtest
ubdev 16819 4006 0 18:50 pts/18 00:00:00 grep --color=auto more
[ubdev@ubdev tmp]$
{quote}
+When the client application exited+
No remote process is running
{quote}[ubdev@ubdev ~]$ ps -ef|grep more
ubdev 16631 5960 0 18:48 pts/10 00:00:00 grep --color=auto more
[ubdev@ubdev ~]$
{quote}
The remote process is created.
{quote}[ubdev@ubdev ~]$ ps -ef|grep more
ubdev 16712 16703 0 18:49 ? 00:00:00 /usr/bin/more /tmp/sigtest
ubdev 16742 5960 0 18:49 pts/10 00:00:00 grep --color=auto more
[ubdev@ubdev ~]$
{quote}
The remote process is terminated by SIGPIPE signal. It's expected since the
client application exited.
{quote}[ubdev@ubdev ~]$ strace -ft -p 16712
strace: Process 16712 attached
18:49:22 read(0, "", 4096) = 0
18:51:04 stat("/tmp/sigtest", \{st_mode=S_IFREG|0664, st_size=3528, ...}) = 0
18:51:04 open("/tmp/sigtest", O_RDONLY) = 3
18:51:04 fstat(3, \{st_mode=S_IFREG|0664, st_size=3528, ...}) = 0
18:51:04 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x7faa286b0000
18:51:04 lseek(3, 0, SEEK_SET) = 0
18:51:04 read(3, "\0a\0n\0t\0 \0-\0f\0 \0/\0h\0o\0m\0e\0/\0u\0b\0d"..., 4096) =
3528
18:51:04 lseek(3, 3528, SEEK_SET) = 3528
18:51:04 fcntl(3, F_SETFD, FD_CLOEXEC) = 0
18:51:04 fstat(1, \{st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
18:51:04 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x7faa286af000
18:51:04 read(3, "", 4096) = 0
18:51:04 {color:#de350b}rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0{color}
18:51:04 write(1, "::::::::::::::\n/tmp/sigtest\n::::"..., 3571) = -1 EPIPE
(Broken pipe)
18:51:04 --- SIGPIPE \{si_signo=SIGPIPE, si_code=SI_USER, si_pid=16712,
si_uid=1000} ---
18:51:04 +++ {color:#de350b}killed by SIGPIPE{color} +++
[ubdev@ubdev ~]$
{quote}
The remote process is not running
{quote}[ubdev@ubdev ~]$ ps -ef|grep more
ubdev 16925 5960 0 18:51 pts/10 00:00:00 grep --color=auto more
[ubdev@ubdev ~]$
{quote}
> Remote process is still available after
> ChannelExec.close(true).awaitUninterruptibly()
> --------------------------------------------------------------------------------------
>
> Key: SSHD-1275
> URL: https://issues.apache.org/jira/browse/SSHD-1275
> Project: MINA SSHD
> Issue Type: Question
> Affects Versions: 2.8.0
> Environment: Java SE 8, Apache NetBeans IDE 8.2
> Reporter: dgü
> Priority: Major
>
> Hello!
> If I close channel immediately by
> {{{}org.apache.sshd.client.channel.ChannelExec.close(true).awaitUninterruptibly(){}}},
> the remote process is not terminated and
> {{org.apache.sshd.client.channel.ChannelExec#getExitStatus()}} returns
> {{{}null{}}}.
> Even if I test with _Thread.sleep(60*1000)_ after channel close, the problem
> still happens. The problem doesn't happen when channel is closed gracefully.
> is this expected behaviour ?
>
> Thanks in advance!
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]