home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / atari / st / tech / 4111 < prev    next >
Encoding:
Internet Message Format  |  1992-07-22  |  1.7 KB

  1. From: jensk@hpbbrd.bbn.hp.com (Jens Kilian)
  2. Date: Tue, 21 Jul 1992 10:51:40 GMT
  3. Subject: Re: MiNT ptys
  4. Message-ID: <9130022@hpbbrd.bbn.hp.com>
  5. Organization: HP Mechanical Design Division
  6. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!usc!sdd.hp.com!hpscdc!hplextra!hpfcso!hpfcmdd!hpbbrd!jensk
  7. Newsgroups: comp.sys.atari.st.tech
  8. References: <mfg.711497130@gmd.de>
  9. Lines: 42
  10.  
  11. Here's a piece of code I use to run something on a different terminal
  12. (mainly stolen from Stephen R. Usher's init(8) package):
  13. ---8<------------------------------------------------------------------8<---
  14.     if (pid == 0) {
  15.         /* This is a child process. */
  16.  
  17.         setpgrp(getpid(), getpid());
  18.  
  19.         if ((ttyfd = open(ttyname, O_RDWR)) < 0) {
  20.             perror(ttyname);
  21.             exit(1);
  22.  
  23.         } else if (! isatty(ttyfd)) {
  24.             close(ttyfd);
  25.             fprintf(stderr, "%s: %s is not a tty\n", progname, ttyname);
  26.             exit(1);
  27.         }
  28.  
  29.         dup2(ttyfd, -1);    /* set controlling terminal */
  30.         dup2(ttyfd, 0);     /* reconnect standard input, output & error */
  31.         dup2(ttyfd, 1);
  32.         dup2(ttyfd, 2);
  33.  
  34.         close(ttyfd);
  35.  
  36.         spawnvp(P_OVERLAY, execname, execargs);
  37.  
  38.         perror(execname);   /* couldn't run program */
  39.         exit(1);
  40.     }
  41. ---8<------------------------------------------------------------------8<---
  42.  
  43.     Jens
  44. --
  45. Internet: jensk@hpbeo82.bbn.hp.com    HPDESK : JENS_KILIAN%XU@HP1200
  46. MausNet:  Jens Kilian @ BB                     KILIAN_JENS/HP1200_XU@hpbbi4
  47. Phone: (0|+49)7031-14-4308            TELNET : 778-4308
  48. Fax  : (0|+49)7031-14-2049
  49. -------------------------------------------------------------------------------
  50. As the air to a bird, or the sea to a fish, so is contempt to the contemptible.
  51.  
  52.  
  53.