1: /* Copyright 1988,1990,1993,1994 by Paul Vixie
   2:  * All rights reserved
   3:  *
   4:  * Distribute freely, except: don't remove my name from the source or
   5:  * documentation (don't take credit for my work), mark your changes (don't
   6:  * get me blamed for your possible bugs), don't alter or remove this
   7:  * notice.  May be sold if buildable source is provided to buyer.  No
   8:  * warrantee of any kind, express or implied, is included with this
   9:  * software; use at your own risk, responsibility for damages (if any) to
  10:  * anyone resulting from the use of this software rests entirely with the
  11:  * user.
  12:  *
  13:  * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
  14:  * I'll try to keep a version up to date.  I can be reached as follows:
  15:  * Paul Vixie          <paul@vix.com>          uunet!decwrl!vixie!paul
  16:  */
  17: 
  18: #if !defined(lint) && !defined(LINT)
  19: static char rcsid[] = "$Id: compat.c,v 1.6 1994/01/15 20:43:43 vixie Exp $";
  20: #endif
  21: 
  22: /* vix 30dec93 [broke this out of misc.c - see RCS log for history]
  23:  * vix 15jan87 [added TIOCNOTTY, thanks csg@pyramid]
  24:  */
  25: 
  26: 
  27: #include "cron.h"
  28: 
  29: #include <fcntl.h>
  30: #include <sys/ioctl.h>
  31: 
  32: /*
  33:  * Ripped off from daemon(3) - differences are this sets the process group
  34:  * and does not fork (because that has been done already).
  35: */
  36: int
  37: setsid()
  38: {
  39:     int newpgrp;
  40:     register int    fd;
  41: 
  42:     newpgrp = setpgrp(0, getpid());
  43:     if  ((fd = open(_PATH_TTY, 2)) >= 0)
  44:         {
  45:         (void) ioctl(fd, TIOCNOTTY, (char*)0);
  46:         (void) close(fd);
  47:         }
  48:     if  ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1)
  49:         {
  50:         (void)dup2(fd, 0);
  51:         (void)dup2(fd, 1);
  52:         (void)dup2(fd, 2);
  53:         if  (fd > 2)
  54:             (void)close(fd);
  55:         }
  56:     return newpgrp;
  57: }

Defined functions

setsid defined in line 36; never used

Defined variables

rcsid defined in line 19; never used
Last modified: 1999-06-16
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1030
Valid CSS Valid XHTML 1.0 Strict