UnixOperatingSystem.st
changeset 3534 126b23939933
parent 3518 82537a8f43fc
child 3536 adad0d12c9a8
equal deleted inserted replaced
3533:59e6bc687f1e 3534:126b23939933
  3031                     /*
  3031                     /*
  3032                     ** In child.
  3032                     ** In child.
  3033                     ** first: dup filedescriptors
  3033                     ** first: dup filedescriptors
  3034                     */
  3034                     */
  3035                     for (i = 0; i < nfd; i++) {
  3035                     for (i = 0; i < nfd; i++) {
  3036                         if (__isSmallInteger(__ArrayInstPtr(fdArray)->a_element[i]) &&
  3036                         OBJ fd;
  3037                             __intVal(__ArrayInstPtr(fdArray)->a_element[i]) != i
  3037                         int rslt;
  3038                         ) {
  3038 
  3039                             dup2(__intVal(__ArrayInstPtr(fdArray)->a_element[i]), i);
  3039                         fd = __ArrayInstPtr(fdArray)->a_element[i];
       
  3040                         if (__isSmallInteger(fd) && (__intVal(fd) != i)) {
       
  3041                             do {
       
  3042                                 rslt = dup2(__intVal(fd), i);
       
  3043                             } while ((rslt < 0) && (errno == EINTR));
  3040                         }
  3044                         }
  3041                     }
  3045                     }
  3042                     /*
  3046                     /*
  3043                     ** second: close unused filedescriptors
  3047                     ** second: close unused filedescriptors
  3044                     */
  3048                     */
  3049                     }
  3053                     }
  3050                     /*
  3054                     /*
  3051                     ** third: close filedescriptors
  3055                     ** third: close filedescriptors
  3052                     */
  3056                     */
  3053                     for (i = 0; i < nclose; i++) {
  3057                     for (i = 0; i < nclose; i++) {
  3054                         if (__isSmallInteger(__ArrayInstPtr(closeFdArray)->a_element[i])) {
  3058                         OBJ fd;
  3055                             close(__intVal(__ArrayInstPtr(closeFdArray)->a_element[i]));
  3059 
       
  3060                         fd = __ArrayInstPtr(closeFdArray)->a_element[i];
       
  3061                         if (__isSmallInteger(fd)) {
       
  3062                             close(__intVal(fd));
  3056                         }
  3063                         }
  3057                     }
  3064                     }
  3058                     if (newPgrp == true) {
  3065                     if (newPgrp == true) {
  3059 # if defined(_POSIX_JOB_CONTROL)
  3066 # if defined(_POSIX_JOB_CONTROL)
  3060                         (void) setpgid(0, 0);
  3067                         (void) setpgid(0, 0);
  5561     "Created: / 23.4.1996 / 16:40:34 / stefan"
  5568     "Created: / 23.4.1996 / 16:40:34 / stefan"
  5562     "Modified: / 27.1.1998 / 20:05:59 / cg"
  5569     "Modified: / 27.1.1998 / 20:05:59 / cg"
  5563 ! !
  5570 ! !
  5564 
  5571 
  5565 !UnixOperatingSystem class methodsFor:'ipc support - UNIX'!
  5572 !UnixOperatingSystem class methodsFor:'ipc support - UNIX'!
       
  5573 
       
  5574 makePTYPair
       
  5575     "make a pipe, return array with two filedescriptors on success,
       
  5576      nil on failure.
       
  5577      This is a lowLevel entry, not for public use.
       
  5578      See ExternalStream>>makePipe for a more user-friendly, public interface."
       
  5579 
       
  5580     |fdS fdM|    
       
  5581                 
       
  5582 %{       
       
  5583 #ifdef IRIX
       
  5584 /*     #include <sys/types.h> /* */
       
  5585 /*     #include <sys/stat.h> /* */
       
  5586 
       
  5587     int _fdM, _fdS;
       
  5588     char *line;
       
  5589 
       
  5590     /*
       
  5591      * Find a pseudo tty to use and open both sides.
       
  5592      *  filedes[0] receives the master file descriptor while filedes[1]
       
  5593      *  receives the slave.  The master is opened with O_NDELAY as commonly
       
  5594      *  needed in daemons such as rlogind and telnetd.
       
  5595      */
       
  5596 
       
  5597     line = _getpty(&_fdM, O_RDWR|O_NDELAY, 0600, 0);
       
  5598     if ((line != 0) && (_fdM >= 0)) {
       
  5599         printf("opening slave side %s\n", line);
       
  5600         _fdS = open(line, O_RDWR);
       
  5601         if (_fdS < 0) {
       
  5602             (void)close(_fdM);
       
  5603             _fdS = _fdM = -1;
       
  5604         }
       
  5605     } else {
       
  5606         _fdM -1;
       
  5607     }
       
  5608     if ((_fdM >= 0) && (_fdS >= 0)) {
       
  5609          fdM = __MKSMALLINT(_fdM);
       
  5610          fdS = __MKSMALLINT(_fdS);
       
  5611     }
       
  5612 #endif
       
  5613 %}.
       
  5614     fdM notNil ifTrue:[
       
  5615         ^ Array with:fdM with:fdS.
       
  5616     ].
       
  5617     ^ nil
       
  5618 !
  5566 
  5619 
  5567 makePipe
  5620 makePipe
  5568     "make a pipe, return array with two filedescriptors on success,
  5621     "make a pipe, return array with two filedescriptors on success,
  5569      nil on failure.
  5622      nil on failure.
  5570      This is a lowLevel entry, not for public use.
  5623      This is a lowLevel entry, not for public use.
  8098 ! !
  8151 ! !
  8099 
  8152 
  8100 !UnixOperatingSystem class methodsFor:'documentation'!
  8153 !UnixOperatingSystem class methodsFor:'documentation'!
  8101 
  8154 
  8102 version
  8155 version
  8103     ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.5 1998-06-05 17:10:27 cg Exp $'
  8156     ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.6 1998-06-09 12:26:56 cg Exp $'
  8104 ! !
  8157 ! !
  8105 UnixOperatingSystem initialize!
  8158 UnixOperatingSystem initialize!