Dear all,

I tried starting background processes with lxc-attach and found strange behaviour in Ubuntu Xenial (both container and host).

When I start lxc-attach without command and type my command in shell, it waits for background process to end before completing the exit:

root@host:~# lxc-attach -n test
root@test:~# sleep 10 &
[1] 14607
root@test:~# exit
# hangs here for 10 seconds
root@host:~#

When I do it with nohup it works as indended: no wait, process continues in the background:

root@host:~# lxc-attach -n test
root@test:~# nohup sleep 10 &
[1] 14621
nohup: ignoring input and appending output to 'nohup.out'
root@test:~# exit
root@host:~# lxc-attach -n test -- pgrep sleep
14621
root@host:~#

When I specify command in lxc-attach arguments or pass it non-interactively, background process gets killed, even with nohup! (I wonder what signal it gets.) There're no hangs below:

root@host:~# lxc-attach -n test -- bash -c 'nohup sleep 10 &'
root@host:~# echo 'nohup sleep 10 &' | lxc-attach -n test
root@host:~# lxc-attach -n test -- pgrep sleep
root@host:~#

Finally, nohup bash works:

root@host:~# lxc-attach -n test -- nohup bash -c 'sleep 10 &'
nohup: appending output to 'nohup.out'
root@host:~# echo 'sleep 10 &' | lxc-attach -n test -- nohup bash
nohup: ignoring input and appending output to 'nohup.out'
root@host:~# lxc-attach -n test -- pgrep sleep
14732
14734
root@host:~#

I wonder if this is intended or should be reported as a bug? I guess this is somehow related to missing parent, right?


root@host:~# uname -a
Linux host 4.4.0-78-generic #99-Ubuntu SMP Thu Apr 27 15:29:09 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

root@host:~# lsb_release -a
No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 16.04.2 LTS
Release:    16.04
Codename:    xenial


--

With Best Regards,
Marat Khalili
_______________________________________________
lxc-users mailing list
[email protected]
http://lists.linuxcontainers.org/listinfo/lxc-users

Reply via email to