Path: utzoo!attcan!uunet!husc6!yale!cmcl2!esquire!yost From: yost@DPW.COM (David A. Yost) Newsgroups: comp.windows.x Subject: Re: I'm looking for code to invoke a slave xterm Message-ID: <2712@esquire.dpw.com> Date: 27 Sep 90 14:45:10 GMT References: <2247@esquire.UUCP> Organization: DP&W, New York, NY Lines: 74 In article <2247@esquire.UUCP> I wrote: >I'd like to fork and exec an xterm that has no shell >running in it and whose stdin and stdout are hooked up >to two file descriptors in my process. Anyone done this? Here's a way to do it: xterm -e sockio -il xtermsocket & This runs sockio in the xterm window instead of a shell. The -i option tells sockio to run in interactive (bidirectional copy) mode, and the l option tells it to listen and accept a connection on "xtermsocket", which is a unix domain socket. Then to talk to the xterm window, you do this: sockio -i xtermsocket I will post sockio to comp.unix.sources sometime soon. Here's what it does: Usage: sockio [ -l [ -c ] ] or: sockio -d inet [ ] or: sockio -d inet -l [ -c ] [ ] Options: [ -k ] [ -i ] or [ -r [ -a ] ] [ -v ] [ -s ] Copies between unix or inet stream socket and standard input and/or output in one of three modes: By default, copies from stdin to socket (write mode). -r Read mode: copies from socket to stdout. -i Interactive mode: copies from socket to stdout and from stdin to socket. -l Sockio listens on the socket and accepts a connection. If unix domain, removes the socket file when it exits or is killed. -c Sockio continually listens for and accepts new connections. Otherwise, when the other end closes the connection, sockio exits. -k When the -l option is not given, by default sockio expects the socket to already exist, and exits with status 1 if it doesn't exist. If the -k option is given, it keeps trying to connect. -s How many bytes or lines to copy. A numeric size is a number of bytes, a number followed by an 'l' is a number of lines. -a Used only with -r, the -a option tells sockio to read all it can (up to the given size, if any) until the socket becomes empty, then exit. -v Verbosity: notify on connects and accepts. -d inet Additional arguments: A name or numeric address in dot notation, default is this host. A argument which can be a number or a service name. In the -l case, can be unspecified, in which case a socket number is assigned by the system, and the number reported to stderr. If no -d option is given, then the given is taken as a filename representing a unix domain socket. Examples: sockio -rlc logs | tee logfile & date | sockio logs date | sockio logs or: awk < /dev/null 'BEGIN { for (;;) print ++n }' | sockio -lc -s 1l numbers & sockio -r numbers sockio -r numbers or: xterm -e sockio -il xtermsocket & sockio -i xtermsocket Bug: if the writer is invoked with -l and -c, output data stranded in the socket when the reader closes the socket is lost. --dave yost yost@dpw.com or uunet!esquire!yost Please don't use other mangled forms you may see in the From, Reply-To, or CC fields above.