home *** CD-ROM | disk | FTP | other *** search
- From: jensk@hpbbrd.bbn.hp.com (Jens Kilian)
- Date: Tue, 21 Jul 1992 10:51:40 GMT
- Subject: Re: MiNT ptys
- Message-ID: <9130022@hpbbrd.bbn.hp.com>
- Organization: HP Mechanical Design Division
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!usc!sdd.hp.com!hpscdc!hplextra!hpfcso!hpfcmdd!hpbbrd!jensk
- Newsgroups: comp.sys.atari.st.tech
- References: <mfg.711497130@gmd.de>
- Lines: 42
-
- Here's a piece of code I use to run something on a different terminal
- (mainly stolen from Stephen R. Usher's init(8) package):
- ---8<------------------------------------------------------------------8<---
- if (pid == 0) {
- /* This is a child process. */
-
- setpgrp(getpid(), getpid());
-
- if ((ttyfd = open(ttyname, O_RDWR)) < 0) {
- perror(ttyname);
- exit(1);
-
- } else if (! isatty(ttyfd)) {
- close(ttyfd);
- fprintf(stderr, "%s: %s is not a tty\n", progname, ttyname);
- exit(1);
- }
-
- dup2(ttyfd, -1); /* set controlling terminal */
- dup2(ttyfd, 0); /* reconnect standard input, output & error */
- dup2(ttyfd, 1);
- dup2(ttyfd, 2);
-
- close(ttyfd);
-
- spawnvp(P_OVERLAY, execname, execargs);
-
- perror(execname); /* couldn't run program */
- exit(1);
- }
- ---8<------------------------------------------------------------------8<---
-
- Jens
- --
- Internet: jensk@hpbeo82.bbn.hp.com HPDESK : JENS_KILIAN%XU@HP1200
- MausNet: Jens Kilian @ BB KILIAN_JENS/HP1200_XU@hpbbi4
- Phone: (0|+49)7031-14-4308 TELNET : 778-4308
- Fax : (0|+49)7031-14-2049
- -------------------------------------------------------------------------------
- As the air to a bird, or the sea to a fish, so is contempt to the contemptible.
-
-
-