Re: How to detach from remote command?
- From: Robert Newson <get.lost@xxxxxxxxxxxxxxxxxxx>
- Date: Sat, 10 Jan 2009 11:25:50 GMT
root wrote:
....
....I want to use rsh (or anything else) to send a command to a machine on
my lan, but I want to detach from that command so I don't have to wait
until the command finishes.
Suppose that every few minutes some machine on the lan
originates a task for a dedicated machine also on
the lan. The dedicated machine only deals with these
tasks. I can't have a user on each machine monitoring
the jobs.
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?
....
I was also thinking of a program on the remote machine
that does nothing but a fork to execute the task, but
uses setpgrp to "detach" from the forking program.
I know that last paragraph is obscure, let me explain.
Suppose I write a program vfork on the remote machine.
I call it like this:
rsh remote vfork command line to be executed
When vfork on the remote machine gets called
it sees its command line arguments as:
comand line to be executed. All vfork does
is execute those arguments via execlp. The
daughter process of vfork, however, is attached
to vfork so rsh waits for the daughter to finish.
So I want to use either setpgid or setpgrp to attach
the daughter process to another task, say the shell
under which some console is running.
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).
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].
.
- Follow-Ups:
- Re: How to detach from remote command?
- From: root
- 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
- 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
|