Re: How to detach from remote command?
- From: root <NoEMail@xxxxxxxx>
- Date: Sat, 10 Jan 2009 13:04:13 GMT
Robert Newson <get.lost@xxxxxxxxxxxxxxxxxxx> wrote:
You mean the task effectively works in the background on the remote machine,
ie you want to effectively do:
$ task &
but on the remote machine?
If I do
rsh remote sleep 100
the rsh keeps the connection open until the sleep command
terminates. It doesn't matter if I do:
rsh remote sleep 100 "&"
I don't think setpgid() works in the way you think it does...it's use is in
the processing of signals and inputting of data from a terminal (see: man
setpgrp).
You are right about my failure to grasp setpgid. What I wanted to do
was to disassociate the task from the shell that rsh brought up.
I have been different options on my machine then porting them over
to the remote machine. I thought I had something when I created a
program which merely copied the command line over to execlp, but
rand setsid() before the execlp. Something like this:
pid=fork();
if(pid==0){
setsid();
execlp(......);
}
exit(0);
Running this on my machine has the effect of running the command
in the background and the prompt comes back immediately. I later found
that there is a setsid command which does the same thing:
setsid command:
setsid sleep 20
comes right back with the sleep command running in the background.
No luck on the remote machine. rsh stays connected until the
command completes.
Mefinx the problem is that the forked remote process is keeping open the
"tty" (socket) of the rsh (not ssh?) process. Your forking program will
need to close [and reopen] stdin, stdout, stderr (file descriptors 0-2) [to
relevant byte streams - especially stdout/stderr if you want results back
somehow, if no input/output is needed, reconnect to /dev/null].
Here's what I think is happening:
rsh brings up a shell on the remote machine
the shell forks to the command, but stays around until the command finishes
rsh keeps the connection open until the shell closes.
I'm pretty sure now that I can't do what I want.
.
- Follow-Ups:
- Re: How to detach from remote command?
- From: Robert Newson
- Re: How to detach from remote command?
- References:
- How to detach from remote command?
- From: root
- Re: How to detach from remote command?
- From: Robert Newson
- Re: How to detach from remote command?
- From: root
- Re: How to detach from remote command?
- From: Robert Newson
- How to detach from remote command?
- Prev by Date: Re: How to detach from remote command?
- Next by Date: Re: How to detach from remote command?
- Previous by thread: Re: How to detach from remote command?
- Next by thread: Re: How to detach from remote command?
- Index(es):
Relevant Pages
|