home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.shell
- Path: sparky!uunet!ftpbox!mothost!merlin.dev.cdx.mot.com!fendahl.dev.cdx.mot.com!mcook
- From: mcook@fendahl.dev.cdx.mot.com (Michael Cook)
- Subject: Re: rshing Ultrix xterms
- Message-ID: <mcook.715394232@fendahl.dev.cdx.mot.com>
- Sender: news@merlin.dev.cdx.mot.com (USENET News System)
- Nntp-Posting-Host: fendahl.dev.cdx.mot.com
- Organization: Motorola Codex, Canton, Massachusetts
- References: <1992Sep1.192315.24302@iscnvx.lmsc.lockheed.com>
- Date: Wed, 2 Sep 1992 00:37:12 GMT
- Lines: 62
-
- rahner@iscnvx.lmsc.lockheed.com (Mark Rahner) writes:
-
- >Hello World,
-
- >I am having trouble rshing an xterm when the remote xterm is started
- >under Ultrix V4.2 (Rev. 96) UWS V4.2 (Rev. 272). Specifically, I can't
- >prevent rsh from hanging around until the remote xterm has completed.
- >I am using the Korn shell on all of the networked systems. It is
- >particularly important to me that the remote xterm be independent of
- >the local xterm. That is, I must be able to terminate the local xterm
- >without affecting the remote xterm.
-
- >And now, a preemptive quote from FAQ 3.2:
-
- >> 2) How do I use "rsh" without having the rsh hang around until the
- >> remote command has completed?
- [...]
- >>
- >> rsh machine -n 'command >/dev/null 2>&1 </dev/null &'
- >>
- >> Why? "-n" attaches rsh's stdin to /dev/null so you could run the
- >> complete rsh command in the background on the LOCAL machine.
- >> Thus "-n" is equivalent to another specific "< /dev/null".
- >> Furthermore, the input/output redirections on the REMOTE machine
- >> (inside the single quotes) ensure that rsh thinks the session can
- >> be terminated (there's no data flow any more.)
-
- I came across the same problem. It seems that there are some stray file
- descriptors being left open somewhere along the line, and rshd is waiting on
- them. My tests show that file descriptors 4, 6, 8, 10, 11 and 12
- (consistently) are left open (along with 0, 1 and 2, of course).
-
- The workaround is to close these extra file descriptors. You can try this:
-
- rsh machine -n 'foo >/dev/null 2>&1 </dev/null' \
- '4>&- 6>&- 8>&- 10>&- 11>&- 12>&-'
-
- but I had trouble finding a shell that would grok two-digit file descriptors
- (sh, sh5 and ksh didn't, but bash did).
-
- Another workaround is to run your command like this:
-
- rsh machine closeall foo
-
- where closeall is this:
-
- #include <sys/param.h>
- #include <fcntl.h>
-
- int main(int argc, char **argv)
- {
- int i;
-
- for (i = 0; i < NOFILE; i++)
- close(i);
- open("/dev/null", O_RDONLY);
- open("/dev/null", O_WRONLY);
- dup(1);
- execvp(argv[1], argv + 1);
- }
-
- Michael.
-