OpenVMSOperatingSystem.st
changeset 3563 16ccd4cefcbe
parent 3559 e0c61cdbb66f
child 3794 ac9a76e16fef
equal deleted inserted replaced
3562:813c3f1e99d7 3563:16ccd4cefcbe
    17 	category:'OS-OpenVMS'
    17 	category:'OS-OpenVMS'
    18 !
    18 !
    19 
    19 
    20 Object subclass:#FileStatusInfo
    20 Object subclass:#FileStatusInfo
    21 	instanceVariableNames:'type mode uid gid size id accessed modified statusChanged path
    21 	instanceVariableNames:'type mode uid gid size id accessed modified statusChanged path
    22 		alternativeName recordFormatNumeric recordFormat recordAttributes
    22 		recordFormatNumeric recordFormat recordAttributes
    23 		fixedHeaderSize recordSize'
    23 		fixedHeaderSize recordSize'
    24 	classVariableNames:''
    24 	classVariableNames:''
    25 	poolDictionaries:''
    25 	poolDictionaries:''
    26 	privateIn:OpenVMSOperatingSystem
    26 	privateIn:OpenVMSOperatingSystem
    27 !
    27 !
    35 
    35 
    36 !OpenVMSOperatingSystem primitiveDefinitions!
    36 !OpenVMSOperatingSystem primitiveDefinitions!
    37 %{
    37 %{
    38 
    38 
    39 #define UNIX_LIKE       /* assumption: a real operatingSystem */
    39 #define UNIX_LIKE       /* assumption: a real operatingSystem */
    40 
       
    41 #if defined(MSWINDOWS) || defined(OS2) || defined(MSDOS) || defined(WIN32)
       
    42 # ifndef MSDOS_LIKE
       
    43 #  define MSDOS_LIKE
       
    44 # endif
       
    45 # undef UNIX_LIKE       /* oops - we were too optimistic - no OS */
       
    46 # ifdef i386
       
    47 #  ifndef _X86_
       
    48 #   define _X86_
       
    49 #  endif
       
    50 # endif
       
    51 #endif /* any MS-non-OS */
       
    52 
       
    53 #if defined(transputer)
       
    54 # undef MSDOS_LIKE
       
    55 # undef UNIX_LIKE       /* oops - we were too optimistic - no OS */
       
    56 #endif
       
    57 
       
    58 #if defined(_AIX)
       
    59 # ifndef WANT_REALPATH
       
    60 #  define WANT_REALPATH
       
    61 # endif
       
    62 # ifndef WANT_SYSTEM
       
    63 #  define WANT_SYSTEM
       
    64 # endif
       
    65 #endif
       
    66 
       
    67 #ifdef LINUX
       
    68   /* use inline string macros */
       
    69 # define __STRINGDEFS__
       
    70 # include <linuxIntern.h>
       
    71 
       
    72 # ifndef WANT_SYSTEM
       
    73 #  define WANT_SYSTEM
       
    74 # endif
       
    75 # define WANT_SHM
       
    76 #endif
       
    77 
       
    78 #ifdef IRIX5
       
    79 # define WANT_SYSTEM
       
    80 #endif
       
    81 
       
    82 #ifdef ultrix
       
    83 # define WANT_SYSTEM
       
    84 #endif
       
    85 
       
    86 #ifdef hpux
       
    87 # define WANT_SYSTEM
       
    88 #endif
       
    89 
       
    90 #ifdef solaris
       
    91 # define WANT_SYSTEM
       
    92 #endif
       
    93 
       
    94 #if defined(SYSV4) && defined(i386) /* e.g. unixware */
       
    95 # define WANT_SYSTEM
       
    96 #endif
       
    97 
    40 
    98 #ifdef __VMS__
    41 #ifdef __VMS__
    99 # undef __new
    42 # undef __new
   100 # undef HAS_WAITPID
    43 # undef HAS_WAITPID
   101 # undef HAS_WAIT3
    44 # undef HAS_WAIT3
   191  * already block against multiple inclusion, some
   134  * already block against multiple inclusion, some
   192  * do not. Therefore, this is done here again.
   135  * do not. Therefore, this is done here again.
   193  * (it does not hurt)
   136  * (it does not hurt)
   194  */ 
   137  */ 
   195 
   138 
   196 #ifdef WANT_REALPATH
       
   197 
       
   198 # ifndef NO_SYS_PARAM_H
       
   199 #  include <sys/param.h>
       
   200 #  define _SYS_PARAM_H_INCLUDED_
       
   201 # endif
       
   202 
       
   203 # include <errno.h>
       
   204 # define _ERRNO_H_INCLUDED_
       
   205 
       
   206 # include <sys/stat.h>
       
   207 # define _SYS_STAT_H_INCLUDED_
       
   208 
       
   209 #endif /* WANT_REALPATH */
       
   210 
       
   211 
       
   212 #ifdef WANT_SHM
   139 #ifdef WANT_SHM
   213 extern int shmctl(), shmget(), shmdt();
   140 extern int shmctl(), shmget(), shmdt();
   214 extern char * shmat();
   141 extern char * shmat();
   215 
   142 
   216 # include <sys/types.h>
   143 # include <sys/types.h>
   222 # include <sys/shm.h>
   149 # include <sys/shm.h>
   223 # define _SYS_SHM_H_INCLUDED_
   150 # define _SYS_SHM_H_INCLUDED_
   224 
   151 
   225 #endif /* WANT_SHM */
   152 #endif /* WANT_SHM */
   226 
   153 
   227 #ifdef IRIX5
   154 
   228 # include <sys/syssgi.h>
   155 
   229 #endif
   156 #ifndef _SIGNAL_H_INCLUDED_
   230 
   157 # include <signal.h>
   231 
   158 # define _SIGNAL_H_INCLUDED_
   232 #ifdef transputer
   159 #endif
   233 
   160 
   234 # define unlink(f)      ((remove(f) == 0) ? 0 : -1)
   161 #ifdef SYSV
   235 
   162 # ifndef _SYS_TYPES_H_INCLUDED_
   236 #else /* not transputer */
   163 #  include <sys/types.h>
   237 
   164 #  define _SYS_TYPES_H_INCLUDED_
   238 # ifndef _SIGNAL_H_INCLUDED_
   165 # endif
   239 #  include <signal.h>
   166 
   240 #  define _SIGNAL_H_INCLUDED_
   167 # ifndef _SYS_PARAM_H_INCLUDED_
   241 # endif
   168 #  ifndef NO_SYS_PARAM_H
   242 
   169 #   include <sys/param.h>
   243 # ifdef SYSV
   170 #   define _SYS_PARAM_H_INCLUDED_
   244 #  ifndef _SYS_TYPES_H_INCLUDED_
       
   245 #   include <sys/types.h>
       
   246 #   define _SYS_TYPES_H_INCLUDED_
       
   247 #  endif
   171 #  endif
   248 
   172 # endif
   249 #  ifndef _SYS_PARAM_H_INCLUDED_
   173 
   250 #   ifndef NO_SYS_PARAM_H
   174 # ifndef _SYS_TIMES_H_INCLUDED_
   251 #    include <sys/param.h>
   175 #  include <sys/times.h>
   252 #    define _SYS_PARAM_H_INCLUDED_
   176 #  define _SYS_TIMES_H_INCLUDED_
   253 #   endif
       
   254 #  endif
       
   255 
       
   256 #  ifndef _SYS_TIMES_H_INCLUDED_
       
   257 #   include <sys/times.h>
       
   258 #   define _SYS_TIMES_H_INCLUDED_
       
   259 #  endif
       
   260 
       
   261 #  ifndef _SYS_FILE_H_INCLUDED_
       
   262 #   include <sys/file.h>
       
   263 #   define _SYS_FILE_H_INCLUDED_
       
   264 #  endif
       
   265 
       
   266 #  if ! defined(sco3_2)
       
   267 #   ifndef _UNISTD_H_INCLUDED_
       
   268 #    include <unistd.h>
       
   269 #    define _UNISTD_H_INCLUDED_
       
   270 #   endif
       
   271 #  endif
       
   272 
       
   273 #  if defined(isc3_2) || defined(sco3_2)
       
   274 #   ifndef _SYS_TIME_H_INCLUDED_
       
   275 #    include <sys/time.h>
       
   276 #    define _SYS_TIME_H_INCLUDED_
       
   277 #   endif
       
   278 #  endif
       
   279 
       
   280 #  if !defined(isc3_2)
       
   281 #   if defined(PCS) && defined(mips)
       
   282 #    include "/usr/include/bsd/sys/time.h"
       
   283 #    include "/usr/include/sys/time.h"
       
   284 #   else
       
   285 #    ifndef _TIME_H_INCLUDED_
       
   286 #     include <time.h>
       
   287 #     define _TIME_H_INCLUDED_
       
   288 #    endif
       
   289 #   endif
       
   290 #  endif
       
   291 
       
   292 #  if defined(isc3_2)
       
   293 #   include <sys/bsdtypes.h>
       
   294 #  endif
       
   295 
       
   296 # else /* not SYSV */
       
   297 
       
   298 #  ifdef MSDOS_LIKE
       
   299 
       
   300 #   ifndef _SYS_TYPES_H_INCLUDED_
       
   301 #    include <sys/types.h>
       
   302 #    define _SYS_TYPES_H_INCLUDED_
       
   303 #   endif
       
   304 
       
   305 #   ifndef _TIME_H_INCLUDED_
       
   306 #    include <time.h>
       
   307 #    define _TIME_H_INCLUDED_
       
   308 #   endif
       
   309 
       
   310 #   ifndef _SYS_TIMEB_H_INCLUDED_
       
   311 #    include <sys/timeb.h>
       
   312 #    define _SYS_TIMEB_H_INCLUDED_
       
   313 #   endif
       
   314 
       
   315 #  else /* not MSDOS_like */
       
   316 
       
   317 #   ifndef _SYS_TIME_H_INCLUDED_
       
   318 #    include <sys/time.h>
       
   319 #    define _SYS_TIME_H_INCLUDED_
       
   320 #   endif
       
   321 
       
   322 #   ifndef _SYS_TYPES_H_INCLUDED_
       
   323 #    include <sys/types.h>
       
   324 #    define _SYS_TYPES_H_INCLUDED_
       
   325 #   endif
       
   326 
       
   327 #  endif /* not MSDOS */
       
   328 # endif /* not SYSV */
       
   329 
       
   330 
       
   331 # ifdef aix
       
   332 
       
   333 #  ifndef _TIME_H_INCLUDED_
       
   334 #   include <time.h>
       
   335 #   define _TIME_H_INCLUDED_
       
   336 #  endif
       
   337 #  ifndef _SYS_SELECT_H_INCLUDED_
       
   338 #   include <sys/select.h>
       
   339 #   define _SYS_SELECT_H_INCLUDED_
       
   340 #  endif
       
   341 
       
   342 # endif /* aix */
       
   343 
       
   344 
       
   345 # ifndef MSDOS_LIKE
       
   346 
       
   347 #  ifndef _PWD_H_INCLUDED_
       
   348 #   include <pwd.h>
       
   349 #   define _PWD_H_INCLUDED_
       
   350 #  endif
       
   351 
       
   352 #  ifndef NO_GRP_H
       
   353 #   ifndef _GRP_H_INCLUDED_
       
   354 #    include <grp.h>
       
   355 #    define _GRP_H_INCLUDED_
       
   356 #   endif
       
   357 #  endif
       
   358 
       
   359 # endif /* not MSDOS */
       
   360 
       
   361 # ifndef _SYS_STAT_H_INCLUDED_
       
   362 #  include <sys/stat.h>
       
   363 #  define _SYS_STAT_H_INCLUDED_
       
   364 # endif
   177 # endif
   365 
   178 
   366 # ifndef _SYS_FILE_H_INCLUDED_
   179 # ifndef _SYS_FILE_H_INCLUDED_
   367 #  ifndef WIN32
   180 #  include <sys/file.h>
   368 #   include <sys/file.h>
       
   369 #  endif
       
   370 #  define _SYS_FILE_H_INCLUDED_
   181 #  define _SYS_FILE_H_INCLUDED_
   371 # endif
   182 # endif
   372 
   183 
   373 # ifndef _ERRNO_H_INCLUDED_
   184 # ifndef _UNISTD_H_INCLUDED_
   374 #  include <errno.h>
   185 #  include <unistd.h>
   375 #  define _ERRNO_H_INCLUDED_
   186 #  define _UNISTD_H_INCLUDED_
   376 # endif
   187 # endif
   377 
   188 
   378 # ifndef _STDIO_H_INCLUDED_
   189 # ifndef _TIME_H_INCLUDED_
   379 #  include <stdio.h>
   190 #  include <time.h>
   380 #  define _STDIO_H_INCLUDED_
   191 #  define _TIME_H_INCLUDED_
   381 # endif
   192 # endif
   382 
   193 
   383 # ifndef _FCNTL_H_INCLUDED_
   194 #else /* not SYSV */
   384 #  include <fcntl.h>
   195 
   385 #  define _FCNTL_H_INCLUDED_
   196 # ifndef _SYS_TIME_H_INCLUDED_
   386 # endif
   197 #  include <sys/time.h>
   387 
   198 #  define _SYS_TIME_H_INCLUDED_
   388 # ifndef _IOCTL_H_INCLUDED_
   199 # endif
   389 #  ifndef WIN32
   200 
   390 #   include <sys/ioctl.h>
   201 # ifndef _SYS_TYPES_H_INCLUDED_
   391 #   define _IOCTL_H_INCLUDED_
   202 #  include <sys/types.h>
   392 #  endif
   203 #  define _SYS_TYPES_H_INCLUDED_
   393 # endif
   204 # endif
   394 
   205 
   395 # ifdef WIN32
   206 #endif /* not SYSV */
   396 /*#  define PROCESSDEBUGWIN32*/
   207 
   397 #  define xxUSE_TimerProc
   208 #ifndef _PWD_H_INCLUDED_
   398 
   209 # include <pwd.h>
   399 #  undef INT
   210 # define _PWD_H_INCLUDED_
   400 #  undef Array
   211 #endif
   401 #  undef Number
   212 
   402 #  undef Method
   213 #ifndef NO_GRP_H
   403 #  undef Point
   214 # ifndef _GRP_H_INCLUDED_
   404 #  undef Rectangle
   215 #  include <grp.h>
   405 #  undef Block
   216 #  define _GRP_H_INCLUDED_
   406 #  undef String
   217 # endif
   407 #  undef Message
   218 #endif
   408 #  undef Object
   219 
   409 #  undef Context
   220 #ifndef _SYS_STAT_H_INCLUDED_
   410 
   221 # include <sys/stat.h>
   411 /* #  include <windows.h> /* */
   222 # define _SYS_STAT_H_INCLUDED_
   412 #  include <stdarg.h> /* */
   223 #endif
   413 #  include <windef.h> /* */
   224 
   414 #  include <winbase.h> /* */
   225 #ifndef _SYS_FILE_H_INCLUDED_
   415 #  include <wingdi.h> /* */
   226 # include <sys/file.h>
   416 #  include <winuser.h> /* */
   227 # define _SYS_FILE_H_INCLUDED_
   417 #  include <winsock.h> /* */
   228 #endif
   418 
   229 
   419 #  ifdef __DEF_Array
   230 #ifndef _ERRNO_H_INCLUDED_
   420 #   define Array __DEF_Array
   231 # include <errno.h>
   421 #  endif
   232 # define _ERRNO_H_INCLUDED_
   422 #  ifdef __DEF_Number
   233 #endif
   423 #   define Number __DEF_Number
   234 
   424 #  endif
   235 #ifndef _STDIO_H_INCLUDED_
   425 #  ifdef __DEF_Method
   236 # include <stdio.h>
   426 #   define Method __DEF_Method
   237 # define _STDIO_H_INCLUDED_
   427 #  endif
   238 #endif
   428 #  ifdef __DEF_Point
   239 
   429 #   define Point __DEF_Point
   240 #ifndef _FCNTL_H_INCLUDED_
   430 #  endif
   241 # include <fcntl.h>
   431 #  ifdef __DEF_Block
   242 # define _FCNTL_H_INCLUDED_
   432 #   define Block __DEF_Block
   243 #endif
   433 #  endif
   244 
   434 #  ifdef __DEF_String
   245 #ifndef _IOCTL_H_INCLUDED_
   435 #   define String __DEF_String
   246 # ifndef WIN32
   436 #  endif
   247 #  include <sys/ioctl.h>
   437 #  ifdef __DEF_Message
   248 #  define _IOCTL_H_INCLUDED_
   438 #   define Message __DEF_Message
   249 # endif
   439 #  endif
   250 #endif
   440 #  ifdef __DEF_Object
   251 
   441 #   define Object __DEF_Object
   252 
   442 #  endif
   253 #if defined (HAS_LOCALECONV)
   443 #  ifdef __DEF_Context
   254 # ifndef _LOCALE_H_INCLUDED_
   444 #   define Context __DEF_Context
   255 #  include <locale.h>
   445 #  endif
   256 #  define _LOCALE_H_INCLUDED_
   446 
   257 # endif
   447 #  define INT int
   258 #endif
   448 
       
   449 #  define stat _stat
       
   450 #  define WIN32_ERR(x)  ((x) | 0x01000000)      /* tag GetLastError codes */
       
   451 						/* as opposed to Posix errors */
       
   452 
       
   453 typedef int (*intf)(int);
       
   454 BOOL __signalUserInterruptWIN32(DWORD sig);
       
   455 # endif /* WIN32 */
       
   456 
       
   457 
       
   458 # if defined(LINUX)
       
   459 #  define HAS_LOCALECONV
       
   460 # endif
       
   461 
       
   462 # if defined (HAS_LOCALECONV)
       
   463 #  ifndef _LOCALE_H_INCLUDED_
       
   464 #   include <locale.h>
       
   465 #   define _LOCALE_H_INCLUDED_
       
   466 #  endif
       
   467 # endif
       
   468 
   259 
   469 /* 
   260 /* 
   470  * posix systems should define these ... 
   261  * posix systems should define these ... 
   471  * but on some (older) systems, they are not.
   262  * but on some (older) systems, they are not.
   472  */
   263  */
   473 # ifndef S_IXUSR
   264 #ifndef S_IXUSR
   474 #  ifdef S_IEXEC
   265 # ifdef S_IEXEC
   475 #   define S_IXUSR S_IEXEC
   266 #  define S_IXUSR S_IEXEC
   476 #   define S_IXGRP (S_IEXEC>>3)
   267 #  define S_IXGRP (S_IEXEC>>3)
   477 #   define S_IXOTH (S_IEXEC>>6)
   268 #  define S_IXOTH (S_IEXEC>>6)
       
   269 # endif
       
   270 #endif
       
   271 
       
   272 #ifndef S_IXUSR
       
   273 # define S_IXUSR 0100
       
   274 # define S_IXGRP 0010
       
   275 # define S_IXOTH 0001
       
   276 #endif
       
   277 
       
   278 #ifndef S_IRUSR
       
   279 # define S_IRUSR 0400
       
   280 # define S_IRGRP 0040
       
   281 # define S_IROTH 0004
       
   282 #endif
       
   283 
       
   284 #ifndef S_IWUSR
       
   285 # define S_IWUSR 0200
       
   286 # define S_IWGRP 0020
       
   287 # define S_IWOTH 0002
       
   288 #endif
       
   289 
       
   290 #ifndef MAXPATHLEN
       
   291 # ifndef MSDOS_LIKE
       
   292 #  ifndef NO_SYS_PARAM_H
       
   293 #   include <sys/param.h>
   478 #  endif
   294 #  endif
   479 # endif
   295 # endif
   480 
       
   481 # ifndef S_IXUSR
       
   482 #  define S_IXUSR 0100
       
   483 #  define S_IXGRP 0010
       
   484 #  define S_IXOTH 0001
       
   485 # endif
       
   486 
       
   487 # ifndef S_IRUSR
       
   488 #  define S_IRUSR 0400
       
   489 #  define S_IRGRP 0040
       
   490 #  define S_IROTH 0004
       
   491 # endif
       
   492 
       
   493 # ifndef S_IWUSR
       
   494 #  define S_IWUSR 0200
       
   495 #  define S_IWGRP 0020
       
   496 #  define S_IWOTH 0002
       
   497 # endif
       
   498 
       
   499 # ifndef MAXPATHLEN
   296 # ifndef MAXPATHLEN
   500 #  ifndef MSDOS_LIKE
   297 #  ifdef FILENAME_MAX  /* i.e. MSDOS_LIKE */
   501 #   ifndef NO_SYS_PARAM_H
   298 #   define MAXPATHLEN FILENAME_MAX
   502 #    include <sys/param.h>
   299 #  else
       
   300 #   ifdef MAX_PATH
       
   301 #    define MAXPATHLEN MAX_PATH
       
   302 #   else
       
   303 #    define MAXPATHLEN 1024
   503 #   endif
   304 #   endif
   504 #  endif
   305 #  endif
   505 #  ifndef MAXPATHLEN
   306 # endif
   506 #   ifdef FILENAME_MAX  /* i.e. MSDOS_LIKE */
   307 #endif
   507 #    define MAXPATHLEN FILENAME_MAX
   308 
   508 #   else
   309 #if defined(HAS_UNAME)
   509 #    ifdef MAX_PATH
   310 # include <sys/utsname.h>
   510 #     define MAXPATHLEN MAX_PATH
   311 #endif
   511 #    else
   312 
   512 #     define MAXPATHLEN 1024
       
   513 #    endif
       
   514 #   endif
       
   515 #  endif
       
   516 # endif
       
   517 
       
   518 # if defined(HAS_UNAME)
       
   519 #  include <sys/utsname.h>
       
   520 # endif
       
   521 
       
   522 # if defined(SYSV4)
       
   523 #  include <stropts.h>
       
   524 # endif
       
   525 
       
   526 /*
       
   527  * NeXT has no pid_t
       
   528  * and no sigemptyset
       
   529  */
       
   530 # ifdef NEXT3
       
   531    typedef int pid_t;
       
   532 #  define sigemptyset(set)      ((*(set) = 0L), 0)
       
   533 #  define HAS_GETDOMAINNAME
       
   534 #  define NO_WAITPID
       
   535 # endif
       
   536 
       
   537 # ifdef sunos
       
   538 #  undef NO_WAITPID
       
   539 #  undef HAS_WAITPID
       
   540 #  define HAS_WAIT3
       
   541 #  define HAS_SIGACTION
       
   542 # endif
       
   543 
       
   544 # ifdef _AIX
       
   545 #  undef HAS_WAIT3
       
   546 # endif
       
   547 
       
   548 /*
       
   549  * some (BSD ?) have no timezone global,
       
   550  * but provide the info in struct timezone.
       
   551  */
       
   552 # if defined(ultrix) || defined(sunos) || defined(NEXT)
       
   553 #  define HAS_NO_TIMEZONE
       
   554 # endif
       
   555 
   313 
   556 /*
   314 /*
   557  * sigaction dummies (you won't believe these call themself ``POSIX'' systems ...)
   315  * sigaction dummies (you won't believe these call themself ``POSIX'' systems ...)
   558  */
   316  */
   559 # ifndef SA_RESTART
   317 #ifndef SA_RESTART
   560 #  define SA_RESTART    0
   318 # define SA_RESTART    0
   561 # endif
   319 #endif
   562 # ifndef SA_SIGINFO
   320 #ifndef SA_SIGINFO
   563 #  define SA_SIGINFO    0
   321 # define SA_SIGINFO    0
   564 # endif
   322 #endif
   565 
   323 
   566 # if defined(HAS_WAITPID) || defined(HAS_WAIT3)
   324 #if defined(HAS_SYSINFO)
   567 #  include <sys/wait.h>
   325 # include <sys/systeminfo.h>
   568 # endif
   326 #endif
   569 
   327 
   570 # if defined(HAS_SYSINFO)
       
   571 #  include <sys/systeminfo.h>
       
   572 # endif
       
   573 
       
   574 #endif /* not transputer */
       
   575 
   328 
   576 /*
   329 /*
   577  * on some systems errno is a macro ... check for it here
   330  * on some systems errno is a macro ... check for it here
   578  */
   331  */
   579 #ifndef errno
   332 #ifndef errno
   588 # define W_OK    2       /* Test for Write permission */
   341 # define W_OK    2       /* Test for Write permission */
   589 # define X_OK    1       /* Test for eXecute permission */
   342 # define X_OK    1       /* Test for eXecute permission */
   590 # define F_OK    0       /* Test for existence of File */
   343 # define F_OK    0       /* Test for existence of File */
   591 #endif
   344 #endif
   592 
   345 
   593 #ifdef WIN32
   346 #define SIGHANDLER_ARG
   594 # define SIGHANDLER_ARG int
       
   595 #else
       
   596 # define SIGHANDLER_ARG
       
   597 #endif
       
   598 
       
   599 #ifdef sunos
       
   600 # define NO_WAITPID
       
   601 #endif
       
   602 #ifdef NEXT
       
   603 # define NO_WAITPID
       
   604 #endif
       
   605 
       
   606 #ifdef MSDOS_LIKE
       
   607 #define _HANDLEVal(o)        (HANDLE)(__externalAddressVal(o))
       
   608 #endif
       
   609 
   347 
   610 /*
   348 /*
   611  * not all systems have time_t and off_t
   349  * not all systems have time_t and off_t
   612  * explicit add of those we know to have ...
   350  * explicit add of those we know to have ...
   613  */
   351  */
   614 #ifdef __osf__
       
   615 # define TIME_T time_t
       
   616 # define OFF_T  off_t
       
   617 #endif
       
   618 
   352 
   619 #ifndef TIME_T
   353 #ifndef TIME_T
   620 # define TIME_T long
   354 # define TIME_T long
   621 #endif
   355 #endif
   622 #ifndef OFF_T
   356 #ifndef OFF_T
   631 #  define TIMEZONE(tmPtr)       0
   365 #  define TIMEZONE(tmPtr)       0
   632 # else
   366 # else
   633 #  define TIMEZONE(tmPtr)       ((tmPtr)->tm_gmtoff)
   367 #  define TIMEZONE(tmPtr)       ((tmPtr)->tm_gmtoff)
   634 # endif
   368 # endif
   635 #else
   369 #else
   636 # ifdef MSDOS_LIKE
   370 # define TIMEZONE(tmPtr)       timezone
   637 #   define TIMEZONE(tmPtr)      0
       
   638 # else
       
   639 #  define TIMEZONE(tmPtr)       timezone
       
   640 # endif
       
   641 #endif
   371 #endif
   642 
   372 
   643 %}
   373 %}
   644 ! !
   374 ! !
   645 
   375 
   655 %}
   385 %}
   656 ! !
   386 ! !
   657 
   387 
   658 !OpenVMSOperatingSystem primitiveFunctions!
   388 !OpenVMSOperatingSystem primitiveFunctions!
   659 %{
   389 %{
   660 
       
   661 /*
       
   662  * some systems' system() is broken in that it does not correctly 
       
   663  * handle EINTR and returns failure even though it actually succeeded. 
       
   664  * (LINUX is one of them)
       
   665  * Here is a fixed version. If you encounter EINTR returns from
       
   666  * OpenVMSOperatingSystem>>executeCommand, you ought to define WANT_SYSTEM
       
   667  * in the xxxIntern.h file to get this fixed version.
       
   668  *
       
   669  * As an added BONUS, this system() enables interrupts while waiting
       
   670  * for the child which enables other threads to continue.
       
   671  * (i.e. it is RT safe)
       
   672  */
       
   673 
       
   674 #if defined(WANT_SYSTEM)
       
   675 
       
   676 /* # define DPRINTF(x)     printf x */
       
   677 # define DPRINTF(x)     /* nothing */
       
   678 
       
   679 # ifndef _STDDEF_H_INCLUDED_
       
   680 #  include <stddef.h>
       
   681 #  define _STDDEF_H_INCLUDED_
       
   682 # endif
       
   683 
       
   684 # ifndef _STDLIB_H_INCLUDED_
       
   685 #  include <stdlib.h>
       
   686 #  define _STDLIB_H_INCLUDED_
       
   687 # endif
       
   688 
       
   689 # ifndef _UNISTD_H_INCLUDED_
       
   690 #  include <unistd.h>
       
   691 #  define _UNISTD_H_INCLUDED_
       
   692 # endif
       
   693 
       
   694 # ifndef _SYS_WAIT_H_INCLUDED
       
   695 #  include <sys/wait.h>
       
   696 #  define _SYS_WAIT_H_INCLUDED
       
   697 # endif
       
   698 
       
   699 # ifndef _SIGNAL_H_INCLUDED_
       
   700 #  include <signal.h>
       
   701 #  define _SIGNAL_H_INCLUDED_
       
   702 # endif
       
   703 
       
   704 # ifndef _SYS_TYPES_H_INCLUDED_
       
   705 #  include <sys/types.h>
       
   706 #  define _SYS_TYPES_H_INCLUDED_
       
   707 # endif
       
   708 
       
   709 # if (!defined(HAVE_GNU_LD) && !defined (__ELF__)) || !defined(LINUX)
       
   710 #  define       __environ       environ
       
   711 #  if !defined(LINUX)
       
   712 #   define      __sigemptyset   sigemptyset
       
   713 #   define      __sigaction     sigaction
       
   714 #   define      __sigaddset     sigaddset
       
   715 #   define      __sigprocmask   sigprocmask
       
   716 #   define      __execve        execve
       
   717 #   define      __wait          wait
       
   718 #   define      __waitpid       waitpid
       
   719 #   if defined(HAS_VFORK)
       
   720 #    define     FORK            vfork
       
   721 #   else
       
   722 #    define     FORK            fork
       
   723 #   endif
       
   724 #  endif /* ! LINUX */
       
   725    extern char **environ;
       
   726 # endif
       
   727 
       
   728 # define        SHELL_PATH      "/bin/sh"       /* Path of the shell.  */
       
   729 # define        SHELL_NAME      "sh"            /* Name to give it.  */
       
   730 
       
   731 # ifndef        FORK
       
   732 #  define       FORK    __fork
       
   733 # endif
       
   734 
       
   735 # ifndef CONST
       
   736 #  ifdef __GNUC__
       
   737 #   define CONST const
       
   738 #  else
       
   739 #   define CONST /* nothing */
       
   740 #  endif
       
   741 # endif
       
   742 
       
   743 static int
       
   744 mySystem(line)
       
   745     register CONST char *line;
       
   746 {
       
   747     int status, save;
       
   748     pid_t pid;
       
   749     struct sigaction sa, intr, quit;
       
   750     sigset_t block, omask;
       
   751 
       
   752     if (line == NULL)
       
   753 	return -1;
       
   754 
       
   755     sa.sa_handler = SIG_IGN;
       
   756     sa.sa_flags = 0;
       
   757     __sigemptyset (&sa.sa_mask);
       
   758 
       
   759     if (__sigaction (SIGINT, &sa, &intr) < 0) {
       
   760 	DPRINTF(("1: errno=%d\n", errno));
       
   761 	return -1;
       
   762     }
       
   763     if (__sigaction (SIGQUIT, &sa, &quit) < 0) {
       
   764 	save = errno;
       
   765 	(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
       
   766 	errno = save;
       
   767 	DPRINTF(("2: errno=%d\n", errno));
       
   768 	return -1;
       
   769     }
       
   770 
       
   771     __sigemptyset (&block);
       
   772     __sigaddset (&block, SIGCHLD);
       
   773     save = errno;
       
   774     if (__sigprocmask(SIG_BLOCK, &block, &omask) < 0) {
       
   775 	if (errno == ENOSYS)
       
   776 	    errno = save;
       
   777 	else {
       
   778 	    save = errno;
       
   779 	    (void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL);
       
   780 	    (void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
       
   781 	    errno = save;
       
   782 	    DPRINTF(("3: errno=%d\n", errno));
       
   783 	    return -1;
       
   784 	}
       
   785     }
       
   786 
       
   787     pid = FORK ();
       
   788     if (pid == (pid_t) 0) {
       
   789 	/* Child side.  */
       
   790 	CONST char *new_argv[4];
       
   791 	new_argv[0] = SHELL_NAME;
       
   792 	new_argv[1] = "-c";
       
   793 	new_argv[2] = line;
       
   794 	new_argv[3] = NULL;
       
   795 
       
   796 	/* Restore the signals.  */
       
   797 	(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
       
   798 	(void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
       
   799 	(void) __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL);
       
   800 
       
   801 	/* Exec the shell.  */
       
   802 	(void) __execve (SHELL_PATH, (char *CONST *) new_argv, __environ);
       
   803 	_exit (127);
       
   804     } else {
       
   805 	if (pid < (pid_t) 0) {
       
   806 	    /* The fork failed.  */
       
   807 	    DPRINTF(("4: errno=%d\n", errno));
       
   808 	    status = -1;
       
   809 	} else {
       
   810 	    /* Parent side.  */
       
   811 #ifdef  NO_WAITPID
       
   812 	    pid_t child;
       
   813 
       
   814 	    do {
       
   815 		__BEGIN_INTERRUPTABLE__
       
   816 		child = __wait (&status);
       
   817 		__END_INTERRUPTABLE__
       
   818 		if (child < 0 && errno != EINTR) {
       
   819 		    DPRINTF(("5: errno=%d\n", errno));
       
   820 		    status = -1;
       
   821 		    break;
       
   822 		}
       
   823 	    } while (child != pid);
       
   824 #else
       
   825 	    pid_t child;
       
   826 
       
   827 	    /* claus: the original did not care for EINTR here ... */
       
   828 	    do {
       
   829 		__BEGIN_INTERRUPTABLE__
       
   830 		child = __waitpid (pid, &status, 0);
       
   831 		__END_INTERRUPTABLE__
       
   832 	    } while ((child != pid) && (errno == EINTR));
       
   833 	    if (child != pid) {
       
   834 		DPRINTF(("6: errno=%d\n", errno));
       
   835 		status = -1;
       
   836 	    }
       
   837 #endif /* NO_WAITPID */
       
   838 	}
       
   839     }
       
   840     save = errno;
       
   841     if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL)
       
   842      | __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL)
       
   843      | __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)) != 0) {
       
   844 	if (errno == ENOSYS) {
       
   845 	    errno = save;
       
   846 	} else {
       
   847 	    status = -1;
       
   848 	    DPRINTF(("7: errno=%d\n", errno));
       
   849 	}
       
   850     }
       
   851 
       
   852     return status;
       
   853 }
       
   854 #else
       
   855 # define __wait wait
       
   856 #endif /* WANT_SYSTEM */
       
   857 
       
   858 
       
   859 /*
       
   860  * some systems do not have realpath();
       
   861  * the alternative of reading from a 'pwp'-pipe
       
   862  * is way too slow. Here is a realpath for the rest of us.
       
   863  * define WANT_REALPATH in the xxxIntern-file to get it.
       
   864  */
       
   865 
       
   866 #if defined(HAS_REALPATH)
       
   867 # undef WANT_REALPATH
       
   868 #endif
       
   869 #if !defined(HAS_GETWD) && !defined(HAS_GETCWD)
       
   870 # undef WANT_REALPATH
       
   871 #endif
       
   872 
       
   873 #if defined(WANT_REALPATH)
       
   874 
       
   875 # ifndef NULL
       
   876 #  define NULL (char *)0
       
   877 # endif
       
   878 
       
   879 # define MAX_READLINKS 32
       
   880 
       
   881 # ifndef MAXPATHLEN
       
   882 #  define MAXPATHLEN     1024
       
   883 # endif
       
   884 
       
   885 static
       
   886 char *realpath(path, resolved_path)
       
   887 char *path;
       
   888 char resolved_path [];
       
   889 {
       
   890 	char copy_path[MAXPATHLEN];
       
   891 	char link_path[MAXPATHLEN];
       
   892 	char *new_path = resolved_path;
       
   893 	char *max_path;
       
   894 	int readlinks = 0;
       
   895 	int n;
       
   896 
       
   897 	/* Make a copy of the source path since we may need to modify it. */
       
   898 	strcpy(copy_path, path);
       
   899 	path = copy_path;
       
   900 	max_path = copy_path + MAXPATHLEN - 2;
       
   901 	/* If it's a relative pathname use getwd for starters. */
       
   902 	if (*path != '/') {
       
   903 #ifdef HAS_GETCWD
       
   904 		new_path = getcwd(new_path, MAXPATHLEN - 1);
       
   905 #else
       
   906 		new_path = getwd(new_path);
       
   907 #endif
       
   908 		if (new_path == NULL) 
       
   909 		    return(NULL);
       
   910 
       
   911 		new_path += strlen(new_path);
       
   912 		if (new_path[-1] != '/')
       
   913 			*new_path++ = '/';
       
   914 	}
       
   915 	else {
       
   916 		*new_path++ = '/';
       
   917 		path++;
       
   918 	}
       
   919 	/* Expand each slash-separated pathname component. */
       
   920 	while (*path != '\0') {
       
   921 		/* Ignore stray "/". */
       
   922 		if (*path == '/') {
       
   923 			path++;
       
   924 			continue;
       
   925 		}
       
   926 		if (*path == '.') {
       
   927 			/* Ignore ".". */
       
   928 			if (path[1] == '\0' || path[1] == '/') {
       
   929 				path++;
       
   930 				continue;
       
   931 			}
       
   932 			if (path[1] == '.') {
       
   933 				if (path[2] == '\0' || path[2] == '/') {
       
   934 					path += 2;
       
   935 					/* Ignore ".." at root. */
       
   936 					if (new_path == resolved_path + 1)
       
   937 						continue;
       
   938 					/* Handle ".." by backing up. */
       
   939 					while ((--new_path)[-1] != '/')
       
   940 						;
       
   941 					continue;
       
   942 				}
       
   943 			}
       
   944 		}
       
   945 		/* Safely copy the next pathname component. */
       
   946 		while (*path != '\0' && *path != '/') {
       
   947 			if (path > max_path) {
       
   948 				errno = ENAMETOOLONG;
       
   949 				return NULL;
       
   950 			}
       
   951 			*new_path++ = *path++;
       
   952 		}
       
   953 #ifdef S_IFLNK
       
   954 		/* Protect against infinite loops. */
       
   955 		if (readlinks++ > MAX_READLINKS) {
       
   956 			errno = ELOOP;
       
   957 			return NULL;
       
   958 		}
       
   959 		/* See if latest pathname component is a symlink. */
       
   960 		*new_path = '\0';
       
   961 		n = readlink(resolved_path, link_path, MAXPATHLEN - 1);
       
   962 		if (n < 0) {
       
   963 			/* EINVAL means the file exists but isn't a symlink. */
       
   964 			if (errno != EINVAL)
       
   965 				return NULL;
       
   966 		}
       
   967 		else {
       
   968 			/* Note: readlink doesn't add the null byte. */
       
   969 			link_path[n] = '\0';
       
   970 			if (*link_path == '/')
       
   971 				/* Start over for an absolute symlink. */
       
   972 				new_path = resolved_path;
       
   973 			else
       
   974 				/* Otherwise back up over this component. */
       
   975 				while (*(--new_path) != '/')
       
   976 					;
       
   977 			/* Safe sex check. */
       
   978 			if (strlen(path) + n >= MAXPATHLEN) {
       
   979 				errno = ENAMETOOLONG;
       
   980 				return NULL;
       
   981 			}
       
   982 			/* Insert symlink contents into path. */
       
   983 			strcat(link_path, path);
       
   984 			strcpy(copy_path, link_path);
       
   985 			path = copy_path;
       
   986 		}
       
   987 #endif /* S_IFLNK */
       
   988 		*new_path++ = '/';
       
   989 	}
       
   990 	/* Delete trailing slash but don't whomp a lone slash. */
       
   991 	if (new_path != resolved_path + 1 && new_path[-1] == '/')
       
   992 		new_path--;
       
   993 	/* Make sure it's null terminated. */
       
   994 	*new_path = '\0';
       
   995 	return resolved_path;
       
   996 }
       
   997 # define HAS_REALPATH
       
   998 #endif /* WANT_REALPATH && not HAS_REALPATH */
       
   999 
   390 
  1000 #ifdef __VMS__
   391 #ifdef __VMS__
  1001 
   392 
  1002 /* #define TRACE_STAT_CALLS /* */
   393 /* #define TRACE_STAT_CALLS /* */
  1003 /* #define TRACE_ACCESS_CALLS /* */
   394 /* #define TRACE_ACCESS_CALLS /* */
  2921 		msg = "No route to host";
  2312 		msg = "No route to host";
  2922 		sym = @symbol(EHOSTUNREACH);
  2313 		sym = @symbol(EHOSTUNREACH);
  2923 		break;
  2314 		break;
  2924 #endif
  2315 #endif
  2925 
  2316 
  2926 #ifdef WIN32
       
  2927 	    /*
       
  2928 	     * WIN32 GetLastError returns
       
  2929 	     */
       
  2930 # ifdef ERROR_FILE_NOT_FOUND
       
  2931 	    case WIN32_ERR(ERROR_FILE_NOT_FOUND):
       
  2932 		msg = "File not found";
       
  2933 		sym = @symbol(ERROR_FILE_NOT_FOUND);
       
  2934 		break;
       
  2935 # endif
       
  2936 # ifdef ERROR_BROKEN_PIPE
       
  2937 	    case WIN32_ERR(ERROR_BROKEN_PIPE):
       
  2938 		msg = "Broken pipe";
       
  2939 		sym = @symbol(ERROR_BROKEN_PIPE);
       
  2940 		break;
       
  2941 # endif
       
  2942 
       
  2943 #endif /* WINM32 */
       
  2944 
       
  2945 #ifdef __VMS__
  2317 #ifdef __VMS__
  2946 # ifdef EVMSERR
  2318 # ifdef EVMSERR
  2947 	    case EVMSERR:
  2319 	    case EVMSERR:
  2948 		msg = "VMS system request error";
  2320 		msg = "VMS system request error";
  2949 		sym = @symbol(EVMSERR);
  2321 		sym = @symbol(EVMSERR);
  3032 	    mbxName_in := self mailBoxNameOf:channelIn.
  2404 	    mbxName_in := self mailBoxNameOf:channelIn.
  3033 	].
  2405 	].
  3034 	(channelOut := fdArray at:2) notNil ifTrue:[
  2406 	(channelOut := fdArray at:2) notNil ifTrue:[
  3035 	    mbxName_out := self mailBoxNameOf:channelOut.
  2407 	    mbxName_out := self mailBoxNameOf:channelOut.
  3036 	].
  2408 	].
  3037     ]
  2409     ].
  3038 
  2410 
  3039 %{  /* STACK: 16000 */
  2411 %{  /* STACK: 16000 */
       
  2412 
  3040 #ifdef __VMS__
  2413 #ifdef __VMS__
  3041     /*
  2414     /*
  3042      * if fork is false, chain to another command (not yet supported)
  2415      * if fork is false, chain to another command (not yet supported)
  3043      * otherwise, spawn a subprocess and let it execute the command.
  2416      * otherwise, spawn a subprocess and let it execute the command.
  3044      * Currently, only the forking version is supported (who chains anyway ?)
  2417      * Currently, only the forking version is supported (who chains anyway ?)
  3045      * Only stdIn & stdOut are allowed in fdArray;
  2418      * Only stdIn & stdOut are allowed in fdArray;
  3046      */
  2419      */
  3047     char fullCmdLine[1024];
  2420     char fullCmdLine[1024];
  3048     char cliBuffer[1024];
  2421     char cliBuffer[1024];
  3049 
  2422 
  3050     if (__isString(aCommandPath) && __isString(argArray)){
  2423     if (__isString(aCommandPath) && __isString(argArray)) {
  3051 	struct dsc$descriptor_s cmddsc, clidsc, in_mbxdsc, out_mbxdsc;
  2424 	struct dsc$descriptor_s cmddsc, clidsc, in_mbxdsc, out_mbxdsc;
  3052 	int status;
  2425 	int status;
  3053 	static struct Vstring in_mbxname, out_mbxname;
  2426 	static struct Vstring in_mbxname, out_mbxname;
  3054 	int in_channel, out_channel;
  2427 	int in_channel, out_channel;
  3055 	int flags;
  2428 	int flags;
  3214 	    RETURN (__MKUINT(pInfo->pid));
  2587 	    RETURN (__MKUINT(pInfo->pid));
  3215 	} else {
  2588 	} else {
  3216 	    /* should never be called that way ... */
  2589 	    /* should never be called that way ... */
  3217 	}
  2590 	}
  3218     }
  2591     }
  3219 
       
  3220 #endif /* VMS */
  2592 #endif /* VMS */
  3221 %}.
  2593 %}.
  3222     "
  2594     "
  3223      path-argument not string
  2595      path-argument not string
  3224      or argArray not an array/nil
  2596      or argArray not an array/nil
  4301 	 size            - files size
  3673 	 size            - files size
  4302 	 id              - files number (i.e. inode number)
  3674 	 id              - files number (i.e. inode number)
  4303 	 accessed        - last access time (as Timestamp)
  3675 	 accessed        - last access time (as Timestamp)
  4304 	 modified        - last modification time (as Timestamp)
  3676 	 modified        - last modification time (as Timestamp)
  4305 	 statusChanged   - last status change time (as Timestamp)
  3677 	 statusChanged   - last status change time (as Timestamp)
  4306 	 alternativeName - (windows only: the MSDOS name of the file)
  3678 	 alternativeName     - (windows only:) the MSDOS name of the file
       
  3679 	 recordFormatNumeric - (VMS only:) numeric value of the recordFormat
       
  3680 	 recordFormat        - (VMS only:) symbolic value of the recordFormat
       
  3681 	 recordAttributes    - (VMS only:) recordAttributes
       
  3682 	 fixedHeaderSize     - (VMS only:) fixed header size in a variable record format
       
  3683 	 recordSize          - (VMS only:) record size.
  4307 
  3684 
  4308      Some of the fields may be returned as nil on systems which do not provide
  3685      Some of the fields may be returned as nil on systems which do not provide
  4309      all of the information.
  3686      all of the information.
  4310      Return nil if such a file does not exist. 
  3687      Return nil if such a file does not exist. 
  4311      For symbolic links (if supported by the OS), 
  3688      For symbolic links (if supported by the OS), 
  4481 		    size:size 
  3858 		    size:size 
  4482 		    id:id 
  3859 		    id:id 
  4483 		    accessed:atime 
  3860 		    accessed:atime 
  4484 		    modified:mtime 
  3861 		    modified:mtime 
  4485 		    statusChanged:ctime
  3862 		    statusChanged:ctime
  4486 		    path:nil
  3863 		    path:nil.
  4487 		    alternativeName:name2.
       
  4488 
  3864 
  4489 	recordFormat notNil ifTrue:[
  3865 	recordFormat notNil ifTrue:[
  4490 	    "/ additional VMS info
  3866 	    "/ additional VMS info
  4491 	    info
  3867 	    info
  4492 		recordFormat:recordFormat
  3868 		recordFormat:recordFormat
  4823      For nonexistent files, nil is returned."
  4199      For nonexistent files, nil is returned."
  4824 
  4200 
  4825     "could be implemented as:
  4201     "could be implemented as:
  4826 	(self infoOf:aPathName) accessed 
  4202 	(self infoOf:aPathName) accessed 
  4827     "
  4203     "
       
  4204 
  4828     |osSeconds i|
  4205     |osSeconds i|
  4829 %{
  4206 %{
  4830 #if !defined(WIN32) && !defined(__VMS__)
  4207 #if !defined(WIN32) && !defined(__VMS__)
  4831     struct stat buf;
  4208     struct stat buf;
  4832     time_t mtime;
  4209     time_t mtime;
  5381 	    case SIGINT:
  4758 	    case SIGINT:
  5382 #endif
  4759 #endif
  5383 #ifdef SIGQUIT
  4760 #ifdef SIGQUIT
  5384 	    case SIGQUIT:
  4761 	    case SIGQUIT:
  5385 #endif
  4762 #endif
  5386 #  ifdef WIN32
  4763 #ifdef WIN32
  5387 #ifdef PROCESSDEBUGWIN32
  4764 # ifdef PROCESSDEBUGWIN32
  5388 		printf("ConsoleSignal %d\n",sigNr);
  4765 		printf("ConsoleSignal %d\n",sigNr);
  5389 #endif
  4766 # endif
  5390 		SetConsoleCtrlHandler((PHANDLER_ROUTINE)__signalUserInterruptWIN32,TRUE);
  4767 		SetConsoleCtrlHandler((PHANDLER_ROUTINE)__signalUserInterruptWIN32,TRUE);
  5391 		RETURN (self);
  4768 		RETURN (self);
  5392 #else
  4769 #else
  5393 # if defined(SIGINT) || defined(SIGQUIT) || defined(SIGBREAK)
  4770 # if defined(SIGINT) || defined(SIGQUIT) || defined(SIGBREAK)
  5394 		handler = __signalUserInterrupt;
  4771 		handler = __signalUserInterrupt;
  5436 	    case CHILD_SIGNAL:
  4813 	    case CHILD_SIGNAL:
  5437 		handler = __signalChildInterrupt;
  4814 		handler = __signalChildInterrupt;
  5438 		break;
  4815 		break;
  5439 #endif
  4816 #endif
  5440 #ifdef SIGALRM
  4817 #ifdef SIGALRM
  5441 # ifndef WIN32
       
  5442 	    case SIGALRM:
  4818 	    case SIGALRM:
  5443 		handler = __signalTimerInterrupt;
  4819 		handler = __signalTimerInterrupt;
  5444 		break;
  4820 		break;
  5445 # endif
       
  5446 #endif
  4821 #endif
  5447 
  4822 
  5448 	    default:
  4823 	    default:
  5449 		handler = __signalInterrupt;
  4824 		handler = __signalInterrupt;
  5450 		break;
  4825 		break;
  5473 	    sigemptyset(&vec.sv_mask);
  4848 	    sigemptyset(&vec.sv_mask);
  5474 	    vec.sv_handler = handler;
  4849 	    vec.sv_handler = handler;
  5475 	    sigvec(sigNr, &vec, NULL);
  4850 	    sigvec(sigNr, &vec, NULL);
  5476 # else
  4851 # else
  5477 #  ifdef WIN32
  4852 #  ifdef WIN32
  5478 #ifdef PROCESSDEBUGWIN32
  4853 #   ifdef PROCESSDEBUGWIN32
  5479 	    printf("signal %d can't change handler\n",sigNr);
  4854 	    printf("signal %d can't change handler\n",sigNr);
  5480 #endif
  4855 #   endif
  5481 #  else
  4856 #  else
  5482 	    (void) signal(sigNr, handler);
  4857 	    (void) signal(sigNr, handler);
  5483 #  endif
  4858 #  endif
  5484 # endif
  4859 # endif
  5485 #endif
  4860 #endif
  5592       self primTerminateProcess:processId
  4967       self primTerminateProcess:processId
  5593     ] ifFalse:[
  4968     ] ifFalse:[
  5594       self sendSignal:(self sigKILL) to:processId.
  4969       self sendSignal:(self sigKILL) to:processId.
  5595     ].
  4970     ].
  5596     "Modified: 28.12.1995 / 15:06:18 / stefan"
  4971     "Modified: 28.12.1995 / 15:06:18 / stefan"
  5597 !
       
  5598 
       
  5599 primTerminateProcess:pid
       
  5600     "terminate a WIN32 process.
       
  5601     The TerminateProcess function is used to unconditionally cause
       
  5602     a process to exit. Use it only in extreme circumstances. The state of
       
  5603     global data maintained by dynamic-link libraries (DLLs)
       
  5604     may be compromised if TerminateProcess is used."
       
  5605 
       
  5606 !
  4972 !
  5607 
  4973 
  5608 sendSignal:signalNumber to:processId
  4974 sendSignal:signalNumber to:processId
  5609     "send a unix signal to some process (maybe myself).
  4975     "send a unix signal to some process (maybe myself).
  5610      Returns false if any error occurred, true otherwise.
  4976      Returns false if any error occurred, true otherwise.
  6331     int pid = 0;
  5697     int pid = 0;
  6332 
  5698 
  6333     /* XXX TODO */
  5699     /* XXX TODO */
  6334 #ifdef UNIX_LIKE
  5700 #ifdef UNIX_LIKE
  6335     pid = getpid();
  5701     pid = getpid();
  6336 #else
       
  6337 # ifdef WIN32
       
  6338     pid = GetCurrentProcessId() & 0x3FFFFFFF;
       
  6339 # endif
       
  6340 #endif
  5702 #endif
  6341     RETURN ( __MKSMALLINT(pid) );
  5703     RETURN ( __MKSMALLINT(pid) );
  6342 %}
  5704 %}
  6343     "
  5705     "
  6344      OpenVMSOperatingSystem getProcessId
  5706      OpenVMSOperatingSystem getProcessId
  7047     t = (ticks * 1000) / HZ;
  6409     t = (ticks * 1000) / HZ;
  7048 #   define HAVE_TIME
  6410 #   define HAVE_TIME
  7049 #  endif /* old SYSV stuff */
  6411 #  endif /* old SYSV stuff */
  7050 # endif
  6412 # endif
  7051 
  6413 
  7052 # ifndef HAVE_TIME
       
  7053 #  ifdef WIN32
       
  7054     t = GetTickCount();
       
  7055 #   define HAVE_TIME
       
  7056 #  endif
       
  7057 # endif
       
  7058 
       
  7059 # ifndef HAVE_TIME
       
  7060 #  ifdef MSDOS_LIKE
       
  7061     struct _timeb timebuffer;
       
  7062 
       
  7063     _ftime(&timebuffer);
       
  7064     t = (timebuffer.time * 1000) + timebuffer.millitm;
       
  7065 #   define HAVE_TIME
       
  7066 #  endif
       
  7067 # endif
       
  7068 #endif
  6414 #endif
  7069 
  6415 
  7070 #ifndef HAVE_TIME
  6416 #ifndef HAVE_TIME
  7071     /* assume HAS_GETTIMEOFDAY 
  6417     /* assume HAS_GETTIMEOFDAY 
  7072      * - will result in a linkage error
  6418      * - will result in a linkage error
  7224      (however, a delay cannot be used in the event handler or scheduler)"
  6570      (however, a delay cannot be used in the event handler or scheduler)"
  7225 
  6571 
  7226     |now then delta|
  6572     |now then delta|
  7227 
  6573 
  7228 %{  /* NOCONTEXT */
  6574 %{  /* NOCONTEXT */
  7229 #ifdef xxWIN32
       
  7230     /*
       
  7231      * does not work under WIN95 - sigh
       
  7232      */
       
  7233     int t = __intVal(millis);
       
  7234 
       
  7235     if (t) {
       
  7236 	Sleep(t);
       
  7237     }
       
  7238     RETURN (self);
       
  7239 #endif
       
  7240 #ifdef __openVMS__
  6575 #ifdef __openVMS__
  7241 # ifdef HAS_USLEEP
  6576 # ifdef HAS_USLEEP
  7242     int millis = __intVal(millis);
  6577     int millis = __intVal(millis);
  7243     int micros;
  6578     int micros;
  7244 
  6579 
  7473 	}
  6808 	}
  7474     } else {
  6809     } else {
  7475 	name = cachedName;
  6810 	name = cachedName;
  7476     }
  6811     }
  7477 # else /* openVMS */
  6812 # else /* openVMS */
  7478 # endif
       
  7479 #else
       
  7480 # ifdef WIN32
       
  7481     if (firstCall) {
       
  7482 	int nameSize = sizeof(cachedName);
       
  7483 
       
  7484 	if (GetUserName(cachedName, &nameSize) == TRUE) {
       
  7485 	    name = cachedName;
       
  7486 	    firstCall = 0;
       
  7487 	}
       
  7488     } else {
       
  7489 	name = cachedName;
       
  7490     }
       
  7491 # endif
  6813 # endif
  7492 #endif
  6814 #endif
  7493     /*
  6815     /*
  7494      * try a few common environment variables ...
  6816      * try a few common environment variables ...
  7495      */
  6817      */
  7670      "return true, if childProcessWait: blocks, if no children are ready.
  6992      "return true, if childProcessWait: blocks, if no children are ready.
  7671       On those systems, we must be somewhat careful when looking out for
  6993       On those systems, we must be somewhat careful when looking out for
  7672       a subprocesses status (to avoid blocking)."
  6994       a subprocesses status (to avoid blocking)."
  7673 
  6995 
  7674 %{ /*NOCONTEXT*/
  6996 %{ /*NOCONTEXT*/
  7675 #if defined(HAS_WAITPID) || defined(HAS_WAIT3) || defined(WIN32) || defined(__VMS__)
  6997 #if defined(__VMS__)
  7676     RETURN(false);
  6998     RETURN(false);
  7677 #else
  6999 #else
  7678     RETURN(true);
  7000     RETURN(true);
  7679 #endif
  7001 #endif
  7680 %}
  7002 %}
  7690      Note that win32 needs to know the HANDLE of the process on which 
  7012      Note that win32 needs to know the HANDLE of the process on which 
  7691      it waits.  In case of an error, THIS ALWAYS WAITS and then times out."
  7013      it waits.  In case of an error, THIS ALWAYS WAITS and then times out."
  7692 
  7014 
  7693     |pid status code core|
  7015     |pid status code core|
  7694 %{
  7016 %{
  7695 #ifdef WIN32
       
  7696     DWORD endStatus;
       
  7697  
       
  7698     if (__isExternalAddress(pidToWait) ) {
       
  7699 	endStatus = WaitForSingleObject( _HANDLEVal(pidToWait), blocking==true ? INFINITE : 0 );
       
  7700 	if ( endStatus == WAIT_TIMEOUT ) {
       
  7701 	     status = @symbol(timeout);
       
  7702 	     /* mhmh david - shouln't we return nil here ? */
       
  7703 	     RETURN(nil);
       
  7704 	} else {
       
  7705 	     status = @symbol(exit);
       
  7706 	}
       
  7707 	code = __MKSMALLINT(endStatus);
       
  7708 	core = false;
       
  7709 	pid = pidToWait;
       
  7710     }
       
  7711 #endif
       
  7712 
       
  7713 #ifdef __VMS__
  7017 #ifdef __VMS__
  7714     {
  7018     {
  7715 	long endStatus, endPid;
  7019 	long endStatus, endPid;
  7716 
  7020 
  7717 	if (! __vms_waitPid(-1, &endStatus, &endPid)) {
  7021 	if (! __vms_waitPid(-1, &endStatus, &endPid)) {
  7724 	code = __MKUINT(endStatus);
  7028 	code = __MKUINT(endStatus);
  7725 	pid = __MKUINT(endPid);
  7029 	pid = __MKUINT(endPid);
  7726 	core = false;
  7030 	core = false;
  7727     }
  7031     }
  7728 #endif /* __VMS__ */
  7032 #endif /* __VMS__ */
  7729 
       
  7730 #if defined(UNIX_LIKE) && !defined(__VMS__)
       
  7731     int p;
       
  7732 
       
  7733 # if defined(HAS_WAITPID)
       
  7734 
       
  7735     int s;
       
  7736 #   define __WAIT     waitpid(-1, &s, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED)
       
  7737 
       
  7738 # else
       
  7739 #  if defined(HAS_WAIT3)
       
  7740 
       
  7741     union wait s;
       
  7742 #   define __WAIT      wait3(&s, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED, 0)
       
  7743 
       
  7744 #  else /* neither waitpid, nor wait3; use wait, which is blocking */
       
  7745 
       
  7746     int s;
       
  7747 #   define __WAIT      wait(&s)
       
  7748 #   define __BLOCKING_WAIT__ 1
       
  7749 
       
  7750     if (blocking != true) {
       
  7751 	/*
       
  7752 	 * We do not support nonBlocking waits, so signal an error
       
  7753 	 * Sorry about the goto, but with all these ifdefs ...
       
  7754 	 */
       
  7755 	goto done;
       
  7756     }
       
  7757 #  endif /*!HAS_WAIT3*/
       
  7758 # endif  /*!HAS_WAITPID*/
       
  7759 
       
  7760 # if !defined(WIFEXITED)
       
  7761 #  define WIFEXITED(stat)      (((int)((stat)&0377))==0)
       
  7762 #  define WIFSIGNALED(stat)    (((int)((stat)&0377))>0&&((int)(((stat)>>8)&0377))==0)
       
  7763 #  define WIFSTOPPED(stat)     (((int)((stat)&0377))==0177&&((int)(((stat)>>8)&0377))!=0)
       
  7764 
       
  7765 #  define WEXITSTATUS(stat)    ((int)(((stat)>>8)&0377))
       
  7766 #  define WTERMSIG(stat)       (((int)((stat)&0377))&0177)
       
  7767 #  define WSTOPSIG(stat)       ((int)(((stat)>>8)&0377))
       
  7768 # endif /*!WIFEXITED*/
       
  7769 
       
  7770 # if !defined(WCOREDUMP)
       
  7771    /*
       
  7772     * some systems lack that definition, although the field is there ...
       
  7773     */
       
  7774 #  if defined(HAS_WAIT3)
       
  7775 #   define WCOREDUMP(status)    (((union __wait*)&(status))->__w_coredump)
       
  7776 #  else
       
  7777 #   define WCOREDUMP(status)    ((int)(((status)>>8)&0200))
       
  7778 #  endif
       
  7779 # endif /*!WCOREDUMP*/
       
  7780 
       
  7781 # if __BLOCKING_WAIT__
       
  7782     __BEGIN_INTERRUPTABLE__
       
  7783 # endif
       
  7784 
       
  7785     do {
       
  7786 	p = __WAIT;
       
  7787     } while (p == -1 && errno == EINTR);
       
  7788 
       
  7789 # if __BLOCKING_WAIT__
       
  7790     __END_INTERRUPTABLE__
       
  7791 #   undef __BLOCKING_WAIT__
       
  7792 # endif
       
  7793 
       
  7794 # undef __WAIT
       
  7795 
       
  7796     if (p == 0)
       
  7797 	RETURN(nil)
       
  7798 
       
  7799     if (p == -1) {
       
  7800 	if (errno == ECHILD)
       
  7801 	    RETURN(nil);
       
  7802     } else {
       
  7803 	pid = __MKSMALLINT(p);
       
  7804 	if (WIFEXITED(s)) {
       
  7805 	    status = @symbol(exit);
       
  7806 	    code = __MKSMALLINT(WEXITSTATUS(s));
       
  7807 	    core = WCOREDUMP(s) ? true : false;
       
  7808 	} else if (WIFSIGNALED(s)) {
       
  7809 	    status = @symbol(signal);
       
  7810 	    code = __MKSMALLINT(WTERMSIG(s));
       
  7811 	} else if (WIFSTOPPED(s)) {
       
  7812 	    status = @symbol(stop);
       
  7813 	    code = __MKSMALLINT(WSTOPSIG(s));
       
  7814 	}
       
  7815 # if defined(WIFCONTINUED)
       
  7816 	else if (WIFCONTINUED(s)) {
       
  7817 	    status = @symbol(continue);
       
  7818 	} 
       
  7819 # endif
       
  7820     }
       
  7821 done: ;
       
  7822 #endif /* UNIX_LIKE */
       
  7823 %}.
  7033 %}.
  7824 
  7034 
  7825     (status isNil or:[pid isNil]) ifTrue:[
  7035     (status isNil or:[pid isNil]) ifTrue:[
  7826 	^ self primitiveFailed
  7036 	^ self primitiveFailed
  7827     ].
  7037     ].
  7844 %{
  7054 %{
  7845 #ifdef NOTDEF   /* does not work ... */
  7055 #ifdef NOTDEF   /* does not work ... */
  7846     /*
  7056     /*
  7847      * if available, try FIONREAD first, which is usually done faster.
  7057      * if available, try FIONREAD first, which is usually done faster.
  7848      */
  7058      */
  7849 # if defined(FIONREAD) && !defined(WIN32)
  7059 # if defined(FIONREAD)
  7850     {
  7060     {
  7851 	int n;
  7061 	int n;
  7852 
  7062 
  7853 	if (__isSmallInteger(fd)) {
  7063 	if (__isSmallInteger(fd)) {
  7854 	    if (ioctl(__intVal(fd), FIONREAD, &n) >= 0) {
  7064 	    if (ioctl(__intVal(fd), FIONREAD, &n) >= 0) {
  7870 %{
  7080 %{
  7871 #ifdef NOTDEF   /* does not work ... */
  7081 #ifdef NOTDEF   /* does not work ... */
  7872     /*
  7082     /*
  7873      * if available, try FIONREAD first, which is usually done faster.
  7083      * if available, try FIONREAD first, which is usually done faster.
  7874      */
  7084      */
  7875 # if defined(FIONREAD) && !defined(WIN32)
  7085 # if defined(FIONREAD)
  7876     {
  7086     {
  7877 	int n;
  7087 	int n;
  7878 
  7088 
  7879 	if (__isSmallInteger(fd)) {
  7089 	if (__isSmallInteger(fd)) {
  7880 	    if (n = ioctl(__intVal(fd), FIONREAD)) {
  7090 	    if (n = ioctl(__intVal(fd), FIONREAD)) {
  7930      Empty fd-sets will always wait. Zero time can be used to poll file-
  7140      Empty fd-sets will always wait. Zero time can be used to poll file-
  7931      descriptors (i.e. to check if I/O possible without blocking).
  7141      descriptors (i.e. to check if I/O possible without blocking).
  7932      Return first ready fd if I/O ok, nil if timed-out or interrupted."
  7142      Return first ready fd if I/O ok, nil if timed-out or interrupted."
  7933 
  7143 
  7934 %{
  7144 %{
  7935 #ifdef WIN32S /* OLD code - without select NO-LONGER-USED */
       
  7936     /*
       
  7937      * support a delay-wait only
       
  7938      * (i.e. fail if any filedescriptor is selected upon)
       
  7939      */
       
  7940     int count;
       
  7941     int i;
       
  7942     int t;
       
  7943     OBJ fd;
       
  7944 
       
  7945     @global(LastErrorNumber) = nil;
       
  7946 
       
  7947     if (! __isSmallInteger(millis)) {
       
  7948 	goto fail;
       
  7949     }
       
  7950 
       
  7951     if (readFdArray != nil) {
       
  7952 	if (! __isArray(readFdArray)) {
       
  7953 	    goto fail;  
       
  7954 	}
       
  7955 	count = __arraySize(readFdArray);
       
  7956 	for (i=0; i<count;i++) {
       
  7957 	    fd = __ArrayInstPtr(readFdArray)->a_element[i];
       
  7958 	    if (fd != nil) {
       
  7959 		if (__isSmallInteger(fd) && (__intVal(fd) >= 0)) {
       
  7960 		    goto fail;
       
  7961 		}
       
  7962 	    }
       
  7963 	}
       
  7964     }
       
  7965     if (writeFdArray != nil) {
       
  7966 	if (! __isArray(writeFdArray)) {
       
  7967 	    goto fail;
       
  7968 	}
       
  7969 	count = __arraySize(writeFdArray);
       
  7970 	for (i=0; i<count;i++) {
       
  7971 	    fd = __ArrayInstPtr(writeFdArray)->a_element[i];
       
  7972 	    if (fd != nil) {
       
  7973 		if (__isSmallInteger(fd) && (__intVal(fd) >= 0)) {
       
  7974 		    goto fail;
       
  7975 		}
       
  7976 	    }
       
  7977 	}
       
  7978     }
       
  7979     if (exceptFdArray != nil) {
       
  7980 	if (! __isArray(exceptFdArray)) {
       
  7981 	    goto fail;
       
  7982 	}
       
  7983 	count = __arraySize(exceptFdArray);
       
  7984 	for (i=0; i<count;i++) {
       
  7985 	    fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
       
  7986 	    if (fd != nil) {
       
  7987 		if (__isSmallInteger(fd) && (__intVal(fd) >= 0)) {
       
  7988 		    goto fail;
       
  7989 		}
       
  7990 	    }
       
  7991 	}
       
  7992     }
       
  7993     t = __intVal(millis);
       
  7994     if (t != 0) {
       
  7995 # if !defined(WIN32) || defined(WIN32s)
       
  7996 	/*
       
  7997 	 * delay only 
       
  7998 	 */
       
  7999 	Sleep(t);
       
  8000     }
       
  8001     RETURN (nil);
       
  8002 # else /* NT or WIN95 */
       
  8003 	HANDLE dummyHandle = (HANDLE)0;
       
  8004 
       
  8005 	/*
       
  8006 	 * notice: MsgWait blocks if there is already a message in the q.
       
  8007 	 * (brain damage behavior) therefore, check queueStatus before
       
  8008 	 */
       
  8009     fd_set rset, wset, eset;
  7145     fd_set rset, wset, eset;
  8010     struct timeval wt, et;
  7146     struct timeval wt, et;
  8011     int f, maxF, i, lX, bX;
  7147     int f, maxF, i, lX, bX;
  8012     INT t;
  7148     INT t;
  8013     OBJ fd, retFd;
  7149     OBJ fd, retFd;
  8014     int ret;
  7150     int ret;
  8015     int count;
  7151     int count;
  8016     int numFds = 0;
  7152     int numFds = 0;
  8017 
  7153 
  8018     if (__isSmallInteger(millis))
  7154     if (__isSmallInteger(millis)) {
  8019     {
       
  8020 	FD_ZERO(&rset);
  7155 	FD_ZERO(&rset);
  8021 	FD_ZERO(&wset);
  7156 	FD_ZERO(&wset);
  8022 	FD_ZERO(&eset);
  7157 	FD_ZERO(&eset);
  8023 
  7158 
  8024 	maxF = -1;
  7159 	maxF = -1;
  8025 	if (readFdArray != nil) {
  7160 	if (__isNonNilObject(readFdArray)) {
  8026 	    if (! __isArray(readFdArray)) {
  7161 	    if (! __isArray(readFdArray)) {
  8027 		goto fail;
  7162 		goto fail;    
  8028 	    }
  7163 	    }
  8029 	    count = __arraySize(readFdArray);
  7164 	    count = __arraySize(readFdArray);
  8030 
  7165 
  8031 	    for (i=0; i<count;i++) {
  7166 	    for (i=0; i<count;i++) {
  8032 		fd = __ArrayInstPtr(readFdArray)->a_element[i];
  7167 		fd = __ArrayInstPtr(readFdArray)->a_element[i];
  8039 		    }
  7174 		    }
  8040 		}
  7175 		}
  8041 	    }
  7176 	    }
  8042 	}
  7177 	}
  8043 
  7178 
  8044 	if (writeFdArray != nil) {
  7179 	if (__isNonNilObject(writeFdArray)) {
  8045 	    if (! __isArray(writeFdArray)) {
  7180 	    if (! __isArray(writeFdArray)) {
  8046 		goto fail;
  7181 		goto fail;    
  8047 	    }
  7182 	    }
  8048 	    count = __arraySize(writeFdArray);
  7183 	    count = __arraySize(writeFdArray);
  8049 	    for (i=0; i<count;i++) {
  7184 	    for (i=0; i<count;i++) {
  8050 		fd = __ArrayInstPtr(writeFdArray)->a_element[i];
  7185 		fd = __ArrayInstPtr(writeFdArray)->a_element[i];
  8051 		if (fd != nil) {
  7186 		if (fd != nil) {
  8052 		    f = __intVal(fd);
  7187 		    f = __intVal(fd);
  8053 		    if ((unsigned)f < FD_SETSIZE) {
  7188 		    if ((unsigned)f < FD_SETSIZE) {
  8054 			FD_SET(f, &wset);
  7189 			FD_SET(f, &wset);       
  8055 			if (f > maxF) maxF = f;
  7190 			if (f > maxF) maxF = f;
  8056 			numFds++;
  7191 			numFds++;
  8057 		    }
  7192 		    }
  8058 		}
  7193 		}
  8059 	    }
  7194 	    }
  8060 	}
  7195 	}
  8061 
  7196 
  8062 	if (exceptFdArray != nil) {
  7197 	if (__isNonNilObject(exceptFdArray)) {
  8063 	    if (! __isArray(exceptFdArray)) {
  7198 	    if (! __isArray(exceptFdArray)) {
  8064 		goto fail;
  7199 		goto fail;    
  8065 	    }
  7200 	    }
  8066 	    count = __arraySize(exceptFdArray);
  7201 	    count = __arraySize(exceptFdArray);
  8067 	    for (i=0; i<count;i++) {
  7202 	    for (i=0; i<count;i++) {
  8068 		fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
  7203 		fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
  8069 		if (fd != nil) {
  7204 		if (fd != nil) {
  8070 		    f = __intVal(fd);
  7205 		    f = __intVal(fd);
  8071 		    if ((unsigned)f < FD_SETSIZE) {
  7206 		    if ((unsigned)f < FD_SETSIZE) {
  8072 			FD_SET(f, &eset);
  7207 			FD_SET(f, &eset);       
  8073 			if (f > maxF) maxF = f;
  7208 			if (f > maxF) maxF = f;
  8074 			numFds++;
  7209 			numFds++;
  8075 		    }
  7210 		    }
  8076 		}
  7211 		}
  8077 	    }
  7212 	    }
  8085 	    wt.tv_sec = wt.tv_usec = 0;
  7220 	    wt.tv_sec = wt.tv_usec = 0;
  8086 	}
  7221 	}
  8087 
  7222 
  8088 	/*
  7223 	/*
  8089 	 * make certain, that interrupt gets us out of the select
  7224 	 * make certain, that interrupt gets us out of the select
       
  7225 	 * However, we must then care for moved objects.
  8090 	 */
  7226 	 */
  8091 	__BEGIN_INTERRUPTABLE__
  7227 	__BEGIN_INTERRUPTABLE__
  8092 	errno = 0;
  7228 	errno = 0;
  8093 
  7229 
  8094 	if (t == 0) {
  7230 	if (t == 0) {
  8095 	    /*
  7231 	    /* 
  8096 	     * if there is no timeout time, we can stay here
  7232 	     * if there is no timeout time, we can stay here interruptable.
  8097 	     * interruptable.
       
  8098 	     */
  7233 	     */
  8099 	    do {
  7234 	    do {
  8100 #  ifdef WIN32
       
  8101 		intf we;
       
  8102 		if (numFds == 0) {
       
  8103 		    HANDLE dummyHandle = (HANDLE)0;
       
  8104 #   if 0
       
  8105 		    if (! GetQueueStatus(QS_ALLINPUT)) {
       
  8106 			MsgWaitForMultipleObjects(0, &dummyHandle, FALSE, t, QS_ALLINPUT);
       
  8107 		    }
       
  8108 		    ret = 0;
       
  8109 #   endif
       
  8110 		    if (we = __getWaitInputEvent())
       
  8111 		      we(t);
       
  8112 		    ret = 0;
       
  8113 		} else {
       
  8114 		    ret = select(0, &rset, &wset, &eset, &wt);
       
  8115 		}
       
  8116 #  else
       
  8117 		ret = select(maxF+1, &rset, &wset, &eset, &wt);
  7235 		ret = select(maxF+1, &rset, &wset, &eset, &wt);
  8118 #  endif /* WIN32 */
       
  8119 	    } while ((ret < 0) && (errno == EINTR));
  7236 	    } while ((ret < 0) && (errno == EINTR));
  8120 	} else {
  7237 	} else {
  8121 	    do {
  7238 	    do {
  8122 #  ifdef WIN32
       
  8123 		intf we;
       
  8124 		if (numFds == 0) {
       
  8125 		    HANDLE dummyHandle = (HANDLE)0;
       
  8126 #   if 0
       
  8127 		    if (! GetQueueStatus(QS_ALLINPUT)) {
       
  8128 			MsgWaitForMultipleObjects(0, &dummyHandle, FALSE, t, QS_ALLINPUT);
       
  8129 		    }
       
  8130 		    ret = 0;
       
  8131 #   endif
       
  8132 		    if (we = __getWaitInputEvent())
       
  8133 		      we(t);
       
  8134 		    ret = 0;
       
  8135 		} else {
       
  8136 		    ret = select(0, &rset, &wset, &eset, &wt);
       
  8137 		}
       
  8138 #  else
       
  8139 		ret = select(maxF+1, &rset, &wset, &eset, &wt);
  7239 		ret = select(maxF+1, &rset, &wset, &eset, &wt);
  8140 #  endif /* WIN32 */
  7240 		/* 
  8141 		/*
       
  8142 		 * for now: dont loop; if we did, we had to adjust the vt-timeval;
  7241 		 * for now: dont loop; if we did, we had to adjust the vt-timeval;
  8143 		 * could otherwise stay in this loop forever ...
  7242 		 * could otherwise stay in this loop forever ...
  8144 		 * Premature return (before the time expired) must be handled by the caller.
  7243 		 * Premature return (before the time expired) must be handled by the caller.
  8145 		 * A good solution is to update the wt-timeval and redo the select.
  7244 		 * A good solution is to update the wt-timeval and redo the select.
  8146 		 */
  7245 		 */
  8176 	 * return nil (means time expired or interrupted)
  7275 	 * return nil (means time expired or interrupted)
  8177 	 */
  7276 	 */
  8178 	RETURN ( nil );
  7277 	RETURN ( nil );
  8179     }
  7278     }
  8180 
  7279 
  8181 # endif /* NT or WIN95 */
       
  8182 
       
  8183 #else /* not WIN32S */
       
  8184 
       
  8185     fd_set rset, wset, eset;
       
  8186     struct timeval wt, et;
       
  8187     int f, maxF, i, lX, bX;
       
  8188     INT t;
       
  8189     OBJ fd, retFd;
       
  8190     int ret;
       
  8191     int count;
       
  8192     int numFds = 0;
       
  8193 
       
  8194     if (__isSmallInteger(millis)) {
       
  8195 	FD_ZERO(&rset);
       
  8196 	FD_ZERO(&wset);
       
  8197 	FD_ZERO(&eset);
       
  8198 
       
  8199 	maxF = -1;
       
  8200 	if (__isNonNilObject(readFdArray)) {
       
  8201 	    if (! __isArray(readFdArray)) {
       
  8202 		goto fail;    
       
  8203 	    }
       
  8204 	    count = __arraySize(readFdArray);
       
  8205 
       
  8206 	    for (i=0; i<count;i++) {
       
  8207 		fd = __ArrayInstPtr(readFdArray)->a_element[i];
       
  8208 		if (fd != nil) {
       
  8209 		    f = __intVal(fd);
       
  8210 		    if ((unsigned)f < FD_SETSIZE) {
       
  8211 			FD_SET(f, &rset);
       
  8212 			if (f > maxF) maxF = f;
       
  8213 			numFds++;
       
  8214 		    }
       
  8215 		}
       
  8216 	    }
       
  8217 	}
       
  8218 
       
  8219 	if (__isNonNilObject(writeFdArray)) {
       
  8220 	    if (! __isArray(writeFdArray)) {
       
  8221 		goto fail;    
       
  8222 	    }
       
  8223 	    count = __arraySize(writeFdArray);
       
  8224 	    for (i=0; i<count;i++) {
       
  8225 		fd = __ArrayInstPtr(writeFdArray)->a_element[i];
       
  8226 		if (fd != nil) {
       
  8227 		    f = __intVal(fd);
       
  8228 		    if ((unsigned)f < FD_SETSIZE) {
       
  8229 			FD_SET(f, &wset);       
       
  8230 			if (f > maxF) maxF = f;
       
  8231 			numFds++;
       
  8232 		    }
       
  8233 		}
       
  8234 	    }
       
  8235 	}
       
  8236 
       
  8237 	if (__isNonNilObject(exceptFdArray)) {
       
  8238 	    if (! __isArray(exceptFdArray)) {
       
  8239 		goto fail;    
       
  8240 	    }
       
  8241 	    count = __arraySize(exceptFdArray);
       
  8242 	    for (i=0; i<count;i++) {
       
  8243 		fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
       
  8244 		if (fd != nil) {
       
  8245 		    f = __intVal(fd);
       
  8246 		    if ((unsigned)f < FD_SETSIZE) {
       
  8247 			FD_SET(f, &eset);       
       
  8248 			if (f > maxF) maxF = f;
       
  8249 			numFds++;
       
  8250 		    }
       
  8251 		}
       
  8252 	    }
       
  8253 	}
       
  8254 
       
  8255 	t = __intVal(millis);
       
  8256 	if (t) {
       
  8257 	    wt.tv_sec = t / 1000;
       
  8258 	    wt.tv_usec = (t % 1000) * 1000;
       
  8259 	} else {
       
  8260 	    wt.tv_sec = wt.tv_usec = 0;
       
  8261 	}
       
  8262 
       
  8263 	/*
       
  8264 	 * make certain, that interrupt gets us out of the select
       
  8265 	 * However, we must then care for moved objects.
       
  8266 	 */
       
  8267 	__BEGIN_INTERRUPTABLE__
       
  8268 	errno = 0;
       
  8269 
       
  8270 	if (t == 0) {
       
  8271 	    /* 
       
  8272 	     * if there is no timeout time, we can stay here interruptable.
       
  8273 	     */
       
  8274 	    do {
       
  8275 # ifdef WIN32
       
  8276 		intf we;
       
  8277 
       
  8278 		if (numFds == 0) {
       
  8279 		    HANDLE dummyHandle = (HANDLE)0;
       
  8280 
       
  8281 #  if 0 /* does not work under WIN95 - sigh */
       
  8282 		    if (! GetQueueStatus(QS_ALLINPUT)) {
       
  8283 			MsgWaitForMultipleObjects(0, &dummyHandle, FALSE, t, QS_ALLINPUT);
       
  8284 		    }
       
  8285 #  else
       
  8286 		    if (we = __getWaitInputEvent()) {
       
  8287 			we(t);
       
  8288 		    }
       
  8289 #  endif
       
  8290 		    ret = 0;
       
  8291 		} else {
       
  8292 		    ret = select(0, &rset, &wset, &eset, &wt);
       
  8293 		}
       
  8294 # else /* a real OS */
       
  8295 		ret = select(maxF+1, &rset, &wset, &eset, &wt);
       
  8296 # endif /* to WIN or not to WIN */
       
  8297 	    } while ((ret < 0) && (errno == EINTR));
       
  8298 	} else {
       
  8299 	    do {
       
  8300 # ifdef WIN32
       
  8301 		intf we;
       
  8302 
       
  8303 		if (numFds == 0) {
       
  8304 		    HANDLE dummyHandle = (HANDLE)0;
       
  8305 #  if 0 /* does not work under WIN95 - sigh */
       
  8306 		    if (! GetQueueStatus(QS_ALLINPUT)) {
       
  8307 			MsgWaitForMultipleObjects(0, &dummyHandle, FALSE, t, QS_ALLINPUT);
       
  8308 		    }
       
  8309 #  else
       
  8310 		    if (we = __getWaitInputEvent()) {
       
  8311 			we(t);
       
  8312 		    }
       
  8313 #  endif
       
  8314 		    ret = 0;
       
  8315 		} else {
       
  8316 		    ret = select(0, &rset, &wset, &eset, &wt);
       
  8317 		}
       
  8318 # else /* a real OS */
       
  8319 		ret = select(maxF+1, &rset, &wset, &eset, &wt);
       
  8320 # endif * to WIN or not to WIN */
       
  8321 		/* 
       
  8322 		 * for now: dont loop; if we did, we had to adjust the vt-timeval;
       
  8323 		 * could otherwise stay in this loop forever ...
       
  8324 		 * Premature return (before the time expired) must be handled by the caller.
       
  8325 		 * A good solution is to update the wt-timeval and redo the select.
       
  8326 		 */
       
  8327 	    } while (0 /* (ret < 0) && (errno == EINTR) */ );
       
  8328 	}
       
  8329 	__END_INTERRUPTABLE__
       
  8330 
       
  8331 	if (ret > 0) {
       
  8332 	    for (i=0; i <= maxF; i++) {
       
  8333 		if (FD_ISSET(i, &rset)
       
  8334 		 || FD_ISSET(i, &wset)
       
  8335 		 || FD_ISSET(i, &eset)) {
       
  8336 		    RETURN ( __MKSMALLINT(i) );
       
  8337 		}
       
  8338 	    }
       
  8339 	} else {
       
  8340 	    if (ret < 0) {
       
  8341 		if (errno == EINTR) {
       
  8342 		    errno = 0;
       
  8343 		    @global(LastErrorNumber) = nil;
       
  8344 		} else {
       
  8345 		    if (@global(InfoPrinting) == true) {
       
  8346 			fprintf(stderr, "OS [info]: select errno = %d\n", errno);
       
  8347 		    }
       
  8348 		    @global(LastErrorNumber) = __MKSMALLINT(errno);
       
  8349 		}
       
  8350 	    } else {
       
  8351 		@global(LastErrorNumber) = nil;
       
  8352 	    }
       
  8353 	}
       
  8354 
       
  8355 	/*
       
  8356 	 * return nil (means time expired or interrupted)
       
  8357 	 */
       
  8358 	RETURN ( nil );
       
  8359     }
       
  8360 #endif /* not MSDOS_LIKE */
       
  8361 
       
  8362 fail: ;
  7280 fail: ;
  8363 %}.
  7281 %}.
  8364     "
  7282     "
  8365      timeout argument not integer,
  7283      timeout argument not integer,
  8366      or any fd-array nonNil and not an array
  7284      or any fd-array nonNil and not an array
  8404     ^ self primitiveFailed
  7322     ^ self primitiveFailed
  8405 ! !
  7323 ! !
  8406 
  7324 
  8407 !OpenVMSOperatingSystem::FileStatusInfo class methodsFor:'instance creation'!
  7325 !OpenVMSOperatingSystem::FileStatusInfo class methodsFor:'instance creation'!
  8408 
  7326 
  8409 type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP alternativeName:name2
  7327 type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP 
  8410     ^ self basicNew
  7328     ^ self basicNew
  8411 	type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP alternativeName:name2
  7329 	type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP 
  8412 ! !
  7330 ! !
  8413 
  7331 
  8414 !OpenVMSOperatingSystem::FileStatusInfo methodsFor:'accessing'!
  7332 !OpenVMSOperatingSystem::FileStatusInfo methodsFor:'accessing'!
  8415 
  7333 
  8416 accessed
  7334 accessed
  8420 
  7338 
  8421 alternativeName
  7339 alternativeName
  8422     "return the files other name (DOS name on windows).
  7340     "return the files other name (DOS name on windows).
  8423      Nil if there is no other name"
  7341      Nil if there is no other name"
  8424 
  7342 
  8425     ^ alternativeName
  7343     ^ nil
  8426 !
  7344 !
  8427 
  7345 
  8428 fixedHeaderSize
  7346 fixedHeaderSize
  8429     "return the fixedHeaderSize (VMS only; nil everywhere else)"
  7347     "return the fixedHeaderSize (VMS only; nil everywhere else)"
  8430 
  7348 
  8521     recordAttributes := ra.
  7439     recordAttributes := ra.
  8522     fixedHeaderSize := hs.
  7440     fixedHeaderSize := hs.
  8523     recordSize := rs
  7441     recordSize := rs
  8524 !
  7442 !
  8525 
  7443 
  8526 type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP alternativeName:name2
  7444 type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP 
  8527     type := t.
  7445     type := t.
  8528     mode := m.
  7446     mode := m.
  8529     uid := u.
  7447     uid := u.
  8530     gid := g.
  7448     gid := g.
  8531     size := s.
  7449     size := s.
  8532     id := i.
  7450     id := i.
  8533     accessed := aT.
  7451     accessed := aT.
  8534     modified := mT.
  7452     modified := mT.
  8535     statusChanged := sT.
  7453     statusChanged := sT.
  8536     path := lP.
  7454     path := lP.
  8537     alternativeName := name2.
       
  8538 ! !
  7455 ! !
  8539 
  7456 
  8540 !OpenVMSOperatingSystem::OSProcessStatus class methodsFor:'documentation'!
  7457 !OpenVMSOperatingSystem::OSProcessStatus class methodsFor:'documentation'!
  8541 
  7458 
  8542 documentation
  7459 documentation
  8696 ! !
  7613 ! !
  8697 
  7614 
  8698 !OpenVMSOperatingSystem class methodsFor:'documentation'!
  7615 !OpenVMSOperatingSystem class methodsFor:'documentation'!
  8699 
  7616 
  8700 version
  7617 version
  8701     ^ '$Header: /cvs/stx/stx/libbasic/OpenVMSOperatingSystem.st,v 1.5 1998-06-12 14:35:37 cg Exp $'
  7618     ^ '$Header: /cvs/stx/stx/libbasic/OpenVMSOperatingSystem.st,v 1.6 1998-06-12 16:02:03 cg Exp $'
  8702 ! !
  7619 ! !
  8703 OpenVMSOperatingSystem initialize!
  7620 OpenVMSOperatingSystem initialize!