Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!gatech!hao!oddjob!sphinx!kdw1 From: kdw1@sphinx.uchicago.edu (Keith Waclena) Newsgroups: comp.unix.questions Subject: Re: bg process into fg (really: fifos) Message-ID: <1679@sphinx.uchicago.edu> Date: Wed, 13-May-87 11:34:46 EDT Article-I.D.: sphinx.1679 Posted: Wed May 13 11:34:46 1987 Date-Received: Sat, 16-May-87 03:18:52 EDT References: <7338@brl-adm.ARPA> <3574@spool.WISC.EDU> Reply-To: kdw1@sphinx.UUCP (Keith Waclena) Organization: University of Chicago, Graduate Library School Lines: 76 In article <3574@spool.WISC.EDU> lm@cottage.WISC.EDU (Larry McVoy) writes: > > Set it up so that upon receipt of the signal, your process opens two > fifo's (I think you might need to be root to create these). The job > will open one for reading, the other for writing. But first close > 0 and 1 (stdin & stdout) so that the file descriptors returned are > also 0 and 1 when you do the opens. > No need to be root; fifos are the only case of using mknod where you needn't be the superuser (Well, one of the only cases anyway..). Fifos are probably the most elegant way to handle the problem; here's a simple program I use to create fifos on the fly, from the shell (sorry, no shar..): -------- Cut Here -------- Cut Here -------- Cut Here -------- Cut Here /* * fifo make one or more fifos * Usage: fifo name ... * Creates a fifo for each argument. * requires system V * Keith Waclena, kdw1@sphinx.uchicago.{UUCP,EDU,BITNET} * Use it as you like; sell it if you can! * This has compiled an run successfully on: * Pyramid 90x under OSx (att universe) * AT&T 3B5 under System V 2.0.1 */ #include #include #include char *myself; /* Name of this program */ char usage[] = "file ..."; /* possible proper args */ main(argc, argv) int argc; char **argv; { int i; /* index of fifo names in argv */ myself = argv[0]; /* our name */ if (argc < 2) { fprintf(stderr, "Usage: %s %s\n", myself, usage); exit(1); } for (i = 1; i < argc; i++) /* For each name on the cmd line */ if (mkfifo(argv[i]) == -1) /* Make a fifo */ perror(myself); /* report any error */ exit(0); } /* * mkfifo: path -> int * Side effect: creates a fifo in the file system at path. * Returns -1 on error. */ int mkfifo(path) char *path; { return mknod(path, S_IFIFO | 0666, 0); } -------- Cut Here -------- Cut Here -------- Cut Here -------- Cut Here Simple as that. I use fifos quite a bit, so I keep a couple in my ~/dev directory. Just don't let tar find 'em heh heh.. Keith Keith Waclena BITNET: kdw1@sphinx.uchicago.bitnet University of Chicago UUCP: ...ihnp4!gargoyle!sphinx!kdw1 Graduate Library School Internet: kdw1@sphinx.uchicago.edu 1100 E. 57th Street Chicago, Illinois 60637 #include