* Really detaching jobs
@ 2015-10-02 11:56 Dominik Vogt
2015-10-02 12:43 ` Jun T.
0 siblings, 1 reply; 7+ messages in thread
From: Dominik Vogt @ 2015-10-02 11:56 UTC (permalink / raw)
To: Zsh Users
Assuming a client machine is running a terminal emulator which is
running an ssh connection to the server and zsh through that
connection:
Client: rxvt -> ssh
Server: sshd -> zsh ->some job
$ cd gcc-sources/build
$ make -k check-gcc
Is there a way to *really* detach the job so that it will complete
if I close the terminal emulator or kill the ssh connection?
<ctrl-z>
bg
disown %
doesn't work and neither does
make check-gcc &!
I could use nohup, but then I need to plan that before issuing the
command. The cases I care about are really jobs like a test run
of Gcc which can take make hours and cannot be simply continued
after interruption.
Ciao
Dominik ^_^ ^_^
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Really detaching jobs
2015-10-02 11:56 Really detaching jobs Dominik Vogt
@ 2015-10-02 12:43 ` Jun T.
2015-10-02 14:38 ` Dominik Vogt
0 siblings, 1 reply; 7+ messages in thread
From: Jun T. @ 2015-10-02 12:43 UTC (permalink / raw)
To: zsh-users
2015/10/02 20:56, Dominik Vogt <vogt@linux.vnet.ibm.com> wrote:
> Is there a way to *really* detach the job so that it will complete
> if I close the terminal emulator or kill the ssh connection?
You may try GNU screen: https://www.gnu.org/software/screen/
It has a "detach" command, which is exactly what you want.
Searching the net for "GNU screen" will find lots of introductions
and tutorials.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Really detaching jobs
2015-10-02 12:43 ` Jun T.
@ 2015-10-02 14:38 ` Dominik Vogt
2015-10-02 15:08 ` Bart Schaefer
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Dominik Vogt @ 2015-10-02 14:38 UTC (permalink / raw)
To: zsh-users
On Fri, Oct 02, 2015 at 09:43:58PM +0900, Jun T. wrote:
>
> 2015/10/02 20:56, Dominik Vogt <vogt@linux.vnet.ibm.com> wrote:
>
> > Is there a way to *really* detach the job so that it will complete
> > if I close the terminal emulator or kill the ssh connection?
>
> You may try GNU screen: https://www.gnu.org/software/screen/
> It has a "detach" command, which is exactly what you want.
Yeah, but if I had known *in advance* that I'd have the problem,
I'd just have used nohup. So the question is really how to detach
a running process group from the controlling terminal, and whether
zsh can help with that in any way (which I guess it cannot).
Ciao
Dominik ^_^ ^_^
--
Dominik Vogt
IBM Germany
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Really detaching jobs
2015-10-02 14:38 ` Dominik Vogt
@ 2015-10-02 15:08 ` Bart Schaefer
2015-10-02 17:15 ` covici
2015-10-02 18:45 ` Mikael Magnusson
2 siblings, 0 replies; 7+ messages in thread
From: Bart Schaefer @ 2015-10-02 15:08 UTC (permalink / raw)
To: vogt, Zsh Users
On Fri, Oct 2, 2015 at 7:38 AM, Dominik Vogt <vogt@linux.vnet.ibm.com> wrote:
>
>
> Yeah, but if I had known *in advance* that I'd have the problem,
> I'd just have used nohup. So the question is really how to detach
> a running process group from the controlling terminal, and whether
> zsh can help with that in any way (which I guess it cannot).
>
Chances are that the reason the process dies is because sshd has
closed the standard output (the terminal) so it gets a write error.
The only reliable way to detach something is to redirect its outputs
(and inputs), which nohup does. Once the process is running, there's
(generally) no external way to change those file descriptors, the
shell can't do anything after the fact.
The advantage of something like "screen" is that if you ALWAYS use it,
you can stop worrying about knowing in advance.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Really detaching jobs
2015-10-02 14:38 ` Dominik Vogt
2015-10-02 15:08 ` Bart Schaefer
@ 2015-10-02 17:15 ` covici
2015-10-02 18:45 ` Mikael Magnusson
2 siblings, 0 replies; 7+ messages in thread
From: covici @ 2015-10-02 17:15 UTC (permalink / raw)
To: zsh-users
Dominik Vogt <vogt@linux.vnet.ibm.com> wrote:
> On Fri, Oct 02, 2015 at 09:43:58PM +0900, Jun T. wrote:
> >
> > 2015/10/02 20:56, Dominik Vogt <vogt@linux.vnet.ibm.com> wrote:
> >
> > > Is there a way to *really* detach the job so that it will complete
> > > if I close the terminal emulator or kill the ssh connection?
> >
> > You may try GNU screen: https://www.gnu.org/software/screen/
> > It has a "detach" command, which is exactly what you want.
>
> Yeah, but if I had known *in advance* that I'd have the problem,
> I'd just have used nohup. So the question is really how to detach
> a running process group from the controlling terminal, and whether
> zsh can help with that in any way (which I guess it cannot).
>
I just always use tmux and zsh and so if there is a disconnect, its good
to go. Tmusx is just a better version of screen.
--
Your life is like a penny. You're going to lose it. The question is:
How do
you spend it?
John Covici
covici@ccs.covici.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Really detaching jobs
2015-10-02 14:38 ` Dominik Vogt
2015-10-02 15:08 ` Bart Schaefer
2015-10-02 17:15 ` covici
@ 2015-10-02 18:45 ` Mikael Magnusson
2015-10-05 6:52 ` Dominik Vogt
2 siblings, 1 reply; 7+ messages in thread
From: Mikael Magnusson @ 2015-10-02 18:45 UTC (permalink / raw)
To: vogt, Zsh Users
On Fri, Oct 2, 2015 at 4:38 PM, Dominik Vogt <vogt@linux.vnet.ibm.com> wrote:
> On Fri, Oct 02, 2015 at 09:43:58PM +0900, Jun T. wrote:
>>
>> 2015/10/02 20:56, Dominik Vogt <vogt@linux.vnet.ibm.com> wrote:
>>
>> > Is there a way to *really* detach the job so that it will complete
>> > if I close the terminal emulator or kill the ssh connection?
>>
>> You may try GNU screen: https://www.gnu.org/software/screen/
>> It has a "detach" command, which is exactly what you want.
>
> Yeah, but if I had known *in advance* that I'd have the problem,
> I'd just have used nohup. So the question is really how to detach
> a running process group from the controlling terminal, and whether
> zsh can help with that in any way (which I guess it cannot).
This may work with varying degrees of success, https://github.com/nelhage/reptyr
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Really detaching jobs
2015-10-02 18:45 ` Mikael Magnusson
@ 2015-10-05 6:52 ` Dominik Vogt
0 siblings, 0 replies; 7+ messages in thread
From: Dominik Vogt @ 2015-10-05 6:52 UTC (permalink / raw)
To: Zsh Users
On Fri, Oct 02, 2015 at 08:45:21PM +0200, Mikael Magnusson wrote:
> On Fri, Oct 2, 2015 at 4:38 PM, Dominik Vogt <vogt@linux.vnet.ibm.com> wrote:
> > 2015/10/02 20:56, Dominik Vogt <vogt@linux.vnet.ibm.com> wrote:
> > Is there a way to *really* detach the job so that it will complete
> > if I close the terminal emulator or kill the ssh connection?
>
> This may work with varying degrees of success, https://github.com/nelhage/reptyr
That's what I was looking for.
$ reptyr PID > /dev/null 2>&1
does the trick. Thanks!
Ciao
Dominik ^_^ ^_^
--
Dominik Vogt
IBM Germany
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-10-05 6:52 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-02 11:56 Really detaching jobs Dominik Vogt
2015-10-02 12:43 ` Jun T.
2015-10-02 14:38 ` Dominik Vogt
2015-10-02 15:08 ` Bart Schaefer
2015-10-02 17:15 ` covici
2015-10-02 18:45 ` Mikael Magnusson
2015-10-05 6:52 ` Dominik Vogt
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).