Unix.st
author Claus Gittinger <cg@exept.de>
Fri, 10 Jan 1997 16:23:40 +0100
changeset 2126 d3da2956f380
parent 2117 460b14a6db96
child 2131 1eeb310e109a
permissions -rw-r--r--
NEXT has no waitpid
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
5
67342904af11 *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1988 by Claus Gittinger
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
     3
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
a27a279701f8 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
2080
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
    13
'From Smalltalk/X, Version:3.1.3 on 7-jan-1997 at 20:04:25'                     !
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
    14
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    15
Object subclass:#OperatingSystem
798
90a518c71a7f recursiveRemoveDirectory does not print garbage to stderr any longer; computeDateAndTimeFrom: now returns the utcOffset
Stefan Vogel <sv@exept.de>
parents: 792
diff changeset
    16
	instanceVariableNames:''
2080
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
    17
	classVariableNames:'HostName DomainName LastErrorNumber OSSignals
759
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 756
diff changeset
    18
		SlowFork ForkFailed ErrorSignal AccessDeniedErrorSignal
1034
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
    19
		FileNotFoundErrorSignal LocaleInfo'
798
90a518c71a7f recursiveRemoveDirectory does not print garbage to stderr any longer; computeDateAndTimeFrom: now returns the utcOffset
Stefan Vogel <sv@exept.de>
parents: 792
diff changeset
    20
	poolDictionaries:''
90a518c71a7f recursiveRemoveDirectory does not print garbage to stderr any longer; computeDateAndTimeFrom: now returns the utcOffset
Stefan Vogel <sv@exept.de>
parents: 792
diff changeset
    21
	category:'System-Support'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    22
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    23
2080
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
    24
Object subclass:#OSProcessStatus
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
    25
	instanceVariableNames:'pid status code core'
1966
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
    26
	classVariableNames:''
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
    27
	poolDictionaries:''
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
    28
	privateIn:OperatingSystem
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
    29
!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
    30
2080
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
    31
Object subclass:#FileStatusInfo
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
    32
	instanceVariableNames:'type mode uid gid size id accessed modified statusChanged path'
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
    33
	classVariableNames:''
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
    34
	poolDictionaries:''
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
    35
	privateIn:OperatingSystem
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
    36
!
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
    37
437
claus
parents: 434
diff changeset
    38
!OperatingSystem primitiveDefinitions!
406
claus
parents: 384
diff changeset
    39
%{
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    40
#define UNIX_LIKE
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    41
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
    42
#if defined(MSWINDOWS) || defined(OS2) || defined(MSDOS) || defined(WIN32)
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    43
# ifndef MSDOS_LIKE
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    44
#  define MSDOS_LIKE
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    45
# endif
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    46
# undef UNIX_LIKE
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
    47
# ifdef i386
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
    48
#  define _X86_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
    49
# endif
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    50
#endif
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    51
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    52
#if defined(transputer)
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    53
# undef MSDOS_LIKE
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    54
# undef UNIX_LIKE
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    55
#endif
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
    56
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
    57
#if defined(_AIX)
439
claus
parents: 438
diff changeset
    58
# ifndef WANT_REALPATH
claus
parents: 438
diff changeset
    59
#  define WANT_REALPATH
claus
parents: 438
diff changeset
    60
# endif
513
0347f6d11d76 interruptable system() on AIX
Claus Gittinger <cg@exept.de>
parents: 512
diff changeset
    61
# ifndef WANT_SYSTEM
0347f6d11d76 interruptable system() on AIX
Claus Gittinger <cg@exept.de>
parents: 512
diff changeset
    62
#  define WANT_SYSTEM
0347f6d11d76 interruptable system() on AIX
Claus Gittinger <cg@exept.de>
parents: 512
diff changeset
    63
# endif
406
claus
parents: 384
diff changeset
    64
#endif
claus
parents: 384
diff changeset
    65
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
    66
#ifdef LINUX
1142
3964108b86ca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1135
diff changeset
    67
  /* use inline string macros */
3964108b86ca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1135
diff changeset
    68
# define __STRINGDEFS__
3964108b86ca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1135
diff changeset
    69
# include <linuxIntern.h>
3964108b86ca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1135
diff changeset
    70
439
claus
parents: 438
diff changeset
    71
# ifndef WANT_SYSTEM
claus
parents: 438
diff changeset
    72
#  define WANT_SYSTEM
claus
parents: 438
diff changeset
    73
# endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
    74
# define WANT_SHM
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
    75
#endif
f74d003548dc system-fix
claus
parents: 424
diff changeset
    76
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
    77
#ifdef IRIX5
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
    78
# define WANT_SYSTEM
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
    79
#endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
    80
514
81fa80a953e2 system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
    81
#ifdef ultrix
81fa80a953e2 system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
    82
# define WANT_SYSTEM
81fa80a953e2 system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
    83
#endif
81fa80a953e2 system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
    84
515
43d76695a662 interruptable system() on hpux
Claus Gittinger <cg@exept.de>
parents: 514
diff changeset
    85
#ifdef hpux
43d76695a662 interruptable system() on hpux
Claus Gittinger <cg@exept.de>
parents: 514
diff changeset
    86
# define WANT_SYSTEM
43d76695a662 interruptable system() on hpux
Claus Gittinger <cg@exept.de>
parents: 514
diff changeset
    87
#endif
43d76695a662 interruptable system() on hpux
Claus Gittinger <cg@exept.de>
parents: 514
diff changeset
    88
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
    89
#ifdef solaris
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
    90
# define WANT_SYSTEM
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
    91
#endif
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
    92
805
850571f0255f WANT_SYSTEM for unixware.
Stefan Vogel <sv@exept.de>
parents: 803
diff changeset
    93
#if defined(SYSV4) && defined(i386) /* e.g. unixware */
520
9620f7dc79d2 interruptable system() on unixware - should now move WANT_SYSTEM into xxxIntern files
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    94
# define WANT_SYSTEM
9620f7dc79d2 interruptable system() on unixware - should now move WANT_SYSTEM into xxxIntern files
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    95
#endif
9620f7dc79d2 interruptable system() on unixware - should now move WANT_SYSTEM into xxxIntern files
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    96
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
    97
/*
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
    98
 * notice: although many systems' include files
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
    99
 * already block against multiple inclusion, some
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   100
 * do not. Therefore, this is done here again.
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   101
 * (it does not hurt)
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   102
 */ 
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   103
439
claus
parents: 438
diff changeset
   104
#ifdef WANT_REALPATH
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   105
439
claus
parents: 438
diff changeset
   106
# include <sys/param.h>
claus
parents: 438
diff changeset
   107
# define _SYS_PARAM_H_INCLUDED_
claus
parents: 438
diff changeset
   108
claus
parents: 438
diff changeset
   109
# include <errno.h>
claus
parents: 438
diff changeset
   110
# define _ERRNO_H_INCLUDED_
claus
parents: 438
diff changeset
   111
claus
parents: 438
diff changeset
   112
# include <sys/stat.h>
claus
parents: 438
diff changeset
   113
# define _SYS_STAT_H_INCLUDED_
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   114
439
claus
parents: 438
diff changeset
   115
#endif /* WANT_REALPATH */
claus
parents: 438
diff changeset
   116
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   117
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   118
434
0511ecb7c818 *** empty log message ***
claus
parents: 433
diff changeset
   119
#ifdef WANT_SHM
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   120
extern int shmctl(), shmget(), shmdt();
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   121
extern char * shmat();
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   122
434
0511ecb7c818 *** empty log message ***
claus
parents: 433
diff changeset
   123
# include <sys/types.h>
437
claus
parents: 434
diff changeset
   124
# define _SYS_TYPES_H_INCLUDED_
439
claus
parents: 438
diff changeset
   125
434
0511ecb7c818 *** empty log message ***
claus
parents: 433
diff changeset
   126
# include <sys/ipc.h>
437
claus
parents: 434
diff changeset
   127
# define _SYS_IPC_H_INCLUDED_
439
claus
parents: 438
diff changeset
   128
434
0511ecb7c818 *** empty log message ***
claus
parents: 433
diff changeset
   129
# include <sys/shm.h>
437
claus
parents: 434
diff changeset
   130
# define _SYS_SHM_H_INCLUDED_
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   131
439
claus
parents: 438
diff changeset
   132
#endif /* WANT_SHM */
434
0511ecb7c818 *** empty log message ***
claus
parents: 433
diff changeset
   133
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   134
434
0511ecb7c818 *** empty log message ***
claus
parents: 433
diff changeset
   135
#ifdef IRIX5
0511ecb7c818 *** empty log message ***
claus
parents: 433
diff changeset
   136
# include <sys/syssgi.h>
0511ecb7c818 *** empty log message ***
claus
parents: 433
diff changeset
   137
#endif
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   138
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   139
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   140
#ifdef transputer
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   141
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   142
# define unlink(f)      ((remove(f) == 0) ? 0 : -1)
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   143
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   144
#else /* not transputer */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   145
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   146
# ifndef _SIGNAL_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   147
#  include <signal.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   148
#  define _SIGNAL_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   149
# endif
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   150
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   151
# ifdef SYSV
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   152
#  ifndef _SYS_TYPES_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   153
#   include <sys/types.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   154
#   define _SYS_TYPES_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   155
#  endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   156
#  ifndef _SYS_PARAM_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   157
#   include <sys/param.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   158
#   define _SYS_PARAM_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   159
#  endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   160
#  ifndef _SYS_TIMES_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   161
#   include <sys/times.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   162
#   define _SYS_TIMES_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   163
#  endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   164
#  ifndef _SYS_FILE_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   165
#   include <sys/file.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   166
#   define _SYS_FILE_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   167
#  endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   168
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   169
#  if ! defined(sco3_2)
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   170
#   ifndef _UNISTD_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   171
#    include <unistd.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   172
#    define _UNISTD_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   173
#   endif
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   174
#  endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   175
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   176
#  if defined(isc3_2) || defined(sco3_2)
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   177
#   ifndef _SYS_TIME_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   178
#    include <sys/time.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   179
#    define _SYS_TIME_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   180
#   endif
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   181
#  endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   182
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   183
#  if !defined(isc3_2)
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   184
#   if defined(PCS) && defined(mips)
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   185
#    include "/usr/include/bsd/sys/time.h"
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   186
#    include "/usr/include/sys/time.h"
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   187
#   else
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   188
#    ifndef _TIME_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   189
#     include <time.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   190
#     define _TIME_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   191
#    endif
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   192
#   endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   193
#  endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   194
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   195
#  if defined(isc3_2)
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   196
#   include <sys/bsdtypes.h>
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   197
#  endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   198
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   199
# else /* not SYSV */
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   200
802
087384994c4a even worse
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
   201
#  ifdef MSDOS_LIKE
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   202
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   203
#   ifndef _SYS_TYPES_H_INCLUDED_
1987
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   204
#    include <types.h>
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   205
#    define _SYS_TYPES_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   206
#   endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   207
#   ifndef _TIME_H_INCLUDED_
1987
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   208
#    include <C:\mstools\h\time.h>
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   209
#    define _TIME_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   210
#   endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   211
#   ifndef _SYS_TIMEB_H_INCLUDED_
1987
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   212
#    include <timeb.h>
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   213
#    define _SYS_TIMEB_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   214
#   endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   215
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   216
#  else /* not MSDOS_like */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   217
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   218
#   ifndef _SYS_TIME_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   219
#    include <sys/time.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   220
#    define _SYS_TIME_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   221
#   endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   222
#   ifndef _SYS_TYPES_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   223
#    include <sys/types.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   224
#    define _SYS_TYPES_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   225
#   endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   226
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   227
#  endif /* not MSDOS */
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   228
# endif /* not SYSV */
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   229
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   230
# ifdef aix
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   231
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   232
#  ifndef _TIME_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   233
#   include <time.h>
914
d00401a9450e Fix syntax error (#defined -> #define).
Stefan Vogel <sv@exept.de>
parents: 855
diff changeset
   234
#   define _TIME_H_INCLUDED_
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   235
#  endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   236
#  ifndef _SYS_SELECT_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   237
#   include <sys/select.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   238
#   define _SYS_SELECT_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   239
#  endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   240
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   241
# endif /* aix */
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   242
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   243
# ifndef MSDOS_LIKE
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   244
#  include <pwd.h>
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   245
#  include <grp.h>
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   246
# endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   247
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   248
# ifndef _SYS_STAT_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   249
#  include <sys/stat.h>
1616
fa734ea238f8 type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   250
#  define _SYS_STAT_H_INCLUDED_
fa734ea238f8 type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   251
# endif
fa734ea238f8 type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   252
fa734ea238f8 type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   253
# ifndef _SYS_FILE_H_INCLUDED_
1633
dc4105e87116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1632
diff changeset
   254
#  ifndef WIN32
dc4105e87116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1632
diff changeset
   255
#   include <sys/file.h>
dc4105e87116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1632
diff changeset
   256
#  endif
1616
fa734ea238f8 type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   257
#  define _SYS_FILE_H_INCLUDED_
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   258
# endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   259
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   260
# ifndef _ERRNO_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   261
#  include <errno.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   262
#  define _ERRNO_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   263
# endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   264
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   265
# ifndef _STDIO_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   266
#  include <stdio.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   267
#  define _STDIO_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   268
# endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   269
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   270
# ifndef _FCNTL_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   271
#  include <fcntl.h>
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   272
#  define _FCNTL_H_INCLUDED_
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   273
# endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   274
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   275
# ifdef WIN32
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   276
#  define USE_TimerProc
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   277
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   278
#  undef INT
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   279
#  undef Array
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   280
#  undef Number
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   281
#  undef Method
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   282
#  undef Point
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   283
#  undef Rectangle
1987
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   284
#  undef Block
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   285
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   286
/* #  include <windows.h> /* */
1987
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   287
#  include <stdarg.h> /* */
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   288
#  include <windef.h> /* */
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   289
#  include <winbase.h> /* */
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   290
#  include <wingdi.h> /* */
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   291
#  include <winuser.h> /* */
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   292
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   293
#  ifndef USE_TimerProc
1987
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   294
#   include <mmsystem.h> /* */
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   295
#  else
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   296
    static UINT w32TimerId;
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   297
#  endif
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   298
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   299
#  ifdef __DEF_Array
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   300
#   define Array __DEF_Array
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   301
#  endif
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   302
#  ifdef __DEF_Number
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   303
#   define Number __DEF_Number
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   304
#  endif
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   305
#  ifdef __DEF_Method
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   306
#   define Method __DEF_Method
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   307
#  endif
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   308
#  ifdef __DEF_Point
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   309
#   define Point __DEF_Point
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   310
#  endif
1987
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   311
#  ifdef __DEF_Block
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   312
#   define Block __DEF_Block
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   313
#  endif
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   314
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   315
#  define stat _stat
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   316
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   317
# endif /* WIN32 */
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   318
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   319
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   320
# if defined(LINUX)
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   321
#  define HAS_LOCALECONV
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   322
# endif
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   323
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   324
# if defined (HAS_LOCALECONV)
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   325
#  ifndef _LOCALE_H_INCLUDED_
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   326
#   include <locale.h>
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   327
#   define _LOCALE_H_INCLUDED_
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   328
#  endif
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   329
# endif
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   330
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   331
/* 
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   332
 * posix systems should define these ... 
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   333
 * but on some (older) systems, they are not.
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   334
 */
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   335
# ifndef S_IXUSR
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   336
#  ifdef S_IEXEC
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   337
#   define S_IXUSR S_IEXEC
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   338
#   define S_IXGRP (S_IEXEC>>3)
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   339
#   define S_IXOTH (S_IEXEC>>6)
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   340
#  endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   341
# endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   342
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   343
# ifndef S_IXUSR
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   344
#  define S_IXUSR 0100
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   345
#  define S_IXGRP 0010
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   346
#  define S_IXOTH 0001
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   347
# endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   348
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   349
# ifndef S_IRUSR
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   350
#  define S_IRUSR 0400
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   351
#  define S_IRGRP 0040
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   352
#  define S_IROTH 0004
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   353
# endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   354
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   355
# ifndef S_IWUSR
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   356
#  define S_IWUSR 0200
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   357
#  define S_IWGRP 0020
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   358
#  define S_IWOTH 0002
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   359
# endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   360
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   361
# ifndef MAXPATHLEN
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   362
#  ifndef MSDOS_LIKE
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   363
#   include <sys/param.h>
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   364
#  endif
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   365
#  ifndef MAXPATHLEN
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   366
#   ifdef FILENAME_MAX  /* i.e. MSDOS_LIKE */
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   367
#    define MAXPATHLEN FILENAME_MAX
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   368
#   else
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   369
#    define MAXPATHLEN 1024
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   370
#   endif
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   371
#  endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   372
# endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   373
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   374
# if defined(HAS_UNAME)
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   375
#  include <sys/utsname.h>
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   376
# endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   377
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
   378
# if defined(SYSV4)
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
   379
#  include <stropts.h>
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
   380
# endif
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
   381
763
7d5e32ed435e dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
   382
/*
2073
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   383
 * NeXT has no pid_t
2107
9987b837fe12 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
   384
 * and no sigemptyset
2073
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   385
 */
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   386
# ifdef NEXT
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   387
   typedef int pid_t;
2107
9987b837fe12 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
   388
#  define sigemptyset(set)      ((*(set) = 0L), 0)
2073
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   389
# endif
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   390
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   391
/*
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   392
 * some (BSD ?) have no timezone
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   393
 */
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   394
# if defined(ultrix) || defined(sunos) || defined(NEXT)
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   395
#  define HAS_NO_TIMEZONE
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   396
# endif
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   397
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
   398
/*
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
   399
 * sigaction dummies (you won't believe these call themself ``POSIX'' systems ...)
763
7d5e32ed435e dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
   400
 */
7d5e32ed435e dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
   401
# ifndef SA_RESTART
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   402
#  define SA_RESTART    0
763
7d5e32ed435e dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
   403
# endif
7d5e32ed435e dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
   404
# ifndef SA_SIGINFO
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   405
#  define SA_SIGINFO    0
763
7d5e32ed435e dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
   406
# endif
7d5e32ed435e dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
   407
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
   408
# if defined(HAS_WAITPID) || defined(HAS_WAIT3)
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
   409
#  include <sys/wait.h>
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
   410
# endif
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
   411
1433
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
   412
# if defined(HAS_SYSINFO)
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
   413
#  include <sys/systeminfo.h>
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
   414
# endif
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
   415
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
   416
#endif /* not transputer */
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   417
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   418
/*
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   419
 * on some systems errno is a macro ... check for it here
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   420
 */
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   421
#ifndef errno
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   422
 extern errno;
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   423
#endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   424
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   425
/*
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   426
 * some (old ?) systems do not define this ...
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   427
 */
675
f3461db7a0ee avoid a warning
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   428
#if !defined(R_OK) && !defined(_AIX)
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   429
# define R_OK    4       /* Test for Read permission */ 
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   430
# define W_OK    2       /* Test for Write permission */
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   431
# define X_OK    1       /* Test for eXecute permission */
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   432
# define F_OK    0       /* Test for existence of File */
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   433
#endif
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   434
832
70e8b7fc357e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 831
diff changeset
   435
#ifdef WIN32
70e8b7fc357e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 831
diff changeset
   436
# define SIGHANDLER_ARG int
70e8b7fc357e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 831
diff changeset
   437
#else
70e8b7fc357e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 831
diff changeset
   438
# define SIGHANDLER_ARG
70e8b7fc357e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 831
diff changeset
   439
#endif
70e8b7fc357e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 831
diff changeset
   440
1441
91284e90f42a sunos has no __wait
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   441
#ifdef sunos
91284e90f42a sunos has no __wait
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   442
# define NO_WAITPID
91284e90f42a sunos has no __wait
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   443
#endif
2126
d3da2956f380 NEXT has no waitpid
Claus Gittinger <cg@exept.de>
parents: 2117
diff changeset
   444
#ifdef NEXT
d3da2956f380 NEXT has no waitpid
Claus Gittinger <cg@exept.de>
parents: 2117
diff changeset
   445
# define NO_WAITPID
d3da2956f380 NEXT has no waitpid
Claus Gittinger <cg@exept.de>
parents: 2117
diff changeset
   446
#endif
1441
91284e90f42a sunos has no __wait
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   447
437
claus
parents: 434
diff changeset
   448
%}
claus
parents: 434
diff changeset
   449
! !
claus
parents: 434
diff changeset
   450
claus
parents: 434
diff changeset
   451
!OperatingSystem primitiveFunctions!
claus
parents: 434
diff changeset
   452
%{
claus
parents: 434
diff changeset
   453
claus
parents: 434
diff changeset
   454
/*
claus
parents: 434
diff changeset
   455
 * some systems' system() is broken in that it does not correctly 
claus
parents: 434
diff changeset
   456
 * handle EINTR and returns failure even though it actually succeeded. 
claus
parents: 434
diff changeset
   457
 * (LINUX is one of them)
claus
parents: 434
diff changeset
   458
 * Here is a fixed version. If you encounter EINTR returns from
claus
parents: 434
diff changeset
   459
 * OperatingSystem>>executeCommand, you ought to define WANT_SYSTEM
claus
parents: 434
diff changeset
   460
 * in the xxxIntern.h file to get this fixed version.
claus
parents: 434
diff changeset
   461
 *
claus
parents: 434
diff changeset
   462
 * As an added BONUS, this system() enables interrupts while waiting
claus
parents: 434
diff changeset
   463
 * for the child which enables other threads to continue.
507
a7780fc27ee9 mad system interuptable (needs WANT_SYSTEM to be defined in xxxIntern.h)
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   464
 * (i.e. it is RT safe)
437
claus
parents: 434
diff changeset
   465
 */
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   466
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   467
#if defined(WANT_SYSTEM)
f74d003548dc system-fix
claus
parents: 424
diff changeset
   468
434
0511ecb7c818 *** empty log message ***
claus
parents: 433
diff changeset
   469
/* # define DPRINTF(x)     printf x */
0511ecb7c818 *** empty log message ***
claus
parents: 433
diff changeset
   470
# define DPRINTF(x)     /* nothing */
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   471
437
claus
parents: 434
diff changeset
   472
# ifndef _STDDEF_H_INCLUDED_
claus
parents: 434
diff changeset
   473
#  include <stddef.h>
claus
parents: 434
diff changeset
   474
#  define _STDDEF_H_INCLUDED_
claus
parents: 434
diff changeset
   475
# endif
claus
parents: 434
diff changeset
   476
claus
parents: 434
diff changeset
   477
# ifndef _STDLIB_H_INCLUDED_
claus
parents: 434
diff changeset
   478
#  include <stdlib.h>
claus
parents: 434
diff changeset
   479
#  define _STDLIB_H_INCLUDED_
claus
parents: 434
diff changeset
   480
# endif
claus
parents: 434
diff changeset
   481
claus
parents: 434
diff changeset
   482
# ifndef _UNISTD_H_INCLUDED_
claus
parents: 434
diff changeset
   483
#  include <unistd.h>
claus
parents: 434
diff changeset
   484
#  define _UNISTD_H_INCLUDED_
claus
parents: 434
diff changeset
   485
# endif
claus
parents: 434
diff changeset
   486
claus
parents: 434
diff changeset
   487
# ifndef _SYS_WAIT_H_INCLUDED
claus
parents: 434
diff changeset
   488
#  include <sys/wait.h>
claus
parents: 434
diff changeset
   489
#  define _SYS_WAIT_H_INCLUDED
claus
parents: 434
diff changeset
   490
# endif
claus
parents: 434
diff changeset
   491
claus
parents: 434
diff changeset
   492
# ifndef _SIGNAL_H_INCLUDED_
claus
parents: 434
diff changeset
   493
#  include <signal.h>
claus
parents: 434
diff changeset
   494
#  define _SIGNAL_H_INCLUDED_
claus
parents: 434
diff changeset
   495
# endif
claus
parents: 434
diff changeset
   496
claus
parents: 434
diff changeset
   497
# ifndef _SYS_TYPES_H_INCLUDED_
claus
parents: 434
diff changeset
   498
#  include <sys/types.h>
claus
parents: 434
diff changeset
   499
#  define _SYS_TYPES_H_INCLUDED_
claus
parents: 434
diff changeset
   500
# endif
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   501
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   502
# if (!defined(HAVE_GNU_LD) && !defined (__ELF__)) || !defined(LINUX)
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   503
#  define       __environ       environ
512
f440411a55e4 no redef warnings on LINUX
Claus Gittinger <cg@exept.de>
parents: 511
diff changeset
   504
#  if !defined(LINUX)
530
07d0bce293c9 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 520
diff changeset
   505
#   define      __sigemptyset   sigemptyset
07d0bce293c9 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 520
diff changeset
   506
#   define      __sigaction     sigaction
07d0bce293c9 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 520
diff changeset
   507
#   define      __sigaddset     sigaddset
07d0bce293c9 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 520
diff changeset
   508
#   define      __sigprocmask   sigprocmask
07d0bce293c9 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 520
diff changeset
   509
#   define      __execve        execve
07d0bce293c9 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 520
diff changeset
   510
#   define      __wait          wait
07d0bce293c9 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 520
diff changeset
   511
#   define      __waitpid       waitpid
674
fba47329ac9d fixed startProcess
Claus Gittinger <cg@exept.de>
parents: 670
diff changeset
   512
#   if defined(HAS_VFORK)
530
07d0bce293c9 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 520
diff changeset
   513
#    define     FORK            vfork
514
81fa80a953e2 system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   514
#   else
530
07d0bce293c9 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 520
diff changeset
   515
#    define     FORK            fork
514
81fa80a953e2 system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents: 513
diff changeset
   516
#   endif
512
f440411a55e4 no redef warnings on LINUX
Claus Gittinger <cg@exept.de>
parents: 511
diff changeset
   517
#  endif /* ! LINUX */
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   518
   extern char **environ;
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   519
# endif
f74d003548dc system-fix
claus
parents: 424
diff changeset
   520
f74d003548dc system-fix
claus
parents: 424
diff changeset
   521
# define        SHELL_PATH      "/bin/sh"       /* Path of the shell.  */
f74d003548dc system-fix
claus
parents: 424
diff changeset
   522
# define        SHELL_NAME      "sh"            /* Name to give it.  */
f74d003548dc system-fix
claus
parents: 424
diff changeset
   523
f74d003548dc system-fix
claus
parents: 424
diff changeset
   524
# ifndef        FORK
f74d003548dc system-fix
claus
parents: 424
diff changeset
   525
#  define       FORK    __fork
f74d003548dc system-fix
claus
parents: 424
diff changeset
   526
# endif
f74d003548dc system-fix
claus
parents: 424
diff changeset
   527
f74d003548dc system-fix
claus
parents: 424
diff changeset
   528
# ifndef CONST
f74d003548dc system-fix
claus
parents: 424
diff changeset
   529
#  ifdef __GNUC__
f74d003548dc system-fix
claus
parents: 424
diff changeset
   530
#   define CONST const
f74d003548dc system-fix
claus
parents: 424
diff changeset
   531
#  else
f74d003548dc system-fix
claus
parents: 424
diff changeset
   532
#   define CONST /* nothing */
f74d003548dc system-fix
claus
parents: 424
diff changeset
   533
#  endif
f74d003548dc system-fix
claus
parents: 424
diff changeset
   534
# endif
f74d003548dc system-fix
claus
parents: 424
diff changeset
   535
670
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
   536
static int
511
7626c5474c7f interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
   537
mySystem(line)
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   538
    register CONST char *line;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   539
{
f74d003548dc system-fix
claus
parents: 424
diff changeset
   540
    int status, save;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   541
    pid_t pid;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   542
    struct sigaction sa, intr, quit;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   543
    sigset_t block, omask;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   544
f74d003548dc system-fix
claus
parents: 424
diff changeset
   545
    if (line == NULL)
670
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
   546
	return -1;
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   547
f74d003548dc system-fix
claus
parents: 424
diff changeset
   548
    sa.sa_handler = SIG_IGN;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   549
    sa.sa_flags = 0;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   550
    __sigemptyset (&sa.sa_mask);
f74d003548dc system-fix
claus
parents: 424
diff changeset
   551
f74d003548dc system-fix
claus
parents: 424
diff changeset
   552
    if (__sigaction (SIGINT, &sa, &intr) < 0) {
f74d003548dc system-fix
claus
parents: 424
diff changeset
   553
	DPRINTF(("1: errno=%d\n", errno));
f74d003548dc system-fix
claus
parents: 424
diff changeset
   554
	return -1;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   555
    }
f74d003548dc system-fix
claus
parents: 424
diff changeset
   556
    if (__sigaction (SIGQUIT, &sa, &quit) < 0) {
f74d003548dc system-fix
claus
parents: 424
diff changeset
   557
	save = errno;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   558
	(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
f74d003548dc system-fix
claus
parents: 424
diff changeset
   559
	errno = save;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   560
	DPRINTF(("2: errno=%d\n", errno));
f74d003548dc system-fix
claus
parents: 424
diff changeset
   561
	return -1;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   562
    }
f74d003548dc system-fix
claus
parents: 424
diff changeset
   563
f74d003548dc system-fix
claus
parents: 424
diff changeset
   564
    __sigemptyset (&block);
f74d003548dc system-fix
claus
parents: 424
diff changeset
   565
    __sigaddset (&block, SIGCHLD);
f74d003548dc system-fix
claus
parents: 424
diff changeset
   566
    save = errno;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   567
    if (__sigprocmask(SIG_BLOCK, &block, &omask) < 0) {
f74d003548dc system-fix
claus
parents: 424
diff changeset
   568
	if (errno == ENOSYS)
f74d003548dc system-fix
claus
parents: 424
diff changeset
   569
	    errno = save;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   570
	else {
f74d003548dc system-fix
claus
parents: 424
diff changeset
   571
	    save = errno;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   572
	    (void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL);
f74d003548dc system-fix
claus
parents: 424
diff changeset
   573
	    (void) __sigaction(SIGQUIT, &quit, (struct sigaction *) NULL);
f74d003548dc system-fix
claus
parents: 424
diff changeset
   574
	    errno = save;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   575
	    DPRINTF(("3: errno=%d\n", errno));
f74d003548dc system-fix
claus
parents: 424
diff changeset
   576
	    return -1;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   577
	}
f74d003548dc system-fix
claus
parents: 424
diff changeset
   578
    }
f74d003548dc system-fix
claus
parents: 424
diff changeset
   579
f74d003548dc system-fix
claus
parents: 424
diff changeset
   580
    pid = FORK ();
f74d003548dc system-fix
claus
parents: 424
diff changeset
   581
    if (pid == (pid_t) 0) {
f74d003548dc system-fix
claus
parents: 424
diff changeset
   582
	/* Child side.  */
f74d003548dc system-fix
claus
parents: 424
diff changeset
   583
	CONST char *new_argv[4];
f74d003548dc system-fix
claus
parents: 424
diff changeset
   584
	new_argv[0] = SHELL_NAME;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   585
	new_argv[1] = "-c";
f74d003548dc system-fix
claus
parents: 424
diff changeset
   586
	new_argv[2] = line;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   587
	new_argv[3] = NULL;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   588
f74d003548dc system-fix
claus
parents: 424
diff changeset
   589
	/* Restore the signals.  */
f74d003548dc system-fix
claus
parents: 424
diff changeset
   590
	(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
f74d003548dc system-fix
claus
parents: 424
diff changeset
   591
	(void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
f74d003548dc system-fix
claus
parents: 424
diff changeset
   592
	(void) __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL);
f74d003548dc system-fix
claus
parents: 424
diff changeset
   593
f74d003548dc system-fix
claus
parents: 424
diff changeset
   594
	/* Exec the shell.  */
f74d003548dc system-fix
claus
parents: 424
diff changeset
   595
	(void) __execve (SHELL_PATH, (char *CONST *) new_argv, __environ);
f74d003548dc system-fix
claus
parents: 424
diff changeset
   596
	_exit (127);
f74d003548dc system-fix
claus
parents: 424
diff changeset
   597
    } else {
f74d003548dc system-fix
claus
parents: 424
diff changeset
   598
	if (pid < (pid_t) 0) {
f74d003548dc system-fix
claus
parents: 424
diff changeset
   599
	    /* The fork failed.  */
f74d003548dc system-fix
claus
parents: 424
diff changeset
   600
	    DPRINTF(("4: errno=%d\n", errno));
f74d003548dc system-fix
claus
parents: 424
diff changeset
   601
	    status = -1;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   602
	} else {
f74d003548dc system-fix
claus
parents: 424
diff changeset
   603
	    /* Parent side.  */
f74d003548dc system-fix
claus
parents: 424
diff changeset
   604
#ifdef  NO_WAITPID
f74d003548dc system-fix
claus
parents: 424
diff changeset
   605
	    pid_t child;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   606
f74d003548dc system-fix
claus
parents: 424
diff changeset
   607
	    do {
805
850571f0255f WANT_SYSTEM for unixware.
Stefan Vogel <sv@exept.de>
parents: 803
diff changeset
   608
		__BEGIN_INTERRUPTABLE__
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   609
		child = __wait (&status);
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   610
		__END_INTERRUPTABLE__
805
850571f0255f WANT_SYSTEM for unixware.
Stefan Vogel <sv@exept.de>
parents: 803
diff changeset
   611
		if (child < 0 && errno != EINTR) {
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   612
		    DPRINTF(("5: errno=%d\n", errno));
f74d003548dc system-fix
claus
parents: 424
diff changeset
   613
		    status = -1;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   614
		    break;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   615
		}
f74d003548dc system-fix
claus
parents: 424
diff changeset
   616
	    } while (child != pid);
f74d003548dc system-fix
claus
parents: 424
diff changeset
   617
#else
f74d003548dc system-fix
claus
parents: 424
diff changeset
   618
	    pid_t child;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   619
f74d003548dc system-fix
claus
parents: 424
diff changeset
   620
	    /* claus: the original did not care for EINTR here ... */
f74d003548dc system-fix
claus
parents: 424
diff changeset
   621
	    do {
805
850571f0255f WANT_SYSTEM for unixware.
Stefan Vogel <sv@exept.de>
parents: 803
diff changeset
   622
		__BEGIN_INTERRUPTABLE__
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   623
		child = __waitpid (pid, &status, 0);
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
   624
		__END_INTERRUPTABLE__
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   625
	    } while ((child != pid) && (errno == EINTR));
f74d003548dc system-fix
claus
parents: 424
diff changeset
   626
	    if (child != pid) {
f74d003548dc system-fix
claus
parents: 424
diff changeset
   627
		DPRINTF(("6: errno=%d\n", errno));
f74d003548dc system-fix
claus
parents: 424
diff changeset
   628
		status = -1;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   629
	    }
f74d003548dc system-fix
claus
parents: 424
diff changeset
   630
#endif /* NO_WAITPID */
f74d003548dc system-fix
claus
parents: 424
diff changeset
   631
	}
f74d003548dc system-fix
claus
parents: 424
diff changeset
   632
    }
f74d003548dc system-fix
claus
parents: 424
diff changeset
   633
    save = errno;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   634
    if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL)
f74d003548dc system-fix
claus
parents: 424
diff changeset
   635
     | __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL)
f74d003548dc system-fix
claus
parents: 424
diff changeset
   636
     | __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)) != 0) {
f74d003548dc system-fix
claus
parents: 424
diff changeset
   637
	if (errno == ENOSYS) {
f74d003548dc system-fix
claus
parents: 424
diff changeset
   638
	    errno = save;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   639
	} else {
f74d003548dc system-fix
claus
parents: 424
diff changeset
   640
	    status = -1;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   641
	    DPRINTF(("7: errno=%d\n", errno));
f74d003548dc system-fix
claus
parents: 424
diff changeset
   642
	}
f74d003548dc system-fix
claus
parents: 424
diff changeset
   643
    }
f74d003548dc system-fix
claus
parents: 424
diff changeset
   644
f74d003548dc system-fix
claus
parents: 424
diff changeset
   645
    return status;
f74d003548dc system-fix
claus
parents: 424
diff changeset
   646
}
1441
91284e90f42a sunos has no __wait
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   647
#else
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   648
# define __wait wait
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   649
#endif /* WANT_SYSTEM */
f74d003548dc system-fix
claus
parents: 424
diff changeset
   650
670
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
   651
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   652
/*
f74d003548dc system-fix
claus
parents: 424
diff changeset
   653
 * some systems do not have realpath();
f74d003548dc system-fix
claus
parents: 424
diff changeset
   654
 * the alternative of reading from a 'pwp'-pipe
f74d003548dc system-fix
claus
parents: 424
diff changeset
   655
 * is way too slow. Here is a realpath for the rest of us.
440
claus
parents: 439
diff changeset
   656
 * define WANT_REALPATH in the xxxIntern-file to get it.
433
f74d003548dc system-fix
claus
parents: 424
diff changeset
   657
 */
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   658
440
claus
parents: 439
diff changeset
   659
#if defined(HAS_REALPATH)
claus
parents: 439
diff changeset
   660
# undef WANT_REALPATH
claus
parents: 439
diff changeset
   661
#endif
claus
parents: 439
diff changeset
   662
#if !defined(HAS_GETWD) && !defined(HAS_GETCWD)
claus
parents: 439
diff changeset
   663
# undef WANT_REALPATH
claus
parents: 439
diff changeset
   664
#endif
claus
parents: 439
diff changeset
   665
claus
parents: 439
diff changeset
   666
#if defined(WANT_REALPATH)
406
claus
parents: 384
diff changeset
   667
claus
parents: 384
diff changeset
   668
# ifndef NULL
claus
parents: 384
diff changeset
   669
#  define NULL (char *)0
claus
parents: 384
diff changeset
   670
# endif
claus
parents: 384
diff changeset
   671
439
claus
parents: 438
diff changeset
   672
# define MAX_READLINKS 32
claus
parents: 438
diff changeset
   673
claus
parents: 438
diff changeset
   674
# ifndef MAXPATHLEN
claus
parents: 438
diff changeset
   675
#  define MAXPATHLEN     1024
claus
parents: 438
diff changeset
   676
# endif
406
claus
parents: 384
diff changeset
   677
claus
parents: 384
diff changeset
   678
static
claus
parents: 384
diff changeset
   679
char *realpath(path, resolved_path)
claus
parents: 384
diff changeset
   680
char *path;
claus
parents: 384
diff changeset
   681
char resolved_path [];
claus
parents: 384
diff changeset
   682
{
claus
parents: 384
diff changeset
   683
	char copy_path[MAXPATHLEN];
claus
parents: 384
diff changeset
   684
	char link_path[MAXPATHLEN];
claus
parents: 384
diff changeset
   685
	char *new_path = resolved_path;
claus
parents: 384
diff changeset
   686
	char *max_path;
claus
parents: 384
diff changeset
   687
	int readlinks = 0;
claus
parents: 384
diff changeset
   688
	int n;
claus
parents: 384
diff changeset
   689
claus
parents: 384
diff changeset
   690
	/* Make a copy of the source path since we may need to modify it. */
claus
parents: 384
diff changeset
   691
	strcpy(copy_path, path);
claus
parents: 384
diff changeset
   692
	path = copy_path;
claus
parents: 384
diff changeset
   693
	max_path = copy_path + MAXPATHLEN - 2;
claus
parents: 384
diff changeset
   694
	/* If it's a relative pathname use getwd for starters. */
claus
parents: 384
diff changeset
   695
	if (*path != '/') {
claus
parents: 384
diff changeset
   696
#ifdef HAS_GETCWD
claus
parents: 384
diff changeset
   697
		getcwd(new_path, MAXPATHLEN - 1);
claus
parents: 384
diff changeset
   698
#else
claus
parents: 384
diff changeset
   699
		getwd(new_path);
claus
parents: 384
diff changeset
   700
#endif
claus
parents: 384
diff changeset
   701
		new_path += strlen(new_path);
claus
parents: 384
diff changeset
   702
		if (new_path[-1] != '/')
claus
parents: 384
diff changeset
   703
			*new_path++ = '/';
claus
parents: 384
diff changeset
   704
	}
claus
parents: 384
diff changeset
   705
	else {
claus
parents: 384
diff changeset
   706
		*new_path++ = '/';
claus
parents: 384
diff changeset
   707
		path++;
claus
parents: 384
diff changeset
   708
	}
claus
parents: 384
diff changeset
   709
	/* Expand each slash-separated pathname component. */
claus
parents: 384
diff changeset
   710
	while (*path != '\0') {
claus
parents: 384
diff changeset
   711
		/* Ignore stray "/". */
claus
parents: 384
diff changeset
   712
		if (*path == '/') {
claus
parents: 384
diff changeset
   713
			path++;
claus
parents: 384
diff changeset
   714
			continue;
claus
parents: 384
diff changeset
   715
		}
claus
parents: 384
diff changeset
   716
		if (*path == '.') {
claus
parents: 384
diff changeset
   717
			/* Ignore ".". */
claus
parents: 384
diff changeset
   718
			if (path[1] == '\0' || path[1] == '/') {
claus
parents: 384
diff changeset
   719
				path++;
claus
parents: 384
diff changeset
   720
				continue;
claus
parents: 384
diff changeset
   721
			}
claus
parents: 384
diff changeset
   722
			if (path[1] == '.') {
claus
parents: 384
diff changeset
   723
				if (path[2] == '\0' || path[2] == '/') {
claus
parents: 384
diff changeset
   724
					path += 2;
claus
parents: 384
diff changeset
   725
					/* Ignore ".." at root. */
claus
parents: 384
diff changeset
   726
					if (new_path == resolved_path + 1)
claus
parents: 384
diff changeset
   727
						continue;
claus
parents: 384
diff changeset
   728
					/* Handle ".." by backing up. */
claus
parents: 384
diff changeset
   729
					while ((--new_path)[-1] != '/')
claus
parents: 384
diff changeset
   730
						;
claus
parents: 384
diff changeset
   731
					continue;
claus
parents: 384
diff changeset
   732
				}
claus
parents: 384
diff changeset
   733
			}
claus
parents: 384
diff changeset
   734
		}
claus
parents: 384
diff changeset
   735
		/* Safely copy the next pathname component. */
claus
parents: 384
diff changeset
   736
		while (*path != '\0' && *path != '/') {
claus
parents: 384
diff changeset
   737
			if (path > max_path) {
claus
parents: 384
diff changeset
   738
				errno = ENAMETOOLONG;
claus
parents: 384
diff changeset
   739
				return NULL;
claus
parents: 384
diff changeset
   740
			}
claus
parents: 384
diff changeset
   741
			*new_path++ = *path++;
claus
parents: 384
diff changeset
   742
		}
claus
parents: 384
diff changeset
   743
#ifdef S_IFLNK
claus
parents: 384
diff changeset
   744
		/* Protect against infinite loops. */
claus
parents: 384
diff changeset
   745
		if (readlinks++ > MAX_READLINKS) {
claus
parents: 384
diff changeset
   746
			errno = ELOOP;
claus
parents: 384
diff changeset
   747
			return NULL;
claus
parents: 384
diff changeset
   748
		}
claus
parents: 384
diff changeset
   749
		/* See if latest pathname component is a symlink. */
claus
parents: 384
diff changeset
   750
		*new_path = '\0';
claus
parents: 384
diff changeset
   751
		n = readlink(resolved_path, link_path, MAXPATHLEN - 1);
claus
parents: 384
diff changeset
   752
		if (n < 0) {
claus
parents: 384
diff changeset
   753
			/* EINVAL means the file exists but isn't a symlink. */
claus
parents: 384
diff changeset
   754
			if (errno != EINVAL)
claus
parents: 384
diff changeset
   755
				return NULL;
claus
parents: 384
diff changeset
   756
		}
claus
parents: 384
diff changeset
   757
		else {
claus
parents: 384
diff changeset
   758
			/* Note: readlink doesn't add the null byte. */
claus
parents: 384
diff changeset
   759
			link_path[n] = '\0';
claus
parents: 384
diff changeset
   760
			if (*link_path == '/')
claus
parents: 384
diff changeset
   761
				/* Start over for an absolute symlink. */
claus
parents: 384
diff changeset
   762
				new_path = resolved_path;
claus
parents: 384
diff changeset
   763
			else
claus
parents: 384
diff changeset
   764
				/* Otherwise back up over this component. */
claus
parents: 384
diff changeset
   765
				while (*(--new_path) != '/')
claus
parents: 384
diff changeset
   766
					;
claus
parents: 384
diff changeset
   767
			/* Safe sex check. */
claus
parents: 384
diff changeset
   768
			if (strlen(path) + n >= MAXPATHLEN) {
claus
parents: 384
diff changeset
   769
				errno = ENAMETOOLONG;
claus
parents: 384
diff changeset
   770
				return NULL;
claus
parents: 384
diff changeset
   771
			}
claus
parents: 384
diff changeset
   772
			/* Insert symlink contents into path. */
claus
parents: 384
diff changeset
   773
			strcat(link_path, path);
claus
parents: 384
diff changeset
   774
			strcpy(copy_path, link_path);
claus
parents: 384
diff changeset
   775
			path = copy_path;
claus
parents: 384
diff changeset
   776
		}
claus
parents: 384
diff changeset
   777
#endif /* S_IFLNK */
claus
parents: 384
diff changeset
   778
		*new_path++ = '/';
claus
parents: 384
diff changeset
   779
	}
claus
parents: 384
diff changeset
   780
	/* Delete trailing slash but don't whomp a lone slash. */
claus
parents: 384
diff changeset
   781
	if (new_path != resolved_path + 1 && new_path[-1] == '/')
claus
parents: 384
diff changeset
   782
		new_path--;
claus
parents: 384
diff changeset
   783
	/* Make sure it's null terminated. */
claus
parents: 384
diff changeset
   784
	*new_path = '\0';
claus
parents: 384
diff changeset
   785
	return resolved_path;
claus
parents: 384
diff changeset
   786
}
claus
parents: 384
diff changeset
   787
# define HAS_REALPATH
claus
parents: 384
diff changeset
   788
#endif /* WANT_REALPATH && not HAS_REALPATH */
claus
parents: 384
diff changeset
   789
%}
claus
parents: 384
diff changeset
   790
! !
claus
parents: 384
diff changeset
   791
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
   792
!OperatingSystem class methodsFor:'documentation'!
2
claus
parents: 1
diff changeset
   793
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   794
copyright
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   795
"
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   796
 COPYRIGHT (c) 1988 by Claus Gittinger
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
   797
	      All Rights Reserved
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   798
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   799
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   800
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   801
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   802
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   803
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   804
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   805
"
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   806
!
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   807
2
claus
parents: 1
diff changeset
   808
documentation
claus
parents: 1
diff changeset
   809
"
530
07d0bce293c9 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 520
diff changeset
   810
    this class realizes access to most (all ?) required operating system services;
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
   811
    some of it is very specific for unix, so do not depend on
1619
2ce129068706 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1617
diff changeset
   812
    things available here in your applications 
2ce129068706 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1617
diff changeset
   813
    - some may not be found in other OS's or be slightly different ...
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
   814
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
   815
    (On the other hand: I do not want to hide all features
759
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 756
diff changeset
   816
     from you - in some situations it MAY be interesting to be
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
   817
     able to get down to a select or fork system call easily (at least on Unix systems).
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
   818
     You decide - portability vs. functionality)
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
   819
1286
4270a0b4917d documentation
Claus Gittinger <cg@exept.de>
parents: 1280
diff changeset
   820
    [Class variables:]
4270a0b4917d documentation
Claus Gittinger <cg@exept.de>
parents: 1280
diff changeset
   821
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   822
	HostName        <String>        remembered hostname
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   823
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   824
	DomainName      <String>        remembered domainname
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   825
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   826
	LastErrorNumber <Integer>       the last value of errno
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   827
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   828
	OSSignals       <Array>         Array of signals to be raised for corresponding
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   829
					OperatingSystem signals.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   830
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   831
	ForkFailed      <Boolean>       set if a fork (or popen) has failed;
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   832
					ST/X will avoid doing more forks/popens
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   833
					if this flag is set, for a slightly
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   834
					smoother operation.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   835
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   836
	SlowFork        <Boolean>       if set, fork and popen are avoided;
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   837
					(more or less obsolete now)
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   838
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   839
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   840
	ErrorSignal     <Signal>        Parentsignal of all OS error signals.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   841
					not directly raised.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   842
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   843
	AccessDeniedErrorSignal
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   844
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   845
	FileNotFoundErrorSignal
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   846
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   847
	LocaleInfo      <Dictionary>    if non nil, that is taken instead of the operating
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   848
					systems locale definitions (allows for overwriting
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   849
					these, or provide a compatible info on systems which do
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   850
					not support locales)
1286
4270a0b4917d documentation
Claus Gittinger <cg@exept.de>
parents: 1280
diff changeset
   851
4270a0b4917d documentation
Claus Gittinger <cg@exept.de>
parents: 1280
diff changeset
   852
    [author:]
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   853
	Claus Gittinger
1286
4270a0b4917d documentation
Claus Gittinger <cg@exept.de>
parents: 1280
diff changeset
   854
4270a0b4917d documentation
Claus Gittinger <cg@exept.de>
parents: 1280
diff changeset
   855
    [see also:]
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   856
	OSProcessStatus
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   857
	Filename Date Time
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   858
	ExternalStream FileStream PipeStream Socket
2
claus
parents: 1
diff changeset
   859
"
1619
2ce129068706 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1617
diff changeset
   860
!
2ce129068706 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1617
diff changeset
   861
2ce129068706 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1617
diff changeset
   862
examples
2ce129068706 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1617
diff changeset
   863
"
1622
e40404e0a49d more examples
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   864
  various queries
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   865
								[exBegin]
1622
e40404e0a49d more examples
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   866
    Transcript 
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   867
	showCR:'hello ' , (OperatingSystem getLoginName)
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   868
								[exEnd]
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   869
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   870
								[exBegin]
1622
e40404e0a49d more examples
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   871
    OperatingSystem isUNIXlike ifTrue:[
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   872
	Transcript showCR:'this is some UNIX-like OS'
1622
e40404e0a49d more examples
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   873
    ] ifFalse:[
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   874
	Transcript showCR:'this OS is not UNIX-like'
1622
e40404e0a49d more examples
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   875
    ]
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   876
								[exEnd]
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   877
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   878
								[exBegin]
1622
e40404e0a49d more examples
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   879
    Transcript 
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   880
	showCR:'this machine is called ' , OperatingSystem getHostName
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   881
								[exEnd]
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   882
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   883
								[exBegin]
1622
e40404e0a49d more examples
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   884
    Transcript 
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   885
	showCR:('this machine is in the '
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   886
	       , OperatingSystem getDomainName
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   887
	       , ' domain')
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   888
								[exEnd]
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   889
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   890
								[exBegin]
1622
e40404e0a49d more examples
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   891
    Transcript 
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   892
	showCR:('this machine''s CPU is a '
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   893
	       , OperatingSystem getCPUType
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   894
	       )
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   895
								[exEnd]
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   896
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   897
								[exBegin]
1622
e40404e0a49d more examples
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   898
    Transcript showCR:'executing ls command ...'.
e40404e0a49d more examples
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   899
    OperatingSystem executeCommand:'ls'.
e40404e0a49d more examples
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   900
    Transcript showCR:'... done.'.
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   901
								[exEnd]
1622
e40404e0a49d more examples
Claus Gittinger <cg@exept.de>
parents: 1621
diff changeset
   902
1621
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
   903
  locking a file 
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
   904
  (should be executed on two running smalltalks - not in two threads):
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   905
								[exBegin]
1621
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
   906
    |f|
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
   907
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
   908
    f := 'testFile' asFilename readWriteStream.
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
   909
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
   910
    10 timesRepeat:[
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   911
	'about to lock ...' printCR.
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   912
	[
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   913
	  OperatingSystem 
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   914
	    lockFD:(f fileDescriptor)
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   915
	    shared:false
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   916
	    blocking:false
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   917
	] whileFalse:[
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   918
	    'process ' print. OperatingSystem getProcessId print. ' is waiting' printCR.
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   919
	    Delay waitForSeconds:1
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   920
	].
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   921
	'LOCKED ...' printCR.
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   922
	Delay waitForSeconds:10.
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   923
	'unlock ...' printCR.
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   924
	(OperatingSystem 
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   925
	    unlockFD:(f fileDescriptor)) printCR.
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   926
	Delay waitForSeconds:3.
1621
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
   927
    ]
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   928
								[exBegin]
1619
2ce129068706 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1617
diff changeset
   929
"
2
claus
parents: 1
diff changeset
   930
! !
claus
parents: 1
diff changeset
   931
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
   932
!OperatingSystem class methodsFor:'initialization'!
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   933
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   934
initialize
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
   935
    "initialize the class"
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
   936
540
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   937
    ObjectMemory addDependent:self.
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   938
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   939
    ErrorSignal isNil ifTrue:[
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   940
	ErrorSignal := Object errorSignal newSignalMayProceed:true..
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   941
	ErrorSignal nameClass:self message:#errorSignal.
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   942
	ErrorSignal notifierString:'OS error encountered'.
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   943
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   944
	AccessDeniedErrorSignal := ErrorSignal newSignalMayProceed:true.
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   945
	AccessDeniedErrorSignal nameClass:self message:#accessDeniedError.
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   946
	AccessDeniedErrorSignal notifierString:'OS access denied'.
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   947
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   948
	FileNotFoundErrorSignal := ErrorSignal newSignalMayProceed:true.
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   949
	FileNotFoundErrorSignal nameClass:self message:#fileNotFoundErrorSignal.
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   950
	FileNotFoundErrorSignal notifierString:'OS file not found'.
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   951
    ]
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   952
!
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   953
1470
266520246a88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1441
diff changeset
   954
update:something with:aParameter from:changedObject
1247
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
   955
    "catch image restart and flush some cached data"
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
   956
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   957
    something == #earlyRestart ifTrue:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   958
	"
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   959
	 flush cached data
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   960
	"
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   961
	HostName := nil.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   962
	DomainName := nil.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
   963
	LastErrorNumber := nil.
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   964
    ]
1247
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
   965
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
   966
    "Modified: 22.4.1996 / 13:10:43 / cg"
1470
266520246a88 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1441
diff changeset
   967
    "Created: 15.6.1996 / 15:22:37 / cg"
2080
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
   968
    "Modified: 7.1.1997 / 19:36:11 / stefan"
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   969
! !
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   970
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
   971
!OperatingSystem class methodsFor:'OS signal constants'!
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   972
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   973
sigABRT
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   974
    "return the signal number for SIGABRT - 0 if not supported by OS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   975
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   976
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   977
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   978
#ifdef SIGABRT
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
   979
    RETURN ( __MKSMALLINT(SIGABRT) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   980
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
   981
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   982
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   983
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   984
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   985
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   986
sigALRM
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   987
    "return the signal number for SIGALRM - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   988
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   989
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   990
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   991
#ifdef SIGALRM
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
   992
    RETURN ( __MKSMALLINT(SIGALRM) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   993
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
   994
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   995
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   996
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   997
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   998
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   999
sigBREAK
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1000
    "return the signal number for SIGBREAK - 0 if not supported.
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1001
     This is an MSDOS specific signal"
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1002
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1003
%{  /* NOCONTEXT */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1004
#ifdef SIGBREAK
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1005
    RETURN ( __MKSMALLINT(SIGBREAK) );
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1006
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1007
    RETURN ( __MKSMALLINT(0) );
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1008
#endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1009
%}
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1010
!
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  1011
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1012
sigBUS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1013
    "return the signal number for SIGBUS - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1014
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1015
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1016
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1017
#ifdef SIGBUS
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1018
    RETURN ( __MKSMALLINT(SIGBUS) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1019
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1020
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1021
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1022
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1023
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1024
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1025
sigCHLD
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1026
    "return the signal number for SIGCHLD - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1027
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1028
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1029
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1030
#if defined(SIGCHLD)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1031
    RETURN ( __MKSMALLINT(SIGCHLD) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1032
#else
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1033
# if  defined(SIGCLD)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1034
    RETURN ( __MKSMALLINT(SIGCLD) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1035
# else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1036
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1037
# endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1038
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1039
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1040
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1041
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1042
sigCONT
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1043
    "return the signal number for SIGCONT - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1044
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1045
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1046
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1047
#if defined(SIGCONT)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1048
    RETURN ( __MKSMALLINT(SIGCONT) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1049
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1050
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1051
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1052
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1053
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1054
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1055
sigDANGER
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1056
    "return the signal number for SIGDANGER - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1057
     (seems to be an AIX special)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1058
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1059
%{  /* NOCONTEXT */
710
10d86ca4c4a6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 704
diff changeset
  1060
#if defined(SIGDANGER)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1061
    RETURN ( __MKSMALLINT(SIGDANGER) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1062
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1063
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1064
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1065
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1066
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1067
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1068
sigEMT
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1069
    "return the signal number for SIGEMT - 0 if not supported by OS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1070
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1071
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1072
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1073
#ifdef SIGEMT
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1074
    RETURN ( __MKSMALLINT(SIGEMT) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1075
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1076
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1077
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1078
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1079
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1080
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1081
sigFP
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1082
    "return the signal number for SIGFP - 0 if not supported by OS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1083
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1084
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1085
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1086
#ifdef SIGFPE
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1087
    RETURN ( __MKSMALLINT(SIGFPE) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1088
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1089
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1090
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1091
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1092
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1093
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1094
sigGRANT
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1095
    "return the signal number for SIGGRANT - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1096
     (seems to be an AIX special)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1097
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1098
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1099
#if defined(SIGGRANT)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1100
    RETURN ( __MKSMALLINT(SIGGRANT) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1101
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1102
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1103
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1104
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1105
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1106
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1107
sigHUP
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1108
    "return the signal number for SIGHUP
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1109
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1110
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1111
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1112
#ifdef SIGHUP
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1113
    RETURN ( __MKSMALLINT(SIGHUP) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1114
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1115
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1116
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1117
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1118
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1119
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1120
sigILL
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1121
    "return the signal number for SIGILL - 0 if not supported by OS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1122
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1123
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1124
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1125
#ifdef SIGILL
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1126
    RETURN ( __MKSMALLINT(SIGILL) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1127
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1128
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1129
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1130
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1131
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1132
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1133
sigINT
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1134
    "return the signal number for SIGINT
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1135
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1136
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1137
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1138
#ifdef SIGINT
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1139
    RETURN ( __MKSMALLINT(SIGINT) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1140
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1141
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1142
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1143
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1144
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1145
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1146
sigIO
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1147
    "return the signal number for SIGIO - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1148
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1149
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1150
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1151
#if defined(SIGIO)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1152
    RETURN ( __MKSMALLINT(SIGIO) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1153
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1154
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1155
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1156
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1157
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1158
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1159
sigIOT
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1160
    "return the signal number for SIGIOT - 0 if not supported by OS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1161
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1162
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1163
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1164
#ifdef SIGIOT
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1165
    RETURN ( __MKSMALLINT(SIGIOT) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1166
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1167
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1168
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1169
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1170
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1171
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1172
sigKILL
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1173
    "return the signal number for SIGKILL
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1174
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1175
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1176
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1177
#ifdef SIGKILL
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1178
    RETURN ( __MKSMALLINT(SIGKILL) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1179
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1180
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1181
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1182
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1183
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1184
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1185
sigLOST
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1186
    "return the signal number for SIGLOST - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1187
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1188
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1189
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1190
#if defined(SIGLOST)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1191
    RETURN ( __MKSMALLINT(SIGLOST) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1192
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1193
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1194
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1195
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1196
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1197
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1198
sigMIGRATE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1199
    "return the signal number for SIGMIGRATE - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1200
     (seems to be an AIX special)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1201
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1202
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1203
#if defined(SIGMIGRATE)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1204
    RETURN ( __MKSMALLINT(SIGMIGRATE) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1205
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1206
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1207
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1208
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1209
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1210
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1211
sigMSG
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1212
    "return the signal number for SIGMSG - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1213
     (seems to be an AIX special)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1214
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1215
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1216
#if defined(SIGMSG)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1217
    RETURN ( __MKSMALLINT(SIGMSG) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1218
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1219
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1220
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1221
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1222
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1223
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1224
sigPIPE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1225
    "return the signal number for SIGPIPE - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1226
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1227
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1228
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1229
#ifdef SIGPIPE
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1230
    RETURN ( __MKSMALLINT(SIGPIPE) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1231
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1232
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1233
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1234
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1235
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1236
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1237
sigPOLL
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1238
    "return the signal number for SIGPOLL - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1239
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1240
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1241
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1242
#if defined(SIGPOLL)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1243
    RETURN ( __MKSMALLINT(SIGPOLL) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1244
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1245
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1246
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1247
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1248
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1249
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1250
sigPRE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1251
    "return the signal number for SIGPRE - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1252
     (seems to be an AIX special)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1253
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1254
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1255
#if defined(SIGPRE)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1256
    RETURN ( __MKSMALLINT(SIGPRE) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1257
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1258
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1259
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1260
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1261
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1262
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1263
sigPROF
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1264
    "return the signal number for SIGPROF - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1265
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1266
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1267
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1268
#if defined(SIGPROF)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1269
    RETURN ( __MKSMALLINT(SIGPROF) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1270
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1271
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1272
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1273
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1274
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1275
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1276
sigPWR
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1277
    "return the signal number for SIGPWR - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1278
     (not available on all systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1279
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1280
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1281
#if defined(SIGPWR)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1282
    RETURN ( __MKSMALLINT(SIGPWR) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1283
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1284
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1285
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1286
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1287
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1288
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1289
sigQUIT
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1290
    "return the signal number for SIGQUIT
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1291
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1292
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1293
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1294
#ifdef SIGQUIT
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1295
    RETURN ( __MKSMALLINT(SIGQUIT) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1296
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1297
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1298
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1299
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1300
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1301
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1302
sigRETRACT
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1303
    "return the signal number for SIGRETRACT - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1304
     (seems to be an AIX special)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1305
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1306
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1307
#if defined(SIGRETRACT)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1308
    RETURN ( __MKSMALLINT(SIGRETRACT) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1309
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1310
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1311
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1312
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1313
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1314
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1315
sigSAK
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1316
    "return the signal number for SIGSAK - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1317
     (seems to be an AIX special)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1318
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1319
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1320
#if defined(SIGSAK)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1321
    RETURN ( __MKSMALLINT(SIGSAK) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1322
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1323
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1324
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1325
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1326
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1327
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1328
sigSEGV
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1329
    "return the signal number for SIGSEGV - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1330
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1331
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1332
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1333
#ifdef SIGSEGV
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1334
    RETURN ( __MKSMALLINT(SIGSEGV) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1335
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1336
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1337
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1338
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1339
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1340
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1341
sigSOUND
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1342
    "return the signal number for SIGSOUND - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1343
     (seems to be an AIX special)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1344
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1345
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1346
#if defined(SIGSOUND)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1347
    RETURN ( __MKSMALLINT(SIGSOUND) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1348
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1349
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1350
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1351
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1352
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1353
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1354
sigSTOP
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1355
    "return the signal number for SIGSTOP - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1356
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1357
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1358
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1359
#if defined(SIGSTOP)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1360
    RETURN ( __MKSMALLINT(SIGSTOP) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1361
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1362
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1363
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1364
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1365
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1366
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1367
sigSYS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1368
    "return the signal number for SIGSYS - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1369
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1370
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1371
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1372
#ifdef SIGSYS
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1373
    RETURN ( __MKSMALLINT(SIGSYS) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1374
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1375
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1376
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1377
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1378
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1379
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1380
sigTERM
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1381
    "return the signal number for SIGTERM - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1382
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1383
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1384
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1385
#ifdef SIGTERM
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1386
    RETURN ( __MKSMALLINT(SIGTERM) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1387
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1388
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1389
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1390
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1391
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1392
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1393
sigTRAP
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1394
    "return the signal number for SIGTRAP - 0 if not supported by OS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1395
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1396
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1397
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1398
#ifdef SIGTRAP
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1399
    RETURN ( __MKSMALLINT(SIGTRAP) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1400
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1401
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1402
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1403
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1404
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1405
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1406
sigTSTP
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1407
    "return the signal number for SIGTSTP - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1408
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1409
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1410
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1411
#if defined(SIGTSTP)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1412
    RETURN ( __MKSMALLINT(SIGTSTP) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1413
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1414
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1415
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1416
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1417
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1418
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1419
sigTTIN
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1420
    "return the signal number for SIGTTIN - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1421
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1422
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1423
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1424
#if defined(SIGTTIN)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1425
    RETURN ( __MKSMALLINT(SIGTTIN) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1426
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1427
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1428
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1429
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1430
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1431
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1432
sigTTOU
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1433
    "return the signal number for SIGTTOU - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1434
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1435
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1436
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1437
#if defined(SIGTTOU)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1438
    RETURN ( __MKSMALLINT(SIGTTOU) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1439
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1440
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1441
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1442
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1443
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1444
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1445
sigURG
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1446
    "return the signal number for SIGURG - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1447
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1448
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1449
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1450
#if defined(SIGURG)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1451
    RETURN ( __MKSMALLINT(SIGURG) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1452
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1453
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1454
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1455
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1456
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1457
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1458
sigUSR1
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1459
    "return the signal number for SIGUSR1 - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1460
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1461
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1462
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1463
#if defined(SIGUSR1)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1464
    RETURN ( __MKSMALLINT(SIGUSR1) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1465
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1466
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1467
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1468
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1469
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1470
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1471
sigUSR2
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1472
    "return the signal number for SIGUSR2 - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1473
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1474
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1475
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1476
#if defined(SIGUSR2)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1477
    RETURN ( __MKSMALLINT(SIGUSR2) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1478
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1479
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1480
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1481
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1482
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1483
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1484
sigVTALRM
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1485
    "return the signal number for SIGVTALRM - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1486
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1487
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1488
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1489
#if defined(SIGVTALRM)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1490
    RETURN ( __MKSMALLINT(SIGVTALRM) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1491
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1492
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1493
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1494
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1495
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1496
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1497
sigWINCH
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1498
    "return the signal number for SIGWINCH - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1499
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1500
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1501
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1502
#if defined(SIGWINCH)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1503
    RETURN ( __MKSMALLINT(SIGWINCH) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1504
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1505
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1506
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1507
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1508
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1509
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1510
sigXCPU
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1511
    "return the signal number for SIGXCPU - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1512
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1513
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1514
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1515
#if defined(SIGXCPU)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1516
    RETURN ( __MKSMALLINT(SIGXCPU) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1517
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1518
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1519
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1520
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1521
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1522
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1523
sigXFSZ
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1524
    "return the signal number for SIGXFSZ - 0 if not supported
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1525
     (the numeric value is not the same across unix-systems)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1526
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1527
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1528
#if defined(SIGXFSZ)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1529
    RETURN ( __MKSMALLINT(SIGXFSZ) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1530
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1531
    RETURN ( __MKSMALLINT(0) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1532
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1533
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1534
! !
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1535
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  1536
!OperatingSystem class methodsFor:'Signal constants'!
540
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
  1537
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1538
accessDeniedErrorSignal
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1539
    "return the signal raised when a (file-) access is denied."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1540
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1541
    ^ AccessDeniedErrorSignal
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1542
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  1543
540
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
  1544
errorSignal
1247
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  1545
    "return the parent signal of all OS signals."
540
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
  1546
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
  1547
    ^ ErrorSignal
1247
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  1548
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  1549
    "Modified: 22.4.1996 / 13:11:31 / cg"
540
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
  1550
!
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
  1551
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
  1552
fileNotFoundErrorSignal
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
  1553
    "return the signal raised when a file was not found."
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
  1554
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
  1555
    ^ FileNotFoundErrorSignal
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
  1556
! !
c34cd0a2fd5f OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
  1557
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  1558
!OperatingSystem class methodsFor:'error messages'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1559
1153
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1560
clearLastErrorNumber
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1561
    "return the last errors number.
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1562
     See also: #lastErrorSymbol and #lastErrorString.
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1563
     Notice: having a single error number is a bad idea in a multithreaded
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  1564
	     environment - this interface will change."
1153
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1565
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1566
    LastErrorNumber := nil.
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1567
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1568
     "
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1569
      OperatingSystem clearLastErrorNumber
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1570
     "
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1571
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1572
    "Created: 12.4.1996 / 09:28:58 / stefan"
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1573
    "Modified: 12.4.1996 / 09:38:51 / stefan"
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1574
!
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  1575
85
claus
parents: 77
diff changeset
  1576
currentErrorNumber
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  1577
    "returns the OS's last error nr (i.e. the value of errno).
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  1578
     Notice, that the value of this flag is only valid immediately
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  1579
     after the error occurred - it gets updated with every other
85
claus
parents: 77
diff changeset
  1580
     request to the OS.
claus
parents: 77
diff changeset
  1581
     Use lastErrorNumber - currentErrorNumber is invalidated by
claus
parents: 77
diff changeset
  1582
     many, many internal calls."
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  1583
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  1584
%{  /* NOCONTEXT */
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  1585
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  1586
     RETURN ( __MKSMALLINT(errno) );
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  1587
%}
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  1588
     "
85
claus
parents: 77
diff changeset
  1589
      OperatingSystem currentErrorNumber
claus
parents: 77
diff changeset
  1590
     "
claus
parents: 77
diff changeset
  1591
!
claus
parents: 77
diff changeset
  1592
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1593
errorNumberFor:aSymbol
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1594
    "given a symbolic error, return the numeric;
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1595
     (i.e. errorNumberFor:#EBADF returns EBADF's value).
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1596
     Use this, since error numbers are really not standard across unix systems."
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1597
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1598
%{   /* NOCONTEXT */
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1599
    OBJ sym = aSymbol;
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1600
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1601
    /*
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1602
     * POSIX errnos - these should be defined
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1603
     */
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1604
#ifdef EPERM
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1605
    if (sym == @symbol(EPERM)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1606
	RETURN ( __MKSMALLINT(EPERM) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1607
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1608
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1609
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1610
#ifdef ENOENT
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1611
    if (sym == @symbol(ENOENT)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1612
	RETURN ( __MKSMALLINT(ENOENT) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1613
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1614
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1615
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1616
#ifdef ESRCH
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1617
    if (sym == @symbol(ESRCH)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1618
	RETURN ( __MKSMALLINT(ESRCH) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1619
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1620
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1621
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1622
#ifdef EINTR
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1623
    if (sym == @symbol(EINTR)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1624
	RETURN ( __MKSMALLINT(EINTR) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1625
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1626
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1627
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1628
#ifdef EIO
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1629
    if (sym == @symbol(EIO)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1630
	RETURN ( __MKSMALLINT(EIO) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1631
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1632
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1633
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1634
#ifdef ENXIO
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1635
    if (sym == @symbol(ENXIO)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1636
	RETURN ( __MKSMALLINT(ENXIO) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1637
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1638
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1639
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1640
#ifdef E2BIG
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1641
    if (sym == @symbol(E2BIG)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1642
	RETURN ( __MKSMALLINT(E2BIG) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1643
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1644
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1645
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1646
#ifdef ENOEXEC
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1647
    if (sym == @symbol(ENOEXEC)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1648
	RETURN ( __MKSMALLINT(ENOEXEC) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1649
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1650
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1651
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1652
#ifdef EBADF
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1653
    if (sym == @symbol(EBADF)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1654
	RETURN ( __MKSMALLINT(EBADF) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1655
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1656
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1657
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1658
#ifdef ECHILD
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1659
    if (sym == @symbol(ECHILD)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1660
	RETURN ( __MKSMALLINT(ECHILD) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1661
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1662
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1663
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1664
#if defined(EAGAIN)
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1665
    if (sym == @symbol(EAGAIN)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1666
	RETURN ( __MKSMALLINT(EAGAIN) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1667
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1668
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1669
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1670
#ifdef ENOMEM
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1671
    if (sym == @symbol(ENOMEM)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1672
	RETURN ( __MKSMALLINT(ENOMEM) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1673
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1674
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1675
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1676
#ifdef EACCES
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1677
    if (sym == @symbol(EACCES)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1678
	RETURN ( __MKSMALLINT(EACCES) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1679
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1680
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1681
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1682
#ifdef EFAULT
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1683
    if (sym == @symbol(EFAULT)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1684
	RETURN ( __MKSMALLINT(EFAULT) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1685
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1686
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1687
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1688
#ifdef EBUSY
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1689
    if (sym == @symbol(EBUSY)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1690
	RETURN ( __MKSMALLINT(EBUSY) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1691
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1692
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1693
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1694
#ifdef EXDEV
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1695
    if (sym == @symbol(EXDEV)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1696
	RETURN ( __MKSMALLINT(EXDEV) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1697
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1698
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1699
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1700
#ifdef ENODEV
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1701
    if (sym == @symbol(ENODEV)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1702
	RETURN ( __MKSMALLINT(ENODEV) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1703
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1704
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1705
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1706
#ifdef ENOTDIR
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1707
    if (sym == @symbol(ENOTDIR)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1708
	RETURN ( __MKSMALLINT(ENOTDIR) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1709
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1710
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1711
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1712
#ifdef EISDIR
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1713
    if (sym == @symbol(EISDIR)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1714
	RETURN ( __MKSMALLINT(EISDIR) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1715
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1716
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1717
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1718
#ifdef EINVAL
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1719
    if (sym == @symbol(EINVAL)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1720
	RETURN ( __MKSMALLINT(EINVAL) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1721
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1722
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1723
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1724
#ifdef ENFILE
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1725
    if (sym == @symbol(ENFILE)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1726
	RETURN ( __MKSMALLINT(ENFILE) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1727
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1728
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1729
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1730
#ifdef EMFILE
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1731
    if (sym == @symbol(EMFILE)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1732
	RETURN ( __MKSMALLINT(EMFILE) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1733
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1734
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1735
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1736
#ifdef ENOTTY
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1737
    if (sym == @symbol(ENOTTY)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1738
	RETURN ( __MKSMALLINT(ENOTTY) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1739
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1740
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1741
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1742
#ifdef EFBIG
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1743
    if (sym == @symbol(EFBIG)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1744
	RETURN ( __MKSMALLINT(EFBIG) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1745
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1746
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1747
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1748
#ifdef ENOSPC
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1749
    if (sym == @symbol(ENOSPC)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1750
	RETURN ( __MKSMALLINT(ENOSPC) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1751
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1752
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1753
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1754
#ifdef ESPIPE
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1755
    if (sym == @symbol(ESPIPE)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1756
	RETURN ( __MKSMALLINT(ESPIPE) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1757
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1758
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1759
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1760
#ifdef EROFS
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1761
    if (sym == @symbol(EROFS)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1762
	RETURN ( __MKSMALLINT(EROFS) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1763
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1764
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1765
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1766
#ifdef EMLINK
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1767
    if (sym == @symbol(EMLINK)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1768
	RETURN ( __MKSMALLINT(EMLINK) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1769
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1770
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1771
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1772
#ifdef EPIPE
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1773
    if (sym == @symbol(EPIPE)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1774
	RETURN ( __MKSMALLINT(EPIPE) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1775
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1776
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1777
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1778
#ifdef EDOM
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1779
    if (sym == @symbol(EDOM)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1780
	RETURN ( __MKSMALLINT(EDOM) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1781
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1782
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1783
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1784
#ifdef ERANGE
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1785
    if (sym == @symbol(ERANGE)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1786
	RETURN ( __MKSMALLINT(ERANGE) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1787
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1788
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1789
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1790
#ifdef EDEADLK
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1791
    if (sym == @symbol(EDEADLK)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1792
	RETURN ( __MKSMALLINT(EDEADLK) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1793
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1794
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1795
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1796
#ifdef ENAMETOOLONG
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1797
    if (sym == @symbol(ENAMETOOLONG)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1798
	RETURN ( __MKSMALLINT(ENAMETOOLONG) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1799
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1800
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1801
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1802
#ifdef ENOLCK
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1803
    if (sym == @symbol(ENOLCK)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1804
	RETURN ( __MKSMALLINT(ENOLCK) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1805
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1806
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1807
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1808
#ifdef ENOSYS
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1809
    if (sym == @symbol(ENOSYS)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1810
	RETURN ( __MKSMALLINT(ENOSYS) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1811
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1812
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1813
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1814
#ifdef ENOTEMPTY
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1815
    if (sym == @symbol(ENOTEMPTY)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1816
	RETURN ( __MKSMALLINT(ENOTEMPTY) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1817
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1818
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1819
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1820
#ifdef EEXIST
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1821
    if (sym == @symbol(EEXIST)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1822
	RETURN ( __MKSMALLINT(EEXIST) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1823
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1824
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1825
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1826
#ifdef EILSEQ
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1827
    if (sym == @symbol(EILSEQ)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1828
	RETURN ( __MKSMALLINT(EILSEQ) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1829
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1830
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1831
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1832
    /*
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1833
     * XPG3 errnos - defined on most systems
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1834
     */
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1835
#ifdef ENOTBLK
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1836
    if (sym == @symbol(ENOTBLK)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1837
	RETURN ( __MKSMALLINT(ENOTBLK) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1838
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1839
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1840
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1841
#ifdef ETXTBSY
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1842
    if (sym == @symbol(ETXTBSY)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1843
	RETURN ( __MKSMALLINT(ETXTBSY) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1844
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1845
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1846
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1847
    /*
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1848
     * some others
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1849
     */
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1850
#ifdef EWOULDBLOCK
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1851
    if (sym == @symbol(EWOULDBLOCK)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1852
	RETURN ( __MKSMALLINT(EWOULDBLOCK) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1853
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1854
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1855
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1856
#ifdef ENOMSG
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1857
    if (sym == @symbol(ENOMSG)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1858
	RETURN ( __MKSMALLINT(ENOMSG) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1859
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1860
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1861
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1862
#ifdef ELOOP
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1863
    if (sym == @symbol(ELOOP)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1864
	RETURN ( __MKSMALLINT(ELOOP) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1865
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1866
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1867
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1868
    /*
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1869
     * some stream errors
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1870
     */
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1871
#ifdef ETIME
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1872
    if (sym == @symbol(ETIME)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1873
	RETURN ( __MKSMALLINT(ETIME) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1874
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1875
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1876
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1877
#ifdef ENOSR
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1878
    if (sym == @symbol(ENOSR)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1879
	RETURN ( __MKSMALLINT(ENOSR) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1880
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1881
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1882
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1883
#ifdef ENOSTR
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1884
    if (sym == @symbol(ENOSTR)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1885
	RETURN ( __MKSMALLINT(ENOSTR) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1886
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1887
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1888
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1889
#ifdef ECOMM
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1890
    if (sym == @symbol(ECOMM)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1891
	RETURN ( __MKSMALLINT(ECOMM) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1892
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1893
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1894
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1895
#ifdef EPROTO
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1896
    if (sym == @symbol(EPROTO)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1897
	RETURN ( __MKSMALLINT(EPROTO) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1898
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1899
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1900
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1901
    /*
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1902
     * nfs errors
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1903
     */
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1904
#ifdef ESTALE
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1905
    if (sym == @symbol(ESTALE)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1906
	RETURN ( __MKSMALLINT(ESTALE) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1907
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1908
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1909
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1910
#ifdef EREMOTE
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1911
    if (sym == @symbol(EREMOTE)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1912
	RETURN ( __MKSMALLINT(EREMOTE) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1913
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1914
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1915
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1916
    /*
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1917
     * some networking errors
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1918
     */
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1919
#ifdef EINPROGRESS
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1920
    if (sym == @symbol(EINPROGRESS)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1921
	RETURN ( __MKSMALLINT(EINPROGRESS) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1922
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1923
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1924
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1925
#ifdef EALREADY
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1926
    if (sym == @symbol(EALREADY)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1927
	RETURN ( __MKSMALLINT(EALREADY) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1928
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1929
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1930
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1931
#ifdef ENOTSOCK
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1932
    if (sym == @symbol(ENOTSOCK)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1933
	RETURN ( __MKSMALLINT(ENOTSOCK) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1934
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1935
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1936
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1937
#ifdef EDESTADDRREQ
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1938
    if (sym == @symbol(EDESTADDRREQ)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1939
	RETURN ( __MKSMALLINT(EDESTADDRREQ) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1940
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1941
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1942
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1943
#ifdef EMSGSIZE
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1944
    if (sym == @symbol(EMSGSIZE)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1945
	RETURN ( __MKSMALLINT(EMSGSIZE) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1946
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1947
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1948
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1949
#ifdef EPROTOTYPE
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1950
    if (sym == @symbol(EPROTOTYPE)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1951
	RETURN ( __MKSMALLINT(EPROTOTYPE) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1952
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1953
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1954
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1955
#ifdef ENOPROTOOPT
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1956
    if (sym == @symbol(ENOPROTOOPT)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1957
	RETURN ( __MKSMALLINT(ENOPROTOOPT) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1958
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1959
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1960
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1961
#ifdef EPROTONOSUPPORT
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1962
    if (sym == @symbol(EPROTONOSUPPORT)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1963
	RETURN ( __MKSMALLINT(EPROTONOSUPPORT) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1964
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1965
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1966
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1967
#ifdef ESOCKTNOSUPPORT
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1968
    if (sym == @symbol(ESOCKTNOSUPPORT)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1969
	RETURN ( __MKSMALLINT(ESOCKTNOSUPPORT) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1970
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1971
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1972
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1973
#ifdef EOPNOTSUPP
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1974
    if (sym == @symbol(EOPNOTSUPP)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1975
	RETURN ( __MKSMALLINT(EOPNOTSUPP) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1976
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1977
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1978
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1979
#ifdef EPFNOSUPPORT
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1980
    if (sym == @symbol(EPFNOSUPPORT)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1981
	RETURN ( __MKSMALLINT(EPFNOSUPPORT) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1982
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1983
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1984
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1985
#ifdef EAFNOSUPPORT
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1986
    if (sym == @symbol(EAFNOSUPPORT)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1987
	RETURN ( __MKSMALLINT(EAFNOSUPPORT) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1988
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1989
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1990
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1991
#ifdef EADDRINUSE
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1992
    if (sym == @symbol(EADDRINUSE)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1993
	RETURN ( __MKSMALLINT(EADDRINUSE) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1994
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1995
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1996
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1997
#ifdef EADDRNOTAVAIL
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  1998
    if (sym == @symbol(EADDRNOTAVAIL)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1999
	RETURN ( __MKSMALLINT(EADDRNOTAVAIL) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2000
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2001
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2002
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2003
#ifdef ETIMEDOUT
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2004
    if (sym == @symbol(ETIMEDOUT)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2005
	RETURN ( __MKSMALLINT(ETIMEDOUT) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2006
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2007
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2008
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2009
#ifdef ECONNREFUSED
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2010
    if (sym == @symbol(ECONNREFUSED)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2011
	RETURN ( __MKSMALLINT(ECONNREFUSED) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2012
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2013
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2014
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2015
#ifdef ENETDOWN
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2016
    if (sym == @symbol(ENETDOWN)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2017
	RETURN ( __MKSMALLINT(ENETDOWN) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2018
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2019
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2020
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2021
#ifdef ENETUNREACH
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2022
    if (sym == @symbol(ENETUNREACH)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2023
	RETURN ( __MKSMALLINT(ENETUNREACH) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2024
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2025
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2026
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2027
#ifdef ENETRESET
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2028
    if (sym == @symbol(ENETRESET)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2029
	RETURN ( __MKSMALLINT(ENETRESET) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2030
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2031
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2032
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2033
#ifdef ECONNABORTED
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2034
    if (sym == @symbol(ECONNABORTED)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2035
	RETURN ( __MKSMALLINT(ECONNABORTED) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2036
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2037
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2038
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2039
#ifdef ECONNRESET
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2040
    if (sym == @symbol(ECONNRESET)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2041
	RETURN ( __MKSMALLINT(ECONNRESET) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2042
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2043
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2044
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2045
#ifdef EISCONN
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2046
    if (sym == @symbol(EISCONN)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2047
	RETURN ( __MKSMALLINT(EISCONN) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2048
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2049
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2050
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2051
#ifdef ENOTCONN
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2052
    if (sym == @symbol(ENOTCONN)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2053
	RETURN ( __MKSMALLINT(ENOTCONN) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2054
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2055
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2056
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2057
#ifdef ESHUTDOWN
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2058
    if (sym == @symbol(ESHUTDOWN)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2059
	RETURN ( __MKSMALLINT(ESHUTDOWN) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2060
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2061
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2062
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2063
#ifdef EHOSTDOWN
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2064
    if (sym == @symbol(EHOSTDOWN)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2065
	RETURN ( __MKSMALLINT(EHOSTDOWN) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2066
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2067
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2068
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2069
#ifdef EHOSTUNREACH
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2070
    if (sym == @symbol(EHOSTUNREACH)) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2071
	RETURN ( __MKSMALLINT(EHOSTUNREACH) );
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2072
    }
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2073
#endif
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2074
%}.
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2075
    ^ -1
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2076
!
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2077
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2078
errorSymbolAndTextForNumber:errNr
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2079
    "return an array consisting of symbol &  message string from a unix errorNumber 
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2080
     (as returned by a system call). 
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2081
     The returned message is in english (as found in /usr/include/errno.h)
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2082
     and should be replaced by a resource lookup before being presented to the user."
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2083
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2084
    |sym text|
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2085
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2086
%{
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2087
    /* claus:
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2088
     * I made this some primitive code, since errnos are not
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2089
     * standard across unixes
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2090
     */
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2091
    char *msg = "unknown error";
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2092
    char buffer[50];
1119
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2093
    OBJ eno = errNr;
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2094
956d62a5656c compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents: 1104
diff changeset
  2095
    if (__isSmallInteger(eno)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  2096
	switch (__intVal(eno)) {
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2097
	    /*
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2098
	     * POSIX errnos - these should be defined
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2099
	     */
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2100
#ifdef EPERM
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2101
	    case EPERM:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2102
		msg = "Operation not permitted";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2103
		sym = @symbol(EPERM);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2104
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2105
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2106
#ifdef ENOENT
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2107
	    case ENOENT:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2108
		msg = "No such file or directory";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2109
		sym = @symbol(ENOENT);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2110
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2111
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2112
#ifdef ESRCH
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2113
	    case ESRCH:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2114
		msg = "No such process";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2115
		sym = @symbol(ESRCH);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2116
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2117
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2118
#ifdef EINTR
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2119
	    case EINTR:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2120
		msg = "Interrupted system call";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2121
		sym = @symbol(EINTR);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2122
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2123
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2124
#ifdef EIO
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2125
	    case EIO:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2126
		msg = "I/O error";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2127
		sym = @symbol(EIO);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2128
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2129
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2130
#ifdef ENXIO
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2131
	    case ENXIO:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2132
		msg = "No such device or address";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2133
		sym = @symbol(ENXIO);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2134
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2135
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2136
#ifdef E2BIG
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2137
	    case E2BIG:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2138
		msg = "Arg list too long";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2139
		sym = @symbol(E2BIG);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2140
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2141
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2142
#ifdef ENOEXEC
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2143
	    case ENOEXEC:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2144
		msg = "Exec format error";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2145
		sym = @symbol(ENOEXEC);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2146
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2147
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2148
#ifdef EBADF
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2149
	    case EBADF:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2150
		msg = "Bad file number";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2151
		sym = @symbol(EBADF);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2152
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2153
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2154
#ifdef ECHILD
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2155
	    case ECHILD:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2156
		msg = "No child processes";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2157
		sym = @symbol(ECHILD);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2158
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2159
#endif
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2160
#if !defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN)
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2161
	    case EAGAIN:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2162
		msg = "Try again";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2163
		sym = @symbol(EAGAIN);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2164
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2165
#endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2166
#ifdef ENOMEM
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2167
	    case ENOMEM:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2168
		msg = "Out of memory";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2169
		sym = @symbol(ENOMEM);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2170
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2171
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2172
#ifdef EACCES
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2173
	    case EACCES:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2174
		msg = "Permission denied";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2175
		sym = @symbol(EACCES);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2176
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2177
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2178
#ifdef EFAULT
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2179
	    case EFAULT:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2180
		msg = "Bad address";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2181
		sym = @symbol(EFAULT);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2182
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2183
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2184
#ifdef EBUSY
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2185
	    case EBUSY:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2186
		msg = "Device or resource busy";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2187
		sym = @symbol(EBUSY);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2188
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2189
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2190
#ifdef EEXIST
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2191
	    case EEXIST:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2192
		msg = "File exists";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2193
		sym = @symbol(EEXIST);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2194
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2195
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2196
#ifdef EXDEV
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2197
	    case EXDEV:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2198
		msg = "Cross-device link";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2199
		sym = @symbol(EXDEV);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2200
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2201
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2202
#ifdef ENODEV
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2203
	    case ENODEV:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2204
		msg = "No such device";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2205
		sym = @symbol(ENODEV);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2206
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2207
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2208
#ifdef ENOTDIR
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2209
	    case ENOTDIR:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2210
		msg = "Not a directory";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2211
		sym = @symbol(ENOTDIR);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2212
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2213
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2214
#ifdef EISDIR
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2215
	    case EISDIR:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2216
		msg = "Is a directory";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2217
		sym = @symbol(EISDIR);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2218
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2219
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2220
#ifdef EINVAL
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2221
	    case EINVAL:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2222
		msg = "Invalid argument";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2223
		sym = @symbol(EINVAL);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2224
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2225
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2226
#ifdef ENFILE
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2227
	    case ENFILE:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2228
		msg = "File table overflow";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2229
		sym = @symbol(ENFILE);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2230
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2231
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2232
#ifdef EMFILE
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2233
	    case EMFILE:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2234
		msg = "Too many open files";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2235
		sym = @symbol(EMFILE);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2236
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2237
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2238
#ifdef ENOTTY
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2239
	    case ENOTTY:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2240
		msg = "Not a typewriter";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2241
		sym = @symbol(ENOTTY);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2242
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2243
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2244
#ifdef EFBIG
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2245
	    case EFBIG:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2246
		msg = "File too large";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2247
		sym = @symbol(EFBIG);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2248
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2249
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2250
#ifdef ENOSPC
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2251
	    case ENOSPC:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2252
		msg = "No space left on device";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2253
		sym = @symbol(ENOSPC);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2254
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2255
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2256
#ifdef ESPIPE
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2257
	    case ESPIPE:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2258
		msg = "Illegal seek";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2259
		sym = @symbol(ESPIPE);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2260
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2261
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2262
#ifdef EROFS
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2263
	    case EROFS:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2264
		msg = "Read-only file system";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2265
		sym = @symbol(EROFS);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2266
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2267
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2268
#ifdef EMLINK
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2269
	    case EMLINK:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2270
		msg = "Too many links";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2271
		sym = @symbol(EMLINK);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2272
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2273
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2274
#ifdef EPIPE
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2275
	    case EPIPE:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2276
		msg = "Broken pipe";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2277
		sym = @symbol(EPIPE);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2278
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2279
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2280
#ifdef EDOM
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2281
	    case EDOM:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2282
		msg = "Math argument out of domain";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2283
		sym = @symbol(EDOM);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2284
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2285
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2286
#ifdef ERANGE
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2287
	    case ERANGE:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2288
		msg = "Math result not representable";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2289
		sym = @symbol(ERANGE);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2290
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2291
#endif
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2292
#ifdef EDEADLK
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  2293
# if EDEADLK != EWOULDBLOCK
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2294
	    case EDEADLK:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2295
		msg = "Resource deadlock would occur";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2296
		sym = @symbol(EDEADLK);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2297
		break;
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  2298
# endif
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2299
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2300
#ifdef ENAMETOOLONG
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2301
	    case ENAMETOOLONG:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2302
		msg = "File name too long";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2303
		sym = @symbol(ENAMETOOLONG);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2304
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2305
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2306
#ifdef ENOLCK
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2307
	    case ENOLCK:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2308
		msg = "No record locks available";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2309
		sym = @symbol(ENOLCK);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2310
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2311
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2312
#ifdef ENOSYS
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2313
	    case ENOSYS:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2314
		msg = "Function not implemented";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2315
		sym = @symbol(ENOSYS);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2316
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2317
#endif
359
claus
parents: 357
diff changeset
  2318
#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST)
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2319
	    case ENOTEMPTY:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2320
		msg = "Directory not empty";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2321
		sym = @symbol(ENOTEMPTY);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2322
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2323
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2324
#ifdef EILSEQ
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2325
	    case EILSEQ:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2326
		msg = "Illegal byte sequence";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2327
		sym = @symbol(EILSEQ);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2328
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2329
#endif
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2330
	    /*
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2331
	     * XPG3 errnos - defined on most systems
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2332
	     */
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2333
#ifdef ENOTBLK
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2334
	    case ENOTBLK:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2335
		msg = "Block device required";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2336
		sym = @symbol(ENOTBLK);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2337
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2338
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2339
#ifdef ETXTBSY
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2340
	    case ETXTBSY:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2341
		msg = "Text file busy";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2342
		sym = @symbol(ETXTBSY);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2343
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2344
#endif
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2345
	    /*
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2346
	     * some others
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2347
	     */
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2348
#ifdef EWOULDBLOCK
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2349
	    case EWOULDBLOCK:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2350
		msg = "Operation would block";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2351
		sym = @symbol(EWOULDBLOCK);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2352
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2353
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2354
#ifdef ENOMSG
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2355
	    case ENOMSG:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2356
		msg = "No message of desired type";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2357
		sym = @symbol(ENOMSG);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2358
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2359
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2360
#ifdef ELOOP
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2361
	    case ELOOP:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2362
		msg = "Too many levels of symbolic links";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2363
		sym = @symbol(ELOOP);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2364
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2365
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2366
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2367
	    /*
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2368
	     * some stream errors
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2369
	     */
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2370
#ifdef ETIME
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2371
	    case ETIME:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2372
		msg = "Timer expired";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2373
		sym = @symbol(ETIME);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2374
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2375
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2376
#ifdef ENOSR
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2377
	    case ENOSR:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2378
		msg = "Out of streams resources";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2379
		sym = @symbol(ENOSR);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2380
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2381
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2382
#ifdef ENOSTR
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2383
	    case ENOSTR:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2384
		msg = "Device not a stream";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2385
		sym = @symbol(ENOSTR);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2386
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2387
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2388
#ifdef ECOMM
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2389
	    case ECOMM:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2390
		msg = "Communication error on send";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2391
		sym = @symbol(ECOMM);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2392
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2393
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2394
#ifdef EPROTO
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2395
	    case EPROTO:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2396
		msg = "Protocol error";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2397
		sym = @symbol(EPROTO);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2398
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2399
#endif
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2400
	    /*
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2401
	     * nfs errors
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2402
	     */
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2403
#ifdef ESTALE
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2404
	    case ESTALE:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2405
		msg = "Stale NFS file handle";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2406
		sym = @symbol(ESTALE);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2407
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2408
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2409
#ifdef EREMOTE
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2410
	    case EREMOTE:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2411
		msg = "Too many levels of remote in path";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2412
		sym = @symbol(EREMOTE);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2413
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2414
#endif
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2415
	    /*
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2416
	     * some networking errors
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2417
	     */
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2418
#ifdef EINPROGRESS
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2419
	    case EINPROGRESS:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2420
		msg = "Operation now in progress";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2421
		sym = @symbol(EINPROGRESS);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2422
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2423
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2424
#ifdef EALREADY
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2425
	    case EALREADY:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2426
		msg = "Operation already in progress";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2427
		sym = @symbol(EALREADY);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2428
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2429
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2430
#ifdef ENOTSOCK
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2431
	    case ENOTSOCK:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2432
		msg = "Socket operation on non-socket";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2433
		sym = @symbol(ENOTSOCK);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2434
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2435
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2436
#ifdef EDESTADDRREQ
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2437
	    case EDESTADDRREQ:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2438
		msg = "Destination address required";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2439
		sym = @symbol(EDESTADDRREQ);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2440
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2441
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2442
#ifdef EMSGSIZE
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2443
	    case EMSGSIZE:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2444
		msg = "Message too long";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2445
		sym = @symbol(EMSGSIZE);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2446
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2447
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2448
#ifdef EPROTOTYPE
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2449
	    case EPROTOTYPE:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2450
		msg = "Protocol wrong type for socket";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2451
		sym = @symbol(EPROTOTYPE);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2452
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2453
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2454
#ifdef ENOPROTOOPT
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2455
	    case ENOPROTOOPT:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2456
		msg = "Protocol not available";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2457
		sym = @symbol(ENOPROTOOPT);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2458
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2459
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2460
#ifdef EPROTONOSUPPORT
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2461
	    case EPROTONOSUPPORT:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2462
		msg = "Protocol not supported";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2463
		sym = @symbol(EPROTONOSUPPORT);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2464
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2465
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2466
#ifdef ESOCKTNOSUPPORT
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2467
	    case ESOCKTNOSUPPORT:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2468
		msg = "Socket type not supported";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2469
		sym = @symbol(ESOCKTNOSUPPORT);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2470
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2471
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2472
#ifdef EOPNOTSUPP
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2473
	    case EOPNOTSUPP:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2474
		msg = "Operation not supported on socket";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2475
		sym = @symbol(EOPNOTSUPP);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2476
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2477
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2478
#ifdef EPFNOSUPPORT
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2479
	    case EPFNOSUPPORT:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2480
		msg = "Protocol family not supported";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2481
		sym = @symbol(EPFNOSUPPORT);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2482
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2483
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2484
#ifdef EAFNOSUPPORT
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2485
	    case EAFNOSUPPORT:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2486
		msg = "Address family not supported by protocol family";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2487
		sym = @symbol(EAFNOSUPPORT);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2488
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2489
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2490
#ifdef EADDRINUSE
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2491
	    case EADDRINUSE:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2492
		msg = "Address already in use";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2493
		sym = @symbol(EADDRINUSE);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2494
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2495
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2496
#ifdef EADDRNOTAVAIL
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2497
	    case EADDRNOTAVAIL:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2498
		msg = "Can\'t assign requested address";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2499
		sym = @symbol(EADDRNOTAVAIL);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2500
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2501
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2502
#ifdef ETIMEDOUT
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2503
	    case ETIMEDOUT:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2504
		msg = "Connection timed out";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2505
		sym = @symbol(ETIMEDOUT);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2506
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2507
#endif
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2508
#ifdef ECONNREFUSED
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2509
	    case ECONNREFUSED:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2510
		msg = "Connection refused";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2511
		sym = @symbol(ECONNREFUSED);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2512
		break;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2513
#endif
362
claus
parents: 359
diff changeset
  2514
#ifdef ENETDOWN
claus
parents: 359
diff changeset
  2515
	    case ENETDOWN:
claus
parents: 359
diff changeset
  2516
		msg = "Network is down";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2517
		sym = @symbol(ENETDOWN);
362
claus
parents: 359
diff changeset
  2518
		break;
claus
parents: 359
diff changeset
  2519
#endif
claus
parents: 359
diff changeset
  2520
#ifdef ENETUNREACH
claus
parents: 359
diff changeset
  2521
	    case ENETUNREACH:
claus
parents: 359
diff changeset
  2522
		msg = "Network is unreachable";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2523
		sym = @symbol(ENETUNREACH);
362
claus
parents: 359
diff changeset
  2524
		break;
claus
parents: 359
diff changeset
  2525
#endif
claus
parents: 359
diff changeset
  2526
#ifdef ENETRESET
claus
parents: 359
diff changeset
  2527
	    case ENETRESET:
claus
parents: 359
diff changeset
  2528
		msg = "Network dropped conn due to reset";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2529
		sym = @symbol(ENETRESET);
362
claus
parents: 359
diff changeset
  2530
		break;
claus
parents: 359
diff changeset
  2531
#endif
claus
parents: 359
diff changeset
  2532
#ifdef ECONNABORTED
claus
parents: 359
diff changeset
  2533
	    case ECONNABORTED:
claus
parents: 359
diff changeset
  2534
		msg = "Software caused connection abort";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2535
		sym = @symbol(ECONNABORTED);
362
claus
parents: 359
diff changeset
  2536
		break;
claus
parents: 359
diff changeset
  2537
#endif
claus
parents: 359
diff changeset
  2538
#ifdef ECONNRESET
claus
parents: 359
diff changeset
  2539
	    case ECONNRESET:
claus
parents: 359
diff changeset
  2540
		msg = "Connection reset by peer";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2541
		sym = @symbol(ECONNRESET);
362
claus
parents: 359
diff changeset
  2542
		break;
claus
parents: 359
diff changeset
  2543
#endif
claus
parents: 359
diff changeset
  2544
#ifdef EISCONN
claus
parents: 359
diff changeset
  2545
	    case EISCONN:
claus
parents: 359
diff changeset
  2546
		msg = "Socket is already connected";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2547
		sym = @symbol(EISCONN);
362
claus
parents: 359
diff changeset
  2548
		break;
claus
parents: 359
diff changeset
  2549
#endif
claus
parents: 359
diff changeset
  2550
#ifdef ENOTCONN
claus
parents: 359
diff changeset
  2551
	    case ENOTCONN:
claus
parents: 359
diff changeset
  2552
		msg = "Socket is not connected";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2553
		sym = @symbol(ENOTCONN);
362
claus
parents: 359
diff changeset
  2554
		break;
claus
parents: 359
diff changeset
  2555
#endif
claus
parents: 359
diff changeset
  2556
#ifdef ESHUTDOWN
claus
parents: 359
diff changeset
  2557
	    case ESHUTDOWN:
claus
parents: 359
diff changeset
  2558
		msg = "Can't send after socket shutdown";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2559
		sym = @symbol(ESHUTDOWN);
362
claus
parents: 359
diff changeset
  2560
		break;
claus
parents: 359
diff changeset
  2561
#endif
claus
parents: 359
diff changeset
  2562
#ifdef EHOSTDOWN
claus
parents: 359
diff changeset
  2563
	    case EHOSTDOWN:
claus
parents: 359
diff changeset
  2564
		msg = "Host is down";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2565
		sym = @symbol(EHOSTDOWN);
362
claus
parents: 359
diff changeset
  2566
		break;
claus
parents: 359
diff changeset
  2567
#endif
claus
parents: 359
diff changeset
  2568
#ifdef EHOSTUNREACH
claus
parents: 359
diff changeset
  2569
	    case EHOSTUNREACH:
claus
parents: 359
diff changeset
  2570
		msg = "No route to host";
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2571
		sym = @symbol(EHOSTUNREACH);
362
claus
parents: 359
diff changeset
  2572
		break;
claus
parents: 359
diff changeset
  2573
#endif
claus
parents: 359
diff changeset
  2574
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2575
	    default:
368
a3c21a89ec37 *** empty log message ***
claus
parents: 362
diff changeset
  2576
		{
809
5eef87c2907b e convenient macro for register saving (sparc only)
Claus Gittinger <cg@exept.de>
parents: 805
diff changeset
  2577
		    __BEGIN_PROTECT_REGISTERS__
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  2578
		    sprintf(buffer, "ErrorNr: %d", __intVal(eno));
809
5eef87c2907b e convenient macro for register saving (sparc only)
Claus Gittinger <cg@exept.de>
parents: 805
diff changeset
  2579
		    __END_PROTECT_REGISTERS__
368
a3c21a89ec37 *** empty log message ***
claus
parents: 362
diff changeset
  2580
		}
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2581
		msg = buffer;
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2582
		break;
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  2583
	}
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  2584
    }
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2585
    text = __MKSTRING(msg);
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2586
%}.
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2587
    ^ Array with:sym with:text
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2588
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2589
    "
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2590
     OperatingSystem errorSymbolAndTextForNumber:4
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2591
    "
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2592
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2593
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2594
errorSymbolForNumber:errNr
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2595
    "return a symbol for a unix errorNumber
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2596
     (as returned by a system call)."
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2597
1153
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  2598
    ^ (self errorSymbolAndTextForNumber:errNr) at:1
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2599
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2600
    "
1666
4797ec69fc53 comment
Claus Gittinger <cg@exept.de>
parents: 1654
diff changeset
  2601
     OperatingSystem errorSymbolForNumber:4
4797ec69fc53 comment
Claus Gittinger <cg@exept.de>
parents: 1654
diff changeset
  2602
     OperatingSystem errorSymbolForNumber:2
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2603
    "
1153
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  2604
8119975c55ce Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents: 1142
diff changeset
  2605
    "Modified: 12.4.1996 / 09:16:29 / stefan"
1666
4797ec69fc53 comment
Claus Gittinger <cg@exept.de>
parents: 1654
diff changeset
  2606
    "Modified: 13.9.1996 / 16:23:35 / cg"
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2607
!
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2608
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2609
errorTextForNumber:errNr
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2610
    "return a message string from a unix errorNumber 
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2611
     (as returned by a system call). 
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2612
     The returned message is in english (as found in /usr/include/errno.h)
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2613
     and should be replaced by a resource lookup before being presented to the user."
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2614
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2615
    ^ (self errorSymbolAndTextForNumber:errNr) at:2
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2616
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2617
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2618
     OperatingSystem errorTextForNumber:4
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2619
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2620
!
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2621
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2622
lastErrorNumber
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2623
    "return the last errors number.
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2624
     See also: #lastErrorSymbol and #lastErrorString.
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2625
     Notice: having a single error number is a bad idea in a multithreaded
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2626
	     environment - this interface will change."
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2627
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2628
    ^ LastErrorNumber
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2629
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2630
     "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2631
      OperatingSystem lastErrorNumber
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2632
     "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2633
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2634
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2635
lastErrorString
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2636
    "return a message string describing the last error.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2637
     See also: #lastErrorNumber and #lastErrorSymbol.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2638
     Notice: having a single error number is a bad idea in a multithreaded
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2639
	     environment - this interface will change."
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2640
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2641
    ^ self errorTextForNumber:LastErrorNumber
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2642
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2643
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2644
     OperatingSystem lastErrorString
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2645
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2646
!
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  2647
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2648
lastErrorSymbol
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2649
    "return a symbol (such as #EBADF or #EACCESS) describing the last error.
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2650
     See also: #lastErrorNumber and #lastErrorString.
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2651
     Notice: having a single error number is a bad idea in a multithreaded
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2652
	     environment - this interface will change."
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2653
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2654
    ^ self errorSymbolForNumber:LastErrorNumber
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2655
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2656
    "
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2657
     OperatingSystem lastErrorSymbol
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2658
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2659
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2660
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  2661
!OperatingSystem class methodsFor:'executing OS commands'!
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2662
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2663
canExecuteCommand:aCommandString
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2664
    "return true, if the OS can execute aCommand."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2665
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2666
    |cmd|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2667
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2668
    cmd := aCommandString asCollectionOfWords first.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2669
    ^ (self pathOfCommand:cmd) notNil
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2670
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2671
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2672
     OperatingSystem canExecuteCommand:'fooBar'  
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2673
     OperatingSystem canExecuteCommand:'ls'  
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2674
     OperatingSystem canExecuteCommand:'cvs'  
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2675
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2676
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2677
    "Created: 4.11.1995 / 19:13:54 / cg"
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  2678
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  2679
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2680
exec:aPath withArguments:argArray
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2681
    "execute the unix command specified by the argument, aPath, with
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2682
     arguments in argArray (no arguments, if nil).
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2683
     If successful, this method does NOT return and smalltalk is gone.
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2684
     If not successful, false is returned. Can be used with fork or to transfer
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2685
     to another program."
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2686
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  2687
    ^ self exec:aPath withArguments:argArray fork:false
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2688
!
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2689
1280
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  2690
exec:aPath withArguments:argArray fileDescriptors:fdArray closeDescriptors:closeFdArray fork:doFork newPgrp:newPgrp
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2691
    "Internal combined fork & exec;
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2692
     If fork is false:
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2693
	 execute the unix command specified by the argument, aPath, with
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2694
	 arguments in argArray (no arguments, if nil).
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2695
	 If successful, this method does not return and smalltalk is gone.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2696
	 If not successful, false is returned. Normal use is with forkForCommand.
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2697
     if its true:
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2698
	for a child to do the above.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2699
	The id of the child process is returned; -1 if fork failed.
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2700
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2701
     fdArray contains the filedescriptors, to be used for the child (if fork is true).
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2702
	fdArray[1] = 15 -> use fd 15 as stdin.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2703
	If an element of the array is set to nil, the corresponding filedescriptor
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2704
	will be closed for the child.
1062
baa5827a7a40 Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents: 1060
diff changeset
  2705
baa5827a7a40 Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents: 1060
diff changeset
  2706
     closeFdArray contains descriptors that will be closed in the subprocess.
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2707
1280
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  2708
     If newPgrp is true, the subprocess will be established in a new process group.
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2709
	Ths processgroup will be equal to id.
1280
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  2710
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2711
    Notice: this used to be two separate ST-methods; however, in order to use
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2712
	    vfork on some machines, it had to be merged into one, to avoid write
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2713
	    accesses to ST/X memory from the vforked-child. The code below only does
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2714
	    read accesses."
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2715
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2716
%{
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2717
#ifndef MSDOS_LIKE
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2718
    char **argv;
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2719
    int nargs, i, id;
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2720
    OBJ arg;
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2721
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2722
    if (__isString(aPath) && 
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2723
	((argArray == nil) || __isArray(argArray)) &&
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2724
	((fdArray == nil) || __isArray(fdArray)) &&
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2725
	((closeFdArray == nil) || __isArray(closeFdArray))
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2726
    ) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2727
	nargs = argArray == nil ? 0 : _arraySize(argArray);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2728
	argv = (char **) malloc(sizeof(char *) * (nargs + 1));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2729
	if (argv) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2730
	    for (i=0; i < nargs; i++) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2731
		arg = __ArrayInstPtr(argArray)->a_element[i];
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2732
		if (__isString(arg)) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2733
		    argv[i] = (char *) __stringVal(arg);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2734
		} else {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2735
		    argv[i] = "";
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2736
		}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2737
	    }
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2738
	    argv[i] = NULL;
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2739
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2740
	    if (doFork == true) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2741
		int nfd, nclose;
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2742
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2743
		nfd = fdArray == nil ? 0 : _arraySize(fdArray);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2744
		nclose = closeFdArray == nil ? 0 : _arraySize(closeFdArray);
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2745
#ifdef HAS_VFORK
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2746
		id = vfork();
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2747
#else
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2748
		id = fork();
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2749
#endif
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2750
		if (id == 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2751
		    /*
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2752
		    ** In child.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2753
		    ** first: dup filedescriptors
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2754
		    */
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2755
		    for (i = 0; i < nfd; i++) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2756
			if (__isSmallInteger(__ArrayInstPtr(fdArray)->a_element[i]) &&
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2757
			    __intVal(__ArrayInstPtr(fdArray)->a_element[i]) != i
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2758
			) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2759
			    dup2(__intVal(__ArrayInstPtr(fdArray)->a_element[i]), i);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2760
			}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2761
		    }
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2762
		    /*
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2763
		    ** second: close unused filedescriptors
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2764
		    */
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2765
		    for (i = 0; i < nfd; i++) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2766
			if (__ArrayInstPtr(fdArray)->a_element[i] == nil) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2767
			    close(i);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2768
			}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2769
		    }
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2770
		    /*
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2771
		    ** third: close filedescriptors
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2772
		    */
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2773
		    for (i = 0; i < nclose; i++) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2774
			if (__isSmallInteger(__ArrayInstPtr(closeFdArray)->a_element[i])) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2775
			    close(__intVal(__ArrayInstPtr(closeFdArray)->a_element[i]));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2776
			}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2777
		    }
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2778
		    if (newPgrp == true) {
1280
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  2779
#if defined(_POSIX_JOB_CONTROL)
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2780
			(void) setpgid(0, 0);
1280
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  2781
#else
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  2782
#if defined(BSD)
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2783
			(void) setpgrp(0);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2784
#endif
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2785
#endif
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2786
		    }
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2787
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2788
		    execv(__stringVal(aPath), argv);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2789
		    /* should not be reached */
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2790
		    _exit(127);                 /* POSIX 2 compatible exit value */
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2791
		}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2792
		/*
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2793
		** In parent: succes or failure
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2794
		*/
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2795
		free(argv);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2796
		RETURN (__MKSMALLINT(id));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2797
	    } else {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2798
		execv(__stringVal(aPath), argv);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2799
		/* 
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2800
		 * should not be reached
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2801
		 * (well, it is, if you pass a wrong command-path)
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2802
		 */
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2803
		free(argv);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2804
		RETURN ( false );
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2805
	    }
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2806
	}
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2807
    }
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2808
#endif
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2809
%}.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2810
    "
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2811
     path-argument not string
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2812
     or argArray not an array/nil
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2813
     or malloc failed
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2814
     or not supported by OS
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2815
    "
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2816
    ^ self primitiveFailed
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2817
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2818
    "
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2819
     |id|
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2820
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2821
     id := OperatingSystem fork.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2822
     id == 0 ifTrue:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2823
	"I am the child"
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2824
	OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp').
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2825
	"not reached"
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2826
     ]
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2827
    "
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2828
    "
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2829
     |id|
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2830
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2831
     id := OperatingSystem fork.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2832
     id == 0 ifTrue:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2833
	"I am the child"
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2834
	OperatingSystem exec:'/bin/sh' withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2').
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2835
	"not reached"
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2836
     ].
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2837
     id printNL.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2838
     (Delay forSeconds:3.5) wait.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2839
     'killing ...' printNL.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2840
     OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2841
     OperatingSystem sendSignal:(OperatingSystem sigKILL) to:id
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2842
    "
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2843
!
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2844
1076
0bfb3317718b backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents: 1062
diff changeset
  2845
exec:aPath withArguments:argArray fileDescriptors:fdArray fork:doFork
0bfb3317718b backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents: 1062
diff changeset
  2846
    "Internal combined fork & exec;
0bfb3317718b backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents: 1062
diff changeset
  2847
     If fork is false:
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2848
	 execute the unix command specified by the argument, aPath, with
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2849
	 arguments in argArray (no arguments, if nil).
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2850
	 If successful, this method does not return and smalltalk is gone.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2851
	 If not successful, false is returned. Normal use is with forkForCommand.
1076
0bfb3317718b backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents: 1062
diff changeset
  2852
     if its true:
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2853
	for a child to do the above.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2854
	The id of the child process is returned; -1 if fork failed.
1076
0bfb3317718b backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents: 1062
diff changeset
  2855
0bfb3317718b backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents: 1062
diff changeset
  2856
     fdArray contains the filedescriptors, to be used for the child (if fork is true).
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2857
	fdArray[1] = 15 -> use fd 15 as stdin.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2858
	If an element of the array is set to nil, the corresponding filedescriptor
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2859
	will be closed for the child.
1076
0bfb3317718b backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents: 1062
diff changeset
  2860
0bfb3317718b backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents: 1062
diff changeset
  2861
    Notice: this used to be two separate ST-methods; however, in order to use
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2862
	    vfork on some machines, it had to be merged into one, to avoid write
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2863
	    accesses to ST/X memory from the vforked-child. The code below only does
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  2864
	    read accesses."
1076
0bfb3317718b backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents: 1062
diff changeset
  2865
1280
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  2866
    ^ self exec:aPath withArguments:argArray fileDescriptors:fdArray closeDescriptors:nil fork:doFork newPgrp:false
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  2867
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  2868
    "Modified: 23.4.1996 / 17:05:41 / stefan"
1076
0bfb3317718b backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents: 1062
diff changeset
  2869
!
0bfb3317718b backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents: 1062
diff changeset
  2870
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2871
exec:aPath withArguments:argArray fork:doFork
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2872
    "Internal combined fork & exec;
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2873
     If fork is false:
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  2874
	 execute the unix command specified by the argument, aPath, with
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  2875
	 arguments in argArray (no arguments, if nil).
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  2876
	 If successful, this method does not return and smalltalk is gone.
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  2877
	 If not successful, false is returned. Normal use is with forkForCommand.
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2878
     if its true:
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2879
	for a child to do the above.
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2880
	The id of the child process is returned; -1 if fork failed.
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2881
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2882
    Notice: this used to be two separate ST-methods; however, in order to use
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  2883
	    vfork on some machines, it had to be merged into one, to avoid write
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2884
	    accesses to ST/X memory from the vforked-child. The code below only does
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2885
	    read accesses."
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2886
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2887
%{
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  2888
#ifndef MSDOS_LIKE
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2889
    char **argv;
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2890
    int nargs, i, id;
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2891
    OBJ arg;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2892
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2893
    if (__isString(aPath) && ((argArray == nil) || __isArray(argArray))) {
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2894
	nargs = argArray == nil ? 0 : _arraySize(argArray);
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2895
	argv = (char **) malloc(sizeof(char *) * (nargs + 1));
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2896
	if (argv) {
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2897
	    for (i=0; i < nargs; i++) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  2898
		arg = __ArrayInstPtr(argArray)->a_element[i];
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2899
		if (__isString(arg)) {
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2900
		    argv[i] = (char *) __stringVal(arg);
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2901
		} else {
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2902
		    argv[i] = "";
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2903
		}
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2904
	    }
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2905
	    argv[i] = NULL;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2906
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2907
	    if (doFork == true) {
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2908
#ifdef HAS_VFORK
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2909
		id = vfork();
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2910
#else
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2911
		id = fork();
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2912
#endif
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2913
		if (id == 0) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  2914
		    execv(__stringVal(aPath), argv);
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2915
		    /* should not be reached */
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2916
		    _exit(127);         /* POSIX-2 compatible exit value */
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2917
		}
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2918
		free(argv);
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2919
		RETURN (__MKSMALLINT(id));
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2920
	    } else {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  2921
		execv(__stringVal(aPath), argv);
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  2922
		/* 
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  2923
		 * should not be reached
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  2924
		 * (well, it is, if you pass a wrong command-path)
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  2925
		 */
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  2926
		free(argv);
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  2927
		RETURN ( false );
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2928
	    }
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2929
	}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2930
    }
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  2931
#endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2932
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2933
    "
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  2934
     path-argument not string
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  2935
     or argArray not an array/nil
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  2936
     or malloc failed
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  2937
     or not supported by OS
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2938
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2939
    ^ self primitiveFailed
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2940
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2941
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2942
     |id|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2943
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2944
     id := OperatingSystem fork.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2945
     id == 0 ifTrue:[
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2946
	"I am the child"
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2947
	OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp').
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2948
	"not reached"
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2949
     ]
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2950
    "
670
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
  2951
    "
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
  2952
     |id|
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
  2953
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  2954
     id := OperatingSystem fork.
670
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
  2955
     id == 0 ifTrue:[
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2956
	"I am the child"
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2957
	OperatingSystem exec:'/bin/sh' withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2').
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  2958
	"not reached"
670
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
  2959
     ].
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
  2960
     id printNL.
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
  2961
     (Delay forSeconds:3.5) wait.
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
  2962
     'killing ...' printNL.
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
  2963
     OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id.
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
  2964
     OperatingSystem sendSignal:(OperatingSystem sigKILL) to:id
4d6d0c031711 startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
  2965
    "
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2966
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2967
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2968
executeCommand:aCommandString
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  2969
    "execute the unix command specified by the argument, aCommandString.
676
4aa4417c103c commentary
Claus Gittinger <cg@exept.de>
parents: 675
diff changeset
  2970
     The commandString is passed to a shell for execution - see the description of
4aa4417c103c commentary
Claus Gittinger <cg@exept.de>
parents: 675
diff changeset
  2971
     'sh -c' in your UNIX manual.
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2972
     Return true if successful, false otherwise."
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2973
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  2974
     ^ self executeCommand:aCommandString onError:[:status| false]
2080
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2975
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2976
"/Old code:
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2977
"/
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2978
"/%{ 
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2979
"/    int status;
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2980
"/
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2981
"/    if (__isString(aCommandString)) {
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2982
"/        /*
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2983
"/         * ST/X provides a modified (fixed) implementation of the
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2984
"/         * system() libc-function, which is interruptable ...
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2985
"/         */
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2986
"/# ifdef WANT_SYSTEM
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2987
"/        status = mySystem((char *) __stringVal(aCommandString));
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2988
"/# else
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2989
"/        status = system((char *) __stringVal(aCommandString));
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2990
"/# endif
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2991
"/        OperatingSystem_LastExecStatus = __MKSMALLINT(status);
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2992
"/        if (status == 0) {
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2993
"/            RETURN ( true );
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2994
"/        }
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2995
"/        OperatingSystem_LastErrorNumber = __MKSMALLINT(errno);
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2996
"/        RETURN ( false );
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2997
"/    }
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2998
"/%}.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  2999
"/    "/
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  3000
"/    "/ invalid argument (non-string)
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  3001
"/    "/
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  3002
"/    ^ self primitiveFailed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3003
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3004
    "
805
850571f0255f WANT_SYSTEM for unixware.
Stefan Vogel <sv@exept.de>
parents: 803
diff changeset
  3005
     OperatingSystem executeCommand:'sleep 30'. 
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3006
     OperatingSystem executeCommand:'pwd'. 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3007
     OperatingSystem executeCommand:'ls -l'. 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3008
     OperatingSystem executeCommand:'invalidCommand'. 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3009
     OperatingSystem executeCommand:'rm /tmp/foofoofoofoo'. 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3010
    "
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3011
2080
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  3012
    "Modified: 7.1.1997 / 19:29:55 / stefan"
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3013
!
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3014
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3015
executeCommand:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream errorTo:anExternalErrStream onError:aBlock
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3016
    "execute the unix command specified by the argument, aCommandString.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3017
     The commandString is passed to a shell for execution - see the description of
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3018
     'sh -c' in your UNIX manual.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3019
     Return true if successful.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3020
     If not successfull, aBlock is called with a Dictionary containing the exit status
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3021
     as argument."
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3022
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3023
    |pid exitStatus sema|
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3024
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3025
    sema := Semaphore new.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3026
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3027
    [
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3028
	pid := self 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3029
		startProcess:aCommandString
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3030
		inputFrom:anExternalInStream 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3031
		outputTo:anExternalOutStream 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3032
		errorTo:anExternalErrStream.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3033
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3034
	pid > 0 ifTrue:[
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3035
	    Processor monitorPid:pid action:[:status |
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3036
		status stillAlive ifFalse:[
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3037
		    exitStatus := status.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3038
		    sema signal
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3039
		].
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3040
	    ].
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3041
	    sema wait.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3042
	] ifFalse:[
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3043
	    exitStatus := OSProcessStatus processCreationFailure.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3044
	].
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3045
    ] valueUninterruptably.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3046
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3047
    exitStatus success ifFalse:[
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3048
	^ aBlock value:exitStatus
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3049
    ].
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3050
    ^ true.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3051
!
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3052
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3053
executeCommand:aCommandString onError:aBlock
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3054
    "execute the unix command specified by the argument, aCommandString.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3055
     The commandString is passed to a shell for execution - see the description of
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3056
     'sh -c' in your UNIX manual.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3057
     Return true if successful.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3058
     If not successfull, aBlock is called with a Dictionary containing the exit status
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3059
     as argument."
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3060
1034
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3061
    |pid exitStatus sema|
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3062
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3063
    sema := Semaphore new.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3064
1034
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3065
    [
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3066
	pid := self startProcess:aCommandString.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3067
	pid > 0 ifTrue:[
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3068
	    Processor monitorPid:pid action:[:status |
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3069
		status stillAlive ifFalse:[
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3070
		    exitStatus := status.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3071
		    sema signal
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3072
		].
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3073
	    ].
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3074
	    sema wait.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3075
	] ifFalse:[
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3076
	    exitStatus := OSProcessStatus processCreationFailure.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3077
	].
1034
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3078
    ] valueUninterruptably.
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3079
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3080
    exitStatus success ifFalse:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3081
	^ aBlock value:exitStatus
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3082
    ].
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3083
    ^ true.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3084
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3085
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3086
    "
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3087
     OperatingSystem executeCommand:'sleep 30' onError:[]. 
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3088
     OperatingSystem executeCommand:'pwd' onError:[:status|status inspect]. 
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3089
     OperatingSystem executeCommand:'ls -l' onError:[]. 
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3090
     OperatingSystem executeCommand:'invalidCommand' onError:[:status| status inspect]. 
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3091
     OperatingSystem executeCommand:'rm /tmp/foofoofoofoo'onError:[:status | status inspect]. 
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3092
    "
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3093
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3094
    "Created: 22.12.1995 / 14:49:59 / stefan"
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  3095
    "Modified: 28.12.1995 / 15:25:48 / stefan"
1034
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3096
    "Modified: 28.2.1996 / 21:41:23 / cg"
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3097
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3098
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3099
fork
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3100
    "fork a new (HEAVY-weight) unix process.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3101
     Dont confuse this with Block>>fork, which creates 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3102
     lightweight smalltalk processes. This method will return
676
4aa4417c103c commentary
Claus Gittinger <cg@exept.de>
parents: 675
diff changeset
  3103
     0 to the child process, and a non-zero number (which is the childs
4aa4417c103c commentary
Claus Gittinger <cg@exept.de>
parents: 675
diff changeset
  3104
     unix-process-id) to the parent (original) process.
764
eadba1b6a721 vfork interface (for poor BSD ultrix) - without it, it takes 20 seconds
Claus Gittinger <cg@exept.de>
parents: 763
diff changeset
  3105
676
4aa4417c103c commentary
Claus Gittinger <cg@exept.de>
parents: 675
diff changeset
  3106
     In normal situations, you dont need to use this low level entry; see
771
1ad3f852e201 merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents: 766
diff changeset
  3107
     #startProcess: and #executCommand: for higher level interfaces."
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  3108
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  3109
%{  /* NOCONTEXT */
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  3110
#ifndef MSDOS_LIKE
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3111
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3112
    int pid;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3113
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3114
    pid = fork();
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  3115
    RETURN ( __MKSMALLINT(pid) );
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  3116
#endif
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  3117
%}.
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  3118
    "/
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  3119
    "/ not supported by OS
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  3120
    "/
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  3121
    ^ self primitiveFailed
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  3122
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3123
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3124
     |id|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3125
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3126
     id := OperatingSystem fork.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3127
     id == 0 ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3128
	OperatingSystem exit
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3129
     ]
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3130
    "
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  3131
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  3132
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3133
getStatusOfProcess:aProcessId
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3134
    "wait for a process to terminate and fetch its exit status.
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3135
     This is required to avoid zombie processes."
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3136
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3137
%{
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3138
#ifndef MSDOS_LIKE
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3139
    int status;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3140
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3141
    if (__isSmallInteger(aProcessId)) {
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3142
	pid_t pid = (pid_t)(__intVal(aProcessId));
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3143
	{
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3144
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3145
# ifdef  NO_WAITPID
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3146
	    pid_t child;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3147
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3148
	    do {
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3149
		__BEGIN_INTERRUPTABLE__
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3150
		child = __wait (&status);
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3151
		__END_INTERRUPTABLE__
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3152
		if (child < 0 && errno != EINTR) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  3153
		    fprintf(stderr, "OS: child-wait errno=%d\n", errno);
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3154
		    status = -1;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3155
		    break;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3156
		}
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3157
	    } while (child != pid);
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3158
# else
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3159
	    pid_t child;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3160
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3161
	    /* claus: the original did not care for EINTR here ... */
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3162
	    do {
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3163
		__BEGIN_INTERRUPTABLE__
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3164
		child = __waitpid (pid, &status, 0);
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3165
		__END_INTERRUPTABLE__
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3166
	    } while ((child != pid) && (errno == EINTR));
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3167
	    if (child != pid) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  3168
		fprintf(stderr, "OS: child-waitpid errno=%d\n", errno);
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3169
		status = -1;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3170
	    }
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3171
# endif /* NO_WAITPID */
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3172
	}
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3173
	RETURN ( __MKSMALLINT(status));
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3174
    }
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3175
#endif
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3176
%}.
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3177
    self primitiveFailed
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  3178
1034
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3179
!
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3180
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3181
pathOfCommand:aCommand
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3182
    "find where aCommand's executable file is"
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3183
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3184
    |path f|
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3185
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3186
    path := self getEnvironment:'PATH'.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3187
    path notNil ifTrue:[
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3188
	(path asCollectionOfSubstringsSeparatedBy:$:) do:[:path |
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3189
	    (f := (path asFilename construct:aCommand)) isExecutable ifTrue:[
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3190
		^  f pathName
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3191
	    ]
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3192
	].
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3193
    ].
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3194
    ^ nil
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3195
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3196
    "
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3197
     OperatingSystem pathOfCommand:'fooBar'  
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3198
     OperatingSystem pathOfCommand:'ls'  
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3199
     OperatingSystem pathOfCommand:'cvs'  
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3200
    "
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3201
!
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3202
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3203
startProcess:aCommandString
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3204
    "start executing the unix command as specified by the argument, aCommandString
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3205
     as a separate process; do not wait for the command to finish.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3206
     The commandString is passed to a shell for execution - see the description of
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3207
     'sh -c' in your UNIX manual.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3208
     Return the processId if successful, nil otherwise.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3209
     Use #waitForProcess: for synchronization and exec status return,
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3210
     or #killProcess: to stop it."
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3211
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3212
    ^ self 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3213
	exec:'/bin/sh' 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3214
	withArguments:(Array with:'sh' with:'-c' with:aCommandString)
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3215
	fork:true.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3216
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3217
    "
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3218
     |pid|
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3219
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3220
     pid := OperatingSystem startProcess:'sleep 2; echo 1; sleep 2; echo 2'.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3221
     (Delay forSeconds:3) wait.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3222
     OperatingSystem killProcess:pid.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  3223
    "
1045
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3224
!
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3225
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3226
startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream errorTo:anExternalErrStream
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3227
    "start executing the unix command as specified by the argument, aCommandString
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3228
     as a separate process; do not wait for the command to finish.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3229
     The commandString is passed to a shell for execution - see the description of
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3230
     'sh -c' in your UNIX manual.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3231
     The command gets stdIn, stdOut and stdErr assigned from the arguments;
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3232
     each may be nil.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3233
     Return the processId if successful, nil otherwise.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3234
     Use #monitorPid:action: for synchronization and exec status return,
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3235
     or #killProcess: to stop it."
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3236
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3237
    |in out err|
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3238
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3239
    anExternalInStream notNil ifTrue:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3240
	in := anExternalInStream fileDescriptor.
1046
7b50e6c3147f nil input -> /dev/null
ca
parents: 1045
diff changeset
  3241
    ] ifFalse:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3242
	in := '/dev/null' asFilename readStream fileDescriptor
1045
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3243
    ].
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3244
    anExternalOutStream notNil ifTrue:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3245
	out := anExternalOutStream fileDescriptor.
1045
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3246
    ].
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3247
    anExternalErrStream notNil ifTrue:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3248
	err := anExternalErrStream fileDescriptor.
1045
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3249
    ].
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3250
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3251
    ^ self 
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3252
	exec:'/bin/sh' 
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3253
	withArguments:(Array with:'sh' with:'-c' with:aCommandString)
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3254
	fileDescriptors:(Array with:in with:out with:err)
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3255
	fork:true.
1045
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3256
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3257
    "blocking at current prio (i.e. only higher prio threads execute):
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3258
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3259
     OperatingSystem executeCommand:'ls -l > out'.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3260
    "
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3261
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3262
    "non-blocking (lower prio threads continue):
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3263
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3264
     |in out err pid sema|
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3265
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3266
     in := 'out' asFilename readStream.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3267
     out := 'out2' asFilename writeStream.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3268
     err := 'err' asFilename writeStream.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3269
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3270
     sema := Semaphore new.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3271
     pid := OperatingSystem startProcess:'sleep 10; grep drw' inputFrom:in outputTo:out errorTo:err.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3272
     pid notNil ifTrue:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3273
	 Processor monitorPid:pid action:[:OSstatus | sema signal ].
1045
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3274
     ].
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3275
     in close.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3276
     out close.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3277
     err close.
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3278
     sema wait.
1422
9a0b792f2953 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  3279
     Transcript showCR:'finished'
1045
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3280
    "
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3281
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3282
    "Created: 29.2.1996 / 12:31:29 / cg"
c7a38395a1d4 added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents: 1040
diff changeset
  3283
    "Modified: 29.2.1996 / 12:49:14 / cg"
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3284
! !
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3285
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  3286
!OperatingSystem class methodsFor:'file access'!
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3287
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3288
closeFd:anInteger
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3289
    "low level close of a filedescriptor"
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3290
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3291
%{
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3292
#if !defined(transputer) && !defined(MSDOS_LIKE)
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3293
     if (__isSmallInteger(anInteger)) {
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3294
	close(__intVal(anInteger));
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3295
	RETURN(self);
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3296
     }
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3297
#endif
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3298
%}.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3299
     ^ self primitiveFailed.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3300
!
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3301
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3302
createDirectory:newPathName
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3303
    "create a new directory with name 'newPathName'.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3304
     Return true if successful, false if failed.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3305
     This is a low-level entry - use Filename protocol for compatibility."
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3306
1497
92f5370f3942 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  3307
    "/ if it already exists this is ok
92f5370f3942 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  3308
92f5370f3942 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  3309
    (self isDirectory:newPathName) ifTrue:[^ true].
92f5370f3942 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  3310
92f5370f3942 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  3311
    "/ since createDirectory is not used too often,
92f5370f3942 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  3312
    "/  you'll forgive me using mkdir ...
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3313
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3314
    ^ self executeCommand:('mkdir 2>/dev/null ', newPathName)
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3315
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3316
    "
1497
92f5370f3942 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  3317
     OperatingSystem createDirectory:'foo'  
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3318
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3319
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3320
    "Modified: 20.12.1995 / 11:24:13 / stefan"
1497
92f5370f3942 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  3321
    "Modified: 29.6.1996 / 14:06:54 / cg"
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3322
!
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3323
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3324
linkFile:oldPath to:newPath
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3325
    "link the file 'oldPath' to 'newPath'. The link will be a hard link.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3326
     Return true if successful, false if not."
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3327
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  3328
%{
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3329
#ifndef MSDOS_LIKE
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3330
    int ret;
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3331
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3332
    if (__isString(oldPath) && __isString(newPath)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3333
	__BEGIN_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3334
	do {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3335
	    ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3336
	} while (ret < 0 && errno == EINTR);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3337
	__END_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3338
	if (ret < 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3339
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3340
	    RETURN ( false );
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3341
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3342
	RETURN (true);
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3343
    }
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3344
#endif
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3345
%}.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3346
    ^ self primitiveFailed
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3347
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3348
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3349
     OperatingSystem linkFile:'foo' to:'bar'
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3350
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3351
!
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3352
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3353
makePipe
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3354
    "make a pipe, return array with two filedescriptors on success,
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3355
     nil on failure.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3356
     This is a lowLevel entry, not for public use.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3357
     See ExternalStream>>makePipe for a more user-friendly, public interface."
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3358
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3359
    |fd1 fd2|    
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3360
                
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3361
%{       
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  3362
#ifdef UNIX_LIKE
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3363
     int fds[2];
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3364
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3365
     if (pipe(fds) < 0) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3366
	@global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3367
	RETURN ( nil );
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3368
     }
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3369
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3370
     fd1 = __MKSMALLINT(fds[0]);
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3371
     fd2 = __MKSMALLINT(fds[1]);
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  3372
#endif
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3373
%}.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3374
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3375
     ^ Array with:fd1 with:fd2.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3376
!
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3377
1132
b09ce8542506 checkin from browser
ca
parents: 1119
diff changeset
  3378
recursiveCopyDirectory:sourcePathName to:destination
b09ce8542506 checkin from browser
ca
parents: 1119
diff changeset
  3379
    "copy the directory named 'sourcePathName' and all contained files/directories to 'destination'.
b09ce8542506 checkin from browser
ca
parents: 1119
diff changeset
  3380
     Return true if successful."
b09ce8542506 checkin from browser
ca
parents: 1119
diff changeset
  3381
b09ce8542506 checkin from browser
ca
parents: 1119
diff changeset
  3382
    ^ self executeCommand:('cp -rf ' , sourcePathName, ' ', destination)
b09ce8542506 checkin from browser
ca
parents: 1119
diff changeset
  3383
b09ce8542506 checkin from browser
ca
parents: 1119
diff changeset
  3384
    "Modified: 7.3.1996 / 15:26:30 / cg"
b09ce8542506 checkin from browser
ca
parents: 1119
diff changeset
  3385
!
b09ce8542506 checkin from browser
ca
parents: 1119
diff changeset
  3386
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3387
recursiveCreateDirectory:dirName
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3388
    "create a directory - with all parent dirs if needed.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3389
     Return true if successful, false otherwise. If false
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3390
     is returned, a partial created tree may be left,
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3391
     which is not cleaned-up here."
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3392
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3393
    self createDirectory:dirName.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3394
    (self isDirectory:dirName) ifFalse:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3395
	(self recursiveCreateDirectory:(self directoryNameOf:dirName)) ifFalse:[^ false].
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3396
	^ self createDirectory:dirName
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3397
    ].
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3398
    ^ true
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3399
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3400
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3401
     OperatingSystem recursiveCreateDirectory:'foo/bar/baz'
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3402
     OperatingSystem recursiveRemoveDirectory:'foo'
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3403
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3404
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3405
    "Modified: 7.3.1996 / 15:26:22 / cg"
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3406
!
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3407
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3408
recursiveRemoveDirectory:fullPathName
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3409
    "remove the directory named 'fullPathName' and all contained files/directories.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3410
     Return true if successful."
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3411
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3412
    ^ self executeCommand:('rm -rf ' , fullPathName)
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3413
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3414
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3415
     OperatingSystem recursiveCreateDirectory:'foo/bar/baz'
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3416
     OperatingSystem recursiveRemoveDirectory:'foo'
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3417
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3418
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3419
    "Modified: 7.3.1996 / 15:26:30 / cg"
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3420
!
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3421
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3422
removeDirectory:fullPathName
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3423
    "remove the directory named 'fullPathName'.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3424
     Return true if successful, false if directory is not empty or no permission.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3425
     This is a lowLevel entry - use Filename protocol for compatibility."
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3426
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  3427
%{
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3428
    int ret;
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3429
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3430
    if (__isString(fullPathName)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3431
	__BEGIN_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3432
	do {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3433
	    ret = rmdir((char *) __stringVal(fullPathName));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3434
	} while (ret < 0 && errno == EINTR);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3435
	__END_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3436
	if (ret < 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3437
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3438
	    RETURN ( false );
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3439
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3440
	RETURN (true);
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3441
    }
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3442
%}.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3443
    ^ self primitiveFailed
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3444
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3445
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3446
     OperatingSystem createDirectory:'foo'
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3447
     OperatingSystem removeDirectory:'foo'
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3448
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3449
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3450
!
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3451
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3452
removeFile:fullPathName
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3453
    "remove the file named 'fullPathName'; return true if successful.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3454
     This is a lowLevel entry - use Filename protocol for compatibility."
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3455
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  3456
%{
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3457
    int ret;
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3458
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3459
    if (__isString(fullPathName)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3460
	__BEGIN_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3461
	do {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3462
	    ret = unlink((char *) __stringVal(fullPathName));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3463
	} while (ret < 0 && errno == EINTR);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3464
	__END_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3465
	if (ret < 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3466
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3467
	    RETURN ( false );
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3468
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3469
	RETURN (true);
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3470
    }
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3471
%}.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3472
    ^ self primitiveFailed
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3473
!
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3474
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3475
renameFile:oldPath to:newPath
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3476
    "rename the file 'oldPath' to 'newPath'. 
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3477
     Return true if successful, false if not"
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3478
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  3479
%{
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3480
    int ret, eno;
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3481
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3482
    if (__isString(oldPath) && __isString(newPath)) {
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3483
#if defined(HAS_RENAME)
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3484
	__BEGIN_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3485
	do {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3486
	    ret = rename((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3487
	} while (ret < 0 && errno == EINTR);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3488
	__END_INTERRUPTABLE__
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3489
#else
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3490
# ifndef MSDOS_LIKE
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3491
	ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3492
	if (ret >= 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3493
	    ret = unlink((char *) __stringVal(oldPath));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3494
	    if (ret < 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3495
		eno = errno;
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3496
		unlink((char *) __stringVal(newPath));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3497
		errno = eno;
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3498
	    }
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3499
	}
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3500
# endif
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3501
#endif
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3502
	if (ret < 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3503
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3504
	    RETURN ( false );
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3505
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3506
	RETURN (true);
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3507
    }
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3508
%}.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3509
    ^ self primitiveFailed
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3510
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3511
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3512
     OperatingSystem renameFile:'foo' to:'bar'
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3513
    "
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3514
!
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3515
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3516
truncateFile:aPathName to:newSize
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3517
    "change a files size return true on success, false on failure.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3518
     This may not be supported on all architectures.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3519
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3520
     This is a low-level entry - use Filename protocol."
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3521
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  3522
%{
1623
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3523
#ifdef HAS_TRUNCATE
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3524
    int ret;
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3525
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3526
    if (__isString(aPathName)
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3527
     && __isSmallInteger(newSize)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3528
	__BEGIN_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3529
	do {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3530
	    ret = truncate((char *) __stringVal(aPathName), __intVal(newSize));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3531
	} while (ret < 0 && errno == EINTR);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3532
	__END_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3533
	if (ret < 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3534
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3535
	    RETURN ( false );
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3536
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3537
	RETURN (true);
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3538
    }
1623
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3539
#else
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3540
# ifdef HAS_FTRUNCATE
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3541
    int ret;
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3542
    int fd;
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3543
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3544
    if (__isString(aPathName)
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3545
     && __isSmallInteger(newSize)) {
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3546
	do {
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3547
	    fd = open((char *) __stringVal(aPathName), 2);
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3548
	} while (fd < 0 && errno == EINTR);
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3549
	if (fd < 0) {
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3550
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3551
	    RETURN ( false );
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3552
	}
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3553
        
1623
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3554
	ret = ftruncate(fd, __intVal(newSize));
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3555
	close(fd);
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3556
	if (ret < 0) {
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3557
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3558
	    RETURN ( false );
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3559
	} 
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3560
	RETURN (true);
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3561
    }
95009f9bfc18 use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents: 1622
diff changeset
  3562
# endif /* using FTRUNCATE */
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3563
#endif
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3564
%}.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3565
    ^ self primitiveFailed
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3566
! !
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3567
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  3568
!OperatingSystem class methodsFor:'file access rights'!
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3569
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3570
accessMaskFor:aSymbol
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3571
    "return the access bits mask for numbers as returned by 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3572
     OperatingSystem>>accessModeOf:
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3573
     and expected by OperatingSystem>>changeAccessModeOf:to:.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3574
     Since these numbers are OS dependent, always use the mask
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3575
     (never hardcode 8rxxx into your code)."
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  3576
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  3577
%{  /* NOCONTEXT */
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3578
#   ifndef S_IRUSR
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3579
    /* posix systems should define these ... */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3580
#    define S_IRUSR 0400
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3581
#    define S_IWUSR 0200
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3582
#    define S_IXUSR 0100
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3583
#    define S_IRGRP 0040
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3584
#    define S_IWGRP 0020
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3585
#    define S_IXGRP 0010
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3586
#    define S_IROTH 0004
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3587
#    define S_IWOTH 0002
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3588
#    define S_IXOTH 0001
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3589
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3590
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3591
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3592
    if (aSymbol == @symbol(readUser)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  3593
	RETURN ( __MKSMALLINT(S_IRUSR) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3594
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3595
    if (aSymbol == @symbol(writeUser)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  3596
	RETURN ( __MKSMALLINT(S_IWUSR) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3597
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3598
    if (aSymbol == @symbol(executeUser)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  3599
	RETURN ( __MKSMALLINT(S_IXUSR) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3600
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3601
    if (aSymbol == @symbol(readGroup)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  3602
	RETURN ( __MKSMALLINT(S_IRGRP) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3603
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3604
    if (aSymbol == @symbol(writeGroup)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  3605
	RETURN ( __MKSMALLINT(S_IWGRP) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3606
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3607
    if (aSymbol == @symbol(executeGroup)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  3608
	RETURN ( __MKSMALLINT(S_IXGRP) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3609
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3610
    if (aSymbol == @symbol(readOthers)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  3611
	RETURN ( __MKSMALLINT(S_IROTH) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3612
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3613
    if (aSymbol == @symbol(writeOthers)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  3614
	RETURN ( __MKSMALLINT(S_IWOTH) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3615
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3616
    if (aSymbol == @symbol(executeOthers)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  3617
	RETURN ( __MKSMALLINT(S_IXOTH) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3618
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3619
%}.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  3620
    ^ self primitiveFailed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3621
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3622
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3623
     OperatingSystem accessMaskFor:#readUser
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3624
    "
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  3625
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  3626
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3627
accessModeOf:aPathName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3628
    "return a number representing access rights rwxrwxrwx for owner,
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3629
     group and others. Return nil if such a file does not exist.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3630
     Notice that the returned number is OS dependent - use the 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3631
     modeMasks as returned by OperatingSystem>>accessMaskFor:"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3632
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3633
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3634
     this could have been implemented as:
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3635
	(self infoOf:aPathName) at:#mode
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3636
     but for huge directory searches the code below is faster
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3637
    "
345
claus
parents: 329
diff changeset
  3638
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  3639
%{
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3640
    struct stat buf;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3641
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3642
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3643
    if (__isString(aPathName)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3644
	__BEGIN_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3645
	do {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3646
	    ret = stat((char *) __stringVal(aPathName), &buf);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3647
	} while ((ret < 0) && (errno == EINTR));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3648
	__END_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3649
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3650
	if (ret < 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3651
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3652
	    RETURN ( nil );
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3653
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3654
	RETURN ( __MKSMALLINT(buf.st_mode & 0777) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3655
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3656
%}.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  3657
   ^ self primitiveFailed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3658
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3659
   "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3660
    (OperatingSystem accessModeOf:'/') printStringRadix:8
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3661
   "
345
claus
parents: 329
diff changeset
  3662
!
claus
parents: 329
diff changeset
  3663
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3664
changeAccessModeOf:aPathName to:modeBits
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3665
    "change the access rights of aPathName to the OS dependent modeBits.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3666
     You should construct this mask using accessMaskFor, to be OS
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3667
     independent. Return true if changed, 
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3668
     false if such a file does not exist or change was not allowd."
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3669
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  3670
%{
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3671
    int ret;
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3672
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3673
    if (__isString(aPathName) && __isSmallInteger(modeBits)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3674
	__BEGIN_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3675
	do {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3676
	    ret = chmod((char *)__stringVal(aPathName), __intVal(modeBits));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3677
	} while (ret < 0 && errno == EINTR);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3678
	__END_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3679
	if (ret < 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3680
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3681
	    RETURN ( false );
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3682
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  3683
	RETURN ( true );
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3684
    }
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3685
%}.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3686
    ^ self primitiveFailed
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3687
! !
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3688
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  3689
!OperatingSystem class methodsFor:'file locking'!
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3690
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3691
lockFD:aFileDescriptor shared:isSharedReadLock blocking:blockIfLocked
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3692
   "set a lock on the file represented by aFileDescriptor.
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3693
    (such as returned by ExternalStream>>fileDescriptor).
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3694
    On some systems, only advisory locks are available -
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3695
    these depends on other accessors to also perform the locking operation.
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3696
    If they do not, they may still access the file 
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3697
    (on some systems, locks are mandatory, on others, they are advisory). 
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3698
    The isSharedReadLock argument (if true) specifies if multiple readers
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3699
    are to be allowed - if false, they are not.
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3700
    On some systems, all locks are non-exclusive locks.
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3701
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3702
    Returns true, if the lock was aquired, false otherwise.
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3703
1616
fa734ea238f8 type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
  3704
    Notice, that not all OS's support these locks; 
fa734ea238f8 type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
  3705
    on some, this may simply be a no-op.
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3706
    Also notice, that some systems block the process, to wait for the lock.
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3707
    This can (again: on some systems) be avoided by passing a false blockIfLocked
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3708
    argument."
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3709
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3710
%{
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3711
    if (__isSmallInteger(aFileDescriptor)) {
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3712
	int fd = __intVal(aFileDescriptor);
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3713
	int lockArg;
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3714
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3715
	/*
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3716
	 * claus: sigh - each one has a different interface ... 
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3717
	 */
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3718
#if defined(F_SETLK)
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3719
	{
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3720
	    /* 
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3721
	     * new fcntl(SETLK) interface;
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3722
	     * available on SYSV4 and Linux
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3723
	     */
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3724
	    struct flock flock;
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3725
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3726
	    if (isSharedReadLock == true) {
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3727
		flock.l_type = F_RDLCK;
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3728
	    } else {
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3729
		flock.l_type = F_WRLCK;
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3730
	    }
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3731
	    flock.l_whence = 0;
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3732
	    flock.l_start = 0;
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3733
	    flock.l_len = 0;
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3734
	    lockArg = F_SETLK;
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3735
# if defined(F_SETLKW)
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3736
	    if (blockIfLocked == true) {
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3737
		lockArg = F_SETLKW;
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3738
	    }
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3739
# endif
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3740
	    if (fcntl(fd, lockArg, &flock) != -1) {
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3741
		RETURN (true);
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3742
	    }
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3743
	}
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3744
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3745
#else /* no F_SETLK available */
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3746
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3747
# if defined(LOCK_EX) && defined(LOCK_UN)
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3748
	/* 
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3749
	 * BSD 4.3 advisory locks
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3750
	 */
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3751
	lockArg = LOCK_EX;
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3752
#  if defined(LOCK_SH)
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3753
	if (isSharedReadLock == true) {
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3754
	    lockArg = LOCK_SH
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3755
	}
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3756
#  endif
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3757
#  if defined(LOCK_NB)
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3758
	if (blockIfLocked == false) {
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3759
	    lockArg |= LOCK_NB;
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3760
	}
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3761
#  endif
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3762
	if (flock(fd, lockArg) != -1) {
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3763
	    RETURN (true);
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3764
	}
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3765
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3766
# else /* no flock available */
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3767
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3768
#  if defined(F_LOCK) && defined(F_UNLOCK)
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3769
	/* 
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3770
	 * SYSV3 advisory locks
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3771
	 */
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3772
	if (lockf(fd, F_LOCK, 0) != -1) {
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3773
	    RETURN (true);
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3774
	}
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3775
#  endif
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3776
# endif
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3777
#endif
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3778
    }
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3779
%}.
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3780
    ^ false
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3781
!
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3782
1616
fa734ea238f8 type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
  3783
supportsFileLocks
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3784
    "return true, if the OS supports file locking"
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3785
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3786
%{ /* NOCONTEXT */
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3787
#if defined(F_SETLK)
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3788
    RETURN (true);
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3789
#else
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3790
# if defined(LOCK_EX) && defined(LOCK_UN)
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3791
    RETURN (true);
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3792
# else
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3793
#  if defined(F_LOCK) && defined(F_UNLOCK)
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3794
    RETURN (true);
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3795
#  endif
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3796
# endif
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3797
#endif
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3798
%}.
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3799
    ^ false
1616
fa734ea238f8 type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
  3800
fa734ea238f8 type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
  3801
    "
fa734ea238f8 type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
  3802
     OperatingSystem supportsFileLocks
fa734ea238f8 type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
  3803
    "
1617
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3804
!
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3805
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3806
supportsNonBlockingFileLocks
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3807
    "return true, if the OS supports nonBlocking file locking
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3808
     (i.e. with immediate return instead of waiting for the lock)"
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3809
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3810
%{ /* NOCONTEXT */
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3811
#if defined(F_SETLK) && defined(F_SETLKW)
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3812
    RETURN (true);
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3813
#else
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3814
# if defined(LOCK_EX) && defined(LOCK_UN) && defined(LOCK_NB)
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3815
    RETURN (true);
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3816
# endif
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3817
#endif
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3818
%}.
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3819
    ^ false
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3820
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3821
    "
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3822
     OperatingSystem supportsNonBlockingFileLocks
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3823
    "
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3824
!
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3825
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3826
supportsSharedLocks
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3827
    "return true, if the OS supports shared (i.e. multiple reader)
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3828
     file locking."
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3829
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3830
%{ /* NOCONTEXT */
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3831
#if defined(F_SETLK) && defined(F_RDLCK) && defined(F_WRLCK)
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3832
    RETURN (true);
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3833
#else
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3834
# if defined(LOCK_EX) && defined(LOCK_SH) && defined(LOCK_UN)
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3835
    RETURN (true);
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3836
# endif
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3837
#endif
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3838
%}.
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3839
    ^ false
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3840
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3841
    "
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3842
     OperatingSystem supportsNonBlockingFileLocks
9b72f5efb8cb added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
  3843
    "
1621
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3844
!
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3845
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3846
unlockFD:aFileDescriptor
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3847
    "clear a file lock on the file represented by aFileDescriptor,
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3848
     which was previously aquired by #lockFD:.
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3849
     Return false, if the unlock failed 
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3850
     (which may happens when a wrong fd is passed, 
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3851
      no lock was set previously, or the systsem does not support locks).
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3852
     Notice, that not all OS's support file locks; 
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3853
     on some, this may simply be a no-op."
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3854
     
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3855
%{
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3856
    if (__isSmallInteger(aFileDescriptor)) {
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3857
	int fd = __intVal(aFileDescriptor);
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3858
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3859
	/*
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3860
	 * claus: sigh - each one has a different interface ...
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3861
	 */
1621
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3862
#if defined(F_SETLK)
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3863
	{
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3864
	    /*
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3865
	     * new fcntl(SETLK) interface;
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3866
	     * available on SYSV4 and Linux
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3867
	     */
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3868
	    struct flock flock;
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3869
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3870
	    flock.l_type = F_UNLCK;
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3871
	    flock.l_whence = 0;
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3872
	    flock.l_start = 0;
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3873
	    flock.l_len = 0;
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3874
	    if (fcntl(fd, F_SETLK, &flock) != -1) {
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3875
		RETURN (true);
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3876
	    }
1621
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3877
	}
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3878
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3879
#else /* no F_SETLK available */
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3880
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3881
# if defined(LOCK_EX) && defined(LOCK_UN)
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3882
	/*
1621
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3883
	 * BSD 4.3 advisory locks
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3884
	 */
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3885
	if (flock(fd, LOCK_UN) != -1) {
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3886
	    RETURN (true);
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  3887
	}
1621
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3888
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3889
# else /* no flock available */
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3890
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3891
#  if defined(F_LOCK) && defined(F_UNLOCK)
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3892
	/* 
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3893
	 * SYSV3 advisory locks
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3894
	 */
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3895
	if (lockf(fd, F_UNLOCK, 0) != -1) {
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3896
	    RETURN (true);
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3897
	}
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3898
#  endif
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3899
# endif
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3900
#endif
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3901
    }
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3902
%}.
30620c379b35 file-lock example
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  3903
    ^ false
1615
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3904
! !
0dc932c45c67 added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
  3905
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  3906
!OperatingSystem class methodsFor:'file queries'!
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  3907
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3908
baseNameOf:aPathString
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3909
    "return the baseName of the argument, aPathString
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3910
     - thats the file/directory name without leading parent-dirs
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3911
     (i.e. OperatingSystem baseNameOf:'/usr/lib/st/file' -> 'file'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3912
       and OperatingSystem baseNameOf:'/usr/lib' -> lib).
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3913
     This method does not check if the path is valid 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3914
     (i.e. if these directories really exist & is readable)."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3915
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3916
    |prev index sep|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3917
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3918
    sep := self fileSeparator.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3919
    ((aPathString size == 1) and:[(aPathString at:1) == sep]) ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3920
	^ aPathString
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3921
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3922
    prev := 1.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3923
    [true] whileTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3924
	index := aPathString indexOf:sep startingAt:prev.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3925
	index == 0 ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3926
	    ^ aPathString copyFrom:prev
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3927
	].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3928
	prev := index + 1
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3929
    ]
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3930
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3931
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3932
     OperatingSystem baseNameOf:'/fee/foo/bar'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3933
     OperatingSystem baseNameOf:'foo/bar'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3934
     OperatingSystem baseNameOf:'../../foo/bar'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3935
     OperatingSystem baseNameOf:'hello'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3936
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3937
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3938
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3939
caseSensitiveFilenames
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3940
    "return true, if the OS has caseSensitive file naming.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3941
     On MSDOS, this will return false. Since this is for Unix, we
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3942
     return true."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3943
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3944
    ^ true
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3945
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3946
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3947
compressPath:pathName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3948
    "return the pathName compressed - that is, remove all ..-entries
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3949
     and . entries. This does not always (in case of symbolic links)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3950
     return the true pathName and is therefore used as a fallback
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3951
     if realPath and popen failed."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3952
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  3953
    |names n "{ Class: SmallInteger }" |
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3954
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3955
    names := pathName 
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3956
		asCollectionOfSubstringsSeparatedBy:self fileSeparator.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3957
    names := names asOrderedCollection.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3958
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3959
     cut off initial double-slashes
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3960
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3961
    [names startsWith:#('' '')] whileTrue:[
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3962
	names removeFirst.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3963
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3964
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3965
     cut off double-slashes at end
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3966
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3967
    [names endsWith:#('')] whileTrue:[
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3968
	names removeLast.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3969
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3970
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3971
     cut off current-dir at beginning
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3972
    "
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  3973
    n := names size.
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  3974
    [(n >= 2) and:[names startsWith:#('.')]] whileTrue:[
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3975
	names removeFirst.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3976
	n := n - 1.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3977
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3978
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3979
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3980
     cut off parent-dirs at end
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3981
    "
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  3982
    [(n > 2) 
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3983
     and:[(names endsWith:#('..'))
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  3984
     and:[((names at:(n - 1)) startsWith:'.') not ]]] whileTrue:[
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3985
	names removeLast; removeLast.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3986
	n := n - 2.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3987
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3988
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3989
    ^ names asStringWith:self fileSeparator 
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3990
		    from:1
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3991
		    to:n
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  3992
		    compressTabs:false final:nil 
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3993
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3994
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3995
     OperatingSystem compressPath:'./..'    
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3996
     OperatingSystem compressPath:'/foo/bar/baz/..'  
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3997
     OperatingSystem compressPath:'foo/bar/baz/..'  
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3998
     OperatingSystem compressPath:'foo/bar/baz/../'  
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  3999
     OperatingSystem compressPath:'foo/bar/baz/..///' 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4000
     OperatingSystem compressPath:'///foo/bar/baz/..///' 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4001
    "
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4002
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4003
    "Modified: 1.11.1996 / 20:13:48 / cg"
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4004
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4005
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4006
directoryNameOf:aPathString
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4007
    "return the directoryName of the argument, aPath
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4008
     - thats the name of the directory where aPath is
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4009
     (i.e. OperatingSystem directoryNameOf:'/usr/lib/st/file' -> '/usr/lib/st'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4010
       and OperatingSystem directoryNameOf:'/usr/lib' -> /usr').
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4011
     This method does not check if the path is valid
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4012
     (i.e. if these directories really exist & are readable)."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4013
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4014
    |last index sep sepString p|
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4015
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4016
    sep := self fileSeparator.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4017
    sepString := sep asString.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4018
    (aPathString = sepString) ifTrue:[
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4019
	"
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4020
	 the trivial '/' case
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4021
	"
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4022
	^ aPathString
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4023
    ].
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4024
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4025
    p := aPathString.
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4026
    [p endsWith:sepString] whileTrue:[
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4027
	(p = sepString) ifTrue:[
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4028
	    ^ p
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4029
	].
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4030
	p := p copyWithoutLast:1
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4031
    ].
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4032
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4033
    last := 1.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4034
    [true] whileTrue:[
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4035
	index := p indexOf:sep startingAt:(last + 1).
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4036
	index == 0 ifTrue:[
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4037
	    (last == 1) ifTrue:[
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4038
		(p startsWith:sepString) ifTrue:[
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4039
		    ^ sepString
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4040
		].
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4041
		^ '.'
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4042
	    ].
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4043
"
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4044
	    (p startsWith:sepString) ifFalse:[
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4045
		(p startsWith:('..' , sepString)) ifFalse:[
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4046
		    ^ './' , (p copyTo:(last - 1))
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4047
		]
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4048
	    ].
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4049
"
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4050
	    ^ p copyTo:(last - 1)
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4051
	].
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4052
	last := index.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4053
    ]
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4054
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4055
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4056
     OperatingSystem directoryNameOf:'/fee/foo/bar'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4057
     OperatingSystem directoryNameOf:'foo/bar'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4058
     OperatingSystem directoryNameOf:'../../foo/bar'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4059
     OperatingSystem directoryNameOf:'bar'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4060
     OperatingSystem directoryNameOf:'/bar'
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4061
     OperatingSystem directoryNameOf:'/tmp' 
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4062
     OperatingSystem directoryNameOf:'/tmp///' 
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4063
     OperatingSystem directoryNameOf:'/bar///' 
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4064
     OperatingSystem directoryNameOf:'/bar/'  
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4065
     OperatingSystem directoryNameOf:'./bar'  
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4066
     OperatingSystem directoryNameOf:'/./bar'  
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4067
    "
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4068
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4069
    "Modified: 22.10.1996 / 18:53:47 / cg"
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4070
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4071
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4072
fileSeparator
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4073
    "return the character used to separate names in a path.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4074
     This character differs for MSDOS and other systems,
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4075
     (but those are currently not supported - so this is some
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4076
      preparation for the future)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4077
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4078
    ^ $/
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4079
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4080
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4081
idOf:aPathName
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4082
    "return the fileNumber (i.e. inode number) of a file.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4083
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4084
     Not all operatingSystems may provide this - on those that do not,
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4085
     some dummy id will be returned.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4086
     On unix, this information can be used to check for two files being 
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4087
     physically identical, even if found in different directories 
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4088
     (i.e. if they are hardLinked)."
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4089
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4090
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4091
     this could have been implemented as:
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4092
	(self infoOf:aPathName) at:#id 
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4093
     but for huge directory searches the code below is faster
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4094
    "
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4095
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  4096
%{
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4097
    struct stat buf;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4098
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4099
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4100
    if (__isString(aPathName)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4101
	__BEGIN_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4102
	do {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4103
	    ret = stat((char *) __stringVal(aPathName), &buf);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4104
	} while (ret < 0 && errno == EINTR);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4105
	__END_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4106
	if (ret >= 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4107
	    RETURN (__MKSMALLINT(buf.st_ino));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4108
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4109
	@global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4110
	RETURN (nil);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4111
    }
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4112
%}
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4113
.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4114
    ^ self primitiveFailed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4115
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4116
    "OperatingSystem idOf:'/'"
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4117
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4118
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4119
infoOf:aPathName
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4120
    "return some object filled with info for the file 'aPathName';
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4121
     the info (for which corresponding access methods are understood by
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4122
     the returned object) is:
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4123
	 type  - a symbol giving the files fileType
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4124
	 mode  - numeric access mode 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4125
	 uid   - owners user id
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4126
	 gid   - owners group id
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4127
	 size  - files size
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4128
	 id    - files number (i.e. inode number)
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4129
	 accessed      - last access time (as osTime-stamp)
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4130
	 modified      - last modification time (as osTime-stamp)
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4131
	 statusChanged - last status change time (as osTime-stamp)
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4132
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4133
     Some of the fields may be returned as nil on systems which do not provide
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4134
     all of the information.
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4135
     Return nil if such a file does not exist. 
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4136
     For symbolic links, the info of the pointed-to-file is returned;
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4137
     use #linkInfoOf: to get info about the link itself.
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4138
    "
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4139
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4140
    |info type mode uid gid size id 
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  4141
     atime mtime ctime|
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4142
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4143
%{
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4144
    struct stat buf;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4145
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4146
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4147
    if (__isString(aPathName)) {
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4148
	__BEGIN_INTERRUPTABLE__
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4149
	do {
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4150
	    ret = stat((char *) __stringVal(aPathName), &buf);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4151
	} while ((ret < 0) && (errno == EINTR));
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4152
	__END_INTERRUPTABLE__
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4153
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4154
	if (ret < 0) {
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4155
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4156
	    RETURN ( nil );
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4157
	}
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4158
	switch (buf.st_mode & S_IFMT) {
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4159
	    case S_IFDIR:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4160
		type = @symbol(directory);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4161
		break;
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4162
	    case S_IFREG:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4163
		type = @symbol(regular);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4164
		break;
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4165
#ifdef S_IFCHR
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4166
	    case S_IFCHR:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4167
		type = @symbol(characterSpecial);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4168
		break;
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4169
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4170
#ifdef S_IFBLK
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4171
	    case S_IFBLK:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4172
		type = @symbol(blockSpecial);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4173
		break;
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4174
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4175
#ifdef S_IFLNK
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4176
	    case S_IFLNK:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4177
		type = @symbol(symbolicLink);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4178
		break;
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4179
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4180
#ifdef S_IFSOCK
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4181
	    case S_IFSOCK:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4182
		type = @symbol(socket);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4183
		break;
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4184
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4185
#ifdef S_IFIFO
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4186
	    case S_IFIFO:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4187
		type = @symbol(fifo);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4188
		break;
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4189
#endif
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4190
	    default:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4191
		type = @symbol(unknown);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4192
		break;
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4193
	}
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4194
	mode = __MKSMALLINT(buf.st_mode & 0777);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4195
	uid = __MKSMALLINT(buf.st_uid);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4196
	gid = __MKSMALLINT(buf.st_gid);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4197
	size = __MKSMALLINT(buf.st_size);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4198
	id = __MKSMALLINT(buf.st_ino);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4199
	atime = __MKUINT(buf.st_atime);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4200
	mtime = __MKUINT(buf.st_mtime);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4201
	ctime = __MKUINT(buf.st_ctime);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4202
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4203
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4204
    mode notNil ifTrue:[
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4205
	^ FileStatusInfo
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4206
	    type:type 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4207
	    mode:mode 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4208
	    uid:uid 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4209
	    gid:gid 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4210
	    size:size 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4211
	    id:id 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4212
	    accessed:(AbsoluteTime fromOSTime:(atime * 1000)) 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4213
	    modified:(AbsoluteTime fromOSTime:(mtime * 1000)) 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4214
	    statusChanged:(AbsoluteTime fromOSTime:(ctime * 1000))
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4215
	    path:nil
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4216
   ].
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4217
   ^ self primitiveFailed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4218
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4219
   "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4220
    OperatingSystem infoOf:'/'
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4221
    (OperatingSystem infoOf:'/') uid
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4222
    (OperatingSystem infoOf:'/') accessed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4223
   "
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4224
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4225
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4226
isDirectory:aPathName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4227
    "return true, if 'aPathName' is a valid directory path name.
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4228
     (i.e. exists and is a directory).
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4229
     This also returns true for symbolic links pointing to a directory;
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4230
     if you need to check for this, use #linkInfo:."
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4231
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  4232
%{
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4233
    struct stat buf;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4234
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4235
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4236
    if (__isString(aPathName)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4237
	__BEGIN_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4238
	do {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4239
	    ret = stat((char *) __stringVal(aPathName), &buf);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4240
	} while ((ret < 0) && (errno == EINTR));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4241
	__END_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4242
	if (ret < 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4243
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4244
	    RETURN ( false );
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4245
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4246
	RETURN ( ((buf.st_mode & S_IFMT) == S_IFDIR) ? true : false);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4247
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4248
%}.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4249
    ^ self primitiveFailed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4250
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4251
    "an alternative implementation would be:
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4252
	^ (self infoOf:aPathName) at:#type == #directory
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4253
    "
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4254
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4255
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4256
isExecutable:aPathName
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4257
    "return true, if the given file is executable.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4258
     For symbolic links, the pointed-to-file is checked."
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4259
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  4260
%{
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4261
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4262
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4263
    if (__isString(aPathName)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4264
	__BEGIN_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4265
	do {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4266
	    ret = access(__stringVal(aPathName), X_OK);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4267
	} while ((ret < 0) && (errno == EINTR));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4268
	__END_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4269
	if (ret < 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4270
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4271
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4272
	RETURN ( ((ret == 0) ? true : false) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4273
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4274
%}.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4275
    ^ self primitiveFailed
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4276
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4277
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4278
isReadable:aPathName
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4279
    "return true, if the file/dir 'aPathName' is readable.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4280
     For symbolic links, the pointed-to-file is checked."
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4281
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  4282
%{
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4283
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4284
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4285
    if (__isString(aPathName)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4286
	__BEGIN_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4287
	do {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4288
	    ret = access(__stringVal(aPathName), R_OK);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4289
	} while ((ret < 0) && (errno == EINTR));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4290
	__END_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4291
	if (ret < 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4292
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4293
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4294
	RETURN ( ((ret == 0) ? true : false) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4295
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4296
%}.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4297
    ^ self primitiveFailed
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4298
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4299
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4300
isSymbolicLink:aPathName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4301
    "return true, if the given file is a symbolic link"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4302
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4303
    ^ (self linkInfoOf:aPathName) notNil
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4304
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4305
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4306
     OperatingSystem isSymbolicLink:'Make.proto'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4307
     OperatingSystem isSymbolicLink:'Makefile' 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4308
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4309
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4310
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4311
isValidPath:aPathName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4312
    "return true, if 'aPathName' is a valid path name
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4313
     (i.e. the file or directory exists)"
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4314
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  4315
%{
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4316
    struct stat buf;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4317
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4318
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4319
    if (__isString(aPathName) || __isSymbol(aPathName) ) {
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4320
	__BEGIN_INTERRUPTABLE__
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4321
	do {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  4322
	    ret = stat((char *) __stringVal(aPathName), &buf);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4323
	} while ((ret < 0) && (errno == EINTR));
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4324
	__END_INTERRUPTABLE__
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4325
	if (ret < 0) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  4326
	    OperatingSystem_LastErrorNumber = __MKSMALLINT(errno);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4327
	    RETURN (false);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4328
	}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4329
	RETURN ( ret ? false : true );
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4330
    }
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4331
%}.
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4332
    ^ self primitiveFailed
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4333
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4334
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4335
isWritable:aPathName
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4336
    "return true, if the given file is writable.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4337
     For symbolic links, the pointed-to-file is checked."
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4338
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  4339
%{
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4340
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4341
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4342
    if (__isString(aPathName)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4343
	__BEGIN_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4344
	do {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4345
	    ret = access(__stringVal(aPathName), W_OK);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4346
	} while ((ret < 0) && (errno == EINTR));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4347
	__END_INTERRUPTABLE__
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4348
	if (ret < 0) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4349
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4350
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4351
	RETURN ( ((ret == 0) ? true : false) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4352
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4353
%}.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4354
    ^ self primitiveFailed
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4355
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4356
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4357
linkInfoOf:aPathName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4358
    "return a dictionary filled with info for the file 'aPathName',
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4359
     IFF aPathName is a symbolic link. 
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4360
     If aPathName is invalid, or its NOT a symbolic link, nil is returned.
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4361
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4362
     The contents of the dictionary gives info about the link itself,
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4363
     on contrast to #infoOf:, which returns the info of the pointed to file
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4364
     in case of a symbolic link."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4365
     
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  4366
    |info type mode uid gid size id atime mtime ctime path|
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4367
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4368
%{  /* STACK: 1200 */
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4369
#ifdef S_IFLNK
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4370
    struct stat buf;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4371
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4372
    char pathBuffer[1024];
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4373
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4374
    if (__isString(aPathName)) {
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4375
	__BEGIN_INTERRUPTABLE__
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4376
	do {
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4377
	    ret = lstat((char *) __stringVal(aPathName), &buf);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4378
	} while ((ret < 0) && (errno == EINTR));
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4379
	__END_INTERRUPTABLE__
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4380
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4381
	if (ret < 0) {
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4382
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4383
	    RETURN ( nil );
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4384
	}
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4385
	switch (buf.st_mode & S_IFMT) {
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4386
	    default:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4387
		RETURN ( nil ); /* not a symbolic link */
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4388
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4389
	    case S_IFLNK:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4390
		type = @symbol(symbolicLink);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4391
		break;
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4392
	}
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4393
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4394
	mode = __MKSMALLINT(buf.st_mode & 0777);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4395
	uid = __MKSMALLINT(buf.st_uid);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4396
	gid = __MKSMALLINT(buf.st_gid);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4397
	size = __MKSMALLINT(buf.st_size);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4398
	id = __MKSMALLINT(buf.st_ino);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4399
	atime = __MKUINT(buf.st_atime);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4400
	mtime = __MKUINT(buf.st_mtime);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4401
	ctime = __MKUINT(buf.st_ctime);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4402
	if ((ret = readlink((char *) __stringVal(aPathName), pathBuffer, sizeof(pathBuffer))) < 0) {
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4403
	    OperatingSystem_LastErrorNumber = __MKSMALLINT(errno);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4404
	    RETURN ( nil );
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4405
	} 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4406
	pathBuffer[ret] = '\0';  /* readlink does not 0-terminate */
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4407
	path = __MKSTRING(pathBuffer);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4408
    }
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4409
#else
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4410
    RETURN ( nil );
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4411
#endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4412
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4413
    mode notNil ifTrue:[
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4414
	info := IdentityDictionary new.
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4415
	^ FileStatusInfo
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4416
	    type:type 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4417
	    mode:mode 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4418
	    uid:uid 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4419
	    gid:gid 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4420
	    size:size 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4421
	    id:id 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4422
	    accessed:(AbsoluteTime fromOSTime:(atime * 1000)) 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4423
	    modified:(AbsoluteTime fromOSTime:(mtime * 1000)) 
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4424
	    statusChanged:(AbsoluteTime fromOSTime:(ctime * 1000))
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4425
	    path:path
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4426
   ].
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4427
   ^ self primitiveFailed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4428
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4429
   "
1084
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4430
    OperatingSystem infoOf:'Make.proto'  
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4431
    OperatingSystem linkInfoOf:'Make.proto' 
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4432
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4433
    OperatingSystem infoOf:'resources/motif.style'   
d6ffc9368fd5 set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
  4434
    OperatingSystem linkInfoOf:'resources/motif.style' 
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4435
   "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4436
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4437
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4438
parentDirectoryName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4439
    "return the name used to refer to parent directories.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4440
     In MSDOS, Unix and other systems this is '..', but maybe different
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4441
     for other systems.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4442
     (but those are currently not supported - so this is some
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4443
      preparation for the future)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4444
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4445
    ^ '..'
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4446
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4447
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4448
pathNameOf:pathName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4449
    "return the pathName of the argument, aPathString,
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4450
     - thats the full pathname of the directory, starting at '/'.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4451
     This method needs the path to be valid
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4452
     (i.e. all directories must exist, be readable and executable).
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4453
     Notice: if symbolic links are involved, the result may look different
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4454
     from what you expect."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4455
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4456
    |p path command|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4457
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4458
    "some systems have a convenient function for this ..."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4459
    path := self primPathNameOf:pathName.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4460
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4461
    path isNil ifTrue:[
2080
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4462
	(self isValidPath:pathName) ifFalse:[
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4463
	    p := pathName.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4464
	    [(p size > 1)
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4465
	     and:[p endsWith:(self fileSeparator)]
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4466
	    ] whileTrue:[
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4467
		p := p copyWithoutLast:1.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4468
	    ].
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4469
	    ^ p
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4470
	].
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4471
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4472
	(SlowFork==true or:[ForkFailed==true]) ifFalse:[
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4473
	    PipeStream openErrorSignal handle:[:ex |
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4474
		ForkFailed := true.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4475
		'OS: cannot fork/popen' errorPrintNL.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4476
		ex return.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4477
	    ] do:[
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4478
		"have to fall back ..."
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4479
		command := 'cd ' , pathName , '; pwd'.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4480
		p := PipeStream readingFrom:command.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4481
	    ].
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4482
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4483
	    (p isNil or:[p atEnd]) ifTrue:[
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4484
		('OS: PipeStream for <' , command , '> failed') errorPrintNL.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4485
	    ] ifFalse:[
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4486
		path := p nextLine.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4487
		p close.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4488
	    ].
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4489
	].
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4490
	path isNil ifTrue:[
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4491
	    path := pathName
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4492
	].
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4493
	(SlowFork==true or:[ForkFailed==true]) ifTrue:[
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4494
	    path := self compressPath:path
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  4495
	]
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4496
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4497
    ^ path.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4498
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4499
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4500
     OperatingSystem pathNameOf:'.'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4501
     OperatingSystem pathNameOf:'../smalltalk/../smalltalk'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4502
     OperatingSystem pathNameOf:'../../..'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4503
     OperatingSystem pathNameOf:'..'
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4504
     OperatingSystem pathNameOf:'/tmp////' 
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4505
     OperatingSystem pathNameOf:'/foo/bar' 
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4506
     OperatingSystem pathNameOf:'/foo/bar/'
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4507
     OperatingSystem pathNameOf:'/foo/bar//'
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4508
    "
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4509
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4510
    "Modified: 22.10.1996 / 17:59:19 / cg"
1991
6dc27b78da3e Fix pathNameOf: for systems not supporting primPathNameOf:
Stefan Vogel <sv@exept.de>
parents: 1987
diff changeset
  4511
    "Modified: 29.11.1996 / 18:02:12 / stefan"
359
claus
parents: 357
diff changeset
  4512
!
claus
parents: 357
diff changeset
  4513
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4514
primPathNameOf:pathName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4515
    "return the pathName of the argument, aPathString,
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4516
     - thats the full pathname of the directory, starting at '/'.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4517
     This method here returns nil, if the OS does not provide a
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4518
     realPath library function.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4519
     Notice: if symbolic links are involved, the result may look different
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4520
     from what you expect."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4521
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4522
    |path|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4523
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4524
    "some systems have a convenient function for this ..."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4525
%{  /* STACK: 16000 */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4526
#ifdef HAS_REALPATH
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4527
    char nameBuffer[MAXPATHLEN + 1];
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4528
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4529
    if (__isString(pathName)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  4530
	if (realpath(__stringVal(pathName), nameBuffer)) {
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  4531
	    RETURN ( __MKSTRING(nameBuffer) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4532
	}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4533
    }
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4534
#else
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4535
# ifdef WIN32
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4536
    char nameBuffer[MAXPATHLEN + 1];
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4537
    char *pFinal;
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4538
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4539
    if (__isString(pathName)) {
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4540
      if (GetFullPathName(__stringVal(pathName), sizeof(nameBuffer),
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4541
			  nameBuffer, &pFinal)) {
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4542
	  RETURN ( __MKSTRING(nameBuffer) );
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4543
      }
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4544
    }
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4545
# endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4546
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4547
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4548
    ^ nil
359
claus
parents: 357
diff changeset
  4549
!
claus
parents: 357
diff changeset
  4550
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4551
timeOfLastAccess:aPathName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4552
    "return the time, when the file was last accessed.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4553
     For nonexistent files, nil is returned."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4554
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4555
    "could be implemented as:
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4556
	(self infoOf:aPathName) at:#accessed 
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  4557
    "
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  4558
    |osSeconds|
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4559
%{
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4560
    struct stat buf;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4561
    time_t mtime;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4562
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4563
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4564
    if (__isString(aPathName)) {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4565
	__BEGIN_INTERRUPTABLE__
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4566
	do {
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4567
	    ret = stat((char *) __stringVal(aPathName), &buf);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4568
	} while (ret < 0 && errno == EINTR);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4569
	__END_INTERRUPTABLE__
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4570
	if (ret < 0) {
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4571
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4572
	    RETURN (nil);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4573
	}
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4574
	osSeconds = __MKUINT(buf.st_atime);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4575
    }
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4576
%}.
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  4577
    osSeconds notNil ifTrue:[^ AbsoluteTime fromOSTime:(osSeconds * 1000)].
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4578
    ^ self primitiveFailed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4579
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4580
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4581
     OperatingSystem timeOfLastAccess:'/'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4582
    "
359
claus
parents: 357
diff changeset
  4583
!
claus
parents: 357
diff changeset
  4584
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4585
timeOfLastChange:aPathName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4586
    "return the time, when the file was last changed. 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4587
     For nonexistent files, nil is returned."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4588
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4589
    "could be implemented as:
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4590
	(self infoOf:aPathName) at:#modified
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  4591
    "
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  4592
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  4593
    |osSeconds|
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4594
%{
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4595
    struct stat buf;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4596
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4597
    time_t mtime;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4598
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4599
    if (__isString(aPathName)) {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4600
	__BEGIN_INTERRUPTABLE__
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4601
	do {
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4602
	    ret = stat((char *) __stringVal(aPathName), &buf);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4603
	} while (ret < 0 && errno == EINTR);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4604
	__END_INTERRUPTABLE__
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4605
	if (ret < 0) {
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4606
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4607
	    RETURN ( nil );
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4608
	}
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  4609
	osSeconds = __MKUINT(buf.st_mtime);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4610
    }
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4611
%}.
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  4612
    osSeconds notNil ifTrue:[^ AbsoluteTime fromOSTime:(osSeconds * 1000)].
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4613
    ^ self primitiveFailed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4614
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4615
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4616
     OperatingSystem timeOfLastChange:'/'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4617
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4618
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4619
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4620
typeOf:aPathName
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4621
    "return the type of a file as a symbol; for nonexistent files,
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4622
     nil is returned.
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4623
     Notice: for symbolic links, the type of the pointed-to file is returned."
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4624
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4625
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4626
     this could have been implemented as:
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4627
	(self infoOf:aPathName) at:#type 
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4628
     but for huge directory searches the code below is faster
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4629
    "
359
claus
parents: 357
diff changeset
  4630
1104
219a06128193 removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents: 1084
diff changeset
  4631
%{
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4632
    struct stat buf;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4633
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4634
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4635
    if (__isString(aPathName)) {
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4636
	__BEGIN_INTERRUPTABLE__
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4637
	do {
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4638
	    ret = stat((char *) __stringVal(aPathName), &buf);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4639
	} while (ret < 0 && errno == EINTR);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4640
	__END_INTERRUPTABLE__
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4641
	if (ret < 0) {
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4642
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4643
	    RETURN ( nil );
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4644
	}
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4645
	switch (buf.st_mode & S_IFMT) {
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4646
	    case S_IFDIR:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4647
		RETURN ( @symbol(directory) );
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4648
	    case S_IFREG:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4649
		RETURN ( @symbol(regular) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4650
#ifdef S_IFCHR
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4651
	    case S_IFCHR:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4652
		RETURN ( @symbol(characterSpecial) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4653
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4654
#ifdef S_IFBLK
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4655
	    case S_IFBLK:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4656
		RETURN ( @symbol(blockSpecial) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4657
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4658
#ifdef S_IFLNK
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4659
	    case S_IFLNK:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4660
		RETURN ( @symbol(symbolicLink) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4661
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4662
#ifdef S_IFSOCK
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4663
	    case S_IFSOCK:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4664
		RETURN ( @symbol(socket) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4665
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4666
#ifdef S_IFIFO
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4667
	    case S_IFIFO:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4668
		RETURN ( @symbol(fifo) );
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4669
#endif
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4670
	    default:
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4671
		RETURN ( @symbol(unknown) );
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  4672
	}
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4673
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4674
%}.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4675
    ^ self primitiveFailed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4676
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4677
    "
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4678
     OperatingSystem typeOf:'/'   
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4679
     OperatingSystem typeOf:'.'   
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4680
     OperatingSystem typeOf:'Make.proto' 
1858
cbbc11c01e10 return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents: 1845
diff changeset
  4681
     OperatingSystem typeOf:'resources/motif.style' 
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4682
    "
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4683
! !
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4684
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  4685
!OperatingSystem class methodsFor:'interrupts & signals'!
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  4686
10
claus
parents: 5
diff changeset
  4687
blockInterrupts
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4688
    "disable interrupt processing - if disabled, incoming
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4689
     interrupts will be registered and handled as soon as
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4690
     interrupts are reenabled by OperatingSystemclass>>unblockInterrupts.
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4691
     Returns the previous blocking status i.e. true if interrupts
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4692
     where already blocked. You need this information for proper
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4693
     unblocking, in case of nested block/unblock calls."
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4694
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4695
%{  /* NOCONTEXT */
710
10d86ca4c4a6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 704
diff changeset
  4696
    RETURN ( __BLOCKINTERRUPTS() );
10
claus
parents: 5
diff changeset
  4697
%}
claus
parents: 5
diff changeset
  4698
!
claus
parents: 5
diff changeset
  4699
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4700
defaultSignal:signalNumber
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4701
    "revert to the default action on arrival of a (Unix-)signal.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4702
     Dont confuse Unix signals with smalltalk signals.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4703
     WARNING: for some signals, it is no good idea to revert to default;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4704
     for example, the default for SIGINT (i.e. ^C) is to exit; while the
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4705
     default for SIGQUIT (^ \) is to dump core.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4706
     Also, NOTICE that signal numbers are not portable between unix
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4707
     systems - use OperatingSystem sigXXX to get the numeric value for
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4708
     a signal."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4709
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4710
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4711
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4712
    if (__isSmallInteger(signalNumber)) {
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4713
#ifdef SIG_DFL
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  4714
	signal(__intVal(signalNumber), SIG_DFL);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4715
	RETURN (self);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4716
#endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4717
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4718
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4719
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4720
     this error is triggered on non-integer argument
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4721
    "
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4722
    ^ self primitiveFailed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4723
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4724
    "you better save a snapshot image before trying this ..."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4725
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4726
     'if you hit ^C now, Smalltalk will exit immediately' printNewline.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4727
     OperatingSystem defaultSignal:(OperatingSystem sigINT).
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4728
     1 to:1000000 do:[:i| ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4729
     OperatingSystem enableSignal:(OperatingSystem sigINT).
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4730
     'normal ^C handling again.' printNewline
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4731
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4732
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4733
840
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  4734
disableChildSignalInterrupts
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  4735
    "disable childSignal interrupts 
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  4736
     (SIGCHLD, if the architecture supports it).
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  4737
     We have to set the signal back to default, because ignoring 
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  4738
     SIGCHLD breaks wait & co"
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  4739
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  4740
    ^ self defaultSignal:(self sigCHLD)
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  4741
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  4742
    "Created: 5.1.1996 / 15:45:28 / stefan"
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  4743
!
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  4744
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4745
disableIOInterruptsOn:fd
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4746
    "turn off IO interrupts for a filedescriptor"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4747
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4748
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4749
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4750
    int ret, flags, f;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4751
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4752
#if (defined(F_GETFL) && defined(F_SETFL) && defined(FASYNC)) || defined(SYSV4)
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4753
    if (__isSmallInteger(fd)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  4754
	f = __intVal(fd);
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4755
# if defined(SYSV4)
759
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 756
diff changeset
  4756
	ret = ioctl(f, I_SETSIG, 0);
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4757
# else /*! SYSV4*/
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4758
	flags = fcntl(f, F_GETFL, 0);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4759
	/*
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4760
	 * if already clear, there is no need for this syscall ...
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4761
	 */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4762
	if (flags & FASYNC) {
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4763
	    ret = fcntl(f, F_SETFL, flags & ~FASYNC);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4764
	    if (ret >= 0) ret = flags;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4765
	} else {
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4766
	    ret = flags;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4767
	}
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4768
# endif /* !SYSV4 */
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  4769
	RETURN ( __MKSMALLINT(ret) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4770
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4771
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4772
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4773
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4774
     this error is triggered on non-integer argument
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4775
     or if the OS does not support IO interrupts.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4776
    "
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4777
    ^ self primitiveFailed
10
claus
parents: 5
diff changeset
  4778
!
claus
parents: 5
diff changeset
  4779
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  4780
disableSignal:signalNumber
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4781
    "disable (Unix-) signal processing for signalNumber.
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4782
     Dont confuse Unix signals with smalltalk signals.
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  4783
     WARNING: for some signals, it is no good idea to disable
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4784
     them; for example, disabling the SIGINT signal turns off ^C
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  4785
     handling.
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4786
     Also, NOTICE that signal numbers are not portable between unix
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4787
     systems - use OperatingSystem sigXXX to get the numeric value for
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4788
     a signal.
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  4789
     Use only for fully debugged stand alone applications."
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  4790
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  4791
%{  /* NOCONTEXT */
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  4792
252
  4793
    if (__isSmallInteger(signalNumber)) {
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  4794
	int sigNo = __intVal(signalNumber);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4795
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4796
	if (sigNo == 0) {
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4797
	    RETURN (self);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4798
	}
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4799
#ifdef SIG_IGN
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4800
	signal(sigNo, SIG_IGN);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  4801
	RETURN (self);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4802
#endif
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  4803
    }
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4804
%}.
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4805
    "
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4806
     this error is triggered on non-integer argument
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4807
    "
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4808
    ^ self primitiveFailed
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4809
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4810
    "
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4811
     'now, ^C is totally ignored ...' printNewline.
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4812
     OperatingSystem disableSignal:(OperatingSystem sigINT).
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4813
     1 to:1000000 do:[:i| ].
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4814
     OperatingSystem enableSignal:(OperatingSystem sigINT).
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4815
     '^C handled again.' printNewline
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4816
    "
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4817
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4818
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4819
disableTimer
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4820
    "disable timer interrupts.
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4821
     WARNING: 
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4822
	the system will not operate correctly with timer interrupts
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  4823
	disabled, because no scheduling or timeouts are possible."
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4824
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4825
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4826
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4827
#if defined(WIN32)
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4828
    KillTimer(NULL, w32TimerId);
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4829
    w32TimerId = 0;
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4830
    RETURN (true);
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4831
#else
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4832
# if defined(ITIMER_REAL)
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4833
    struct itimerval dt;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4834
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4835
    dt.it_interval.tv_sec = 0;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4836
    dt.it_interval.tv_usec = 0;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4837
    dt.it_value.tv_sec = 0;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4838
    dt.it_value.tv_usec = 0;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4839
    setitimer(ITIMER_REAL, &dt, 0);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4840
    RETURN (true);
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4841
# endif /* ITIMER_REAL */
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  4842
#endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4843
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4844
.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4845
    ^ false
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4846
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4847
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4848
disableUserInterrupts
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4849
    "disable userInterrupt processing;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4850
     when disabled, no ^C processing takes place.
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4851
     WARNING:
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  4852
	 If at all, use this only for debugged stand-alone applications, since
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  4853
	 no exit to the debugger is possible with user interrupts disabled.
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  4854
	 We recommend setting up a handler for the signal instead of disabling it."
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4855
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4856
    self disableSignal:(self sigBREAK).
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4857
    self disableSignal:(self sigINT).
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4858
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4859
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4860
enableAbortInterrupts
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4861
    "enable abort signalhandling, and make it a regular signalInterrupt.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4862
     (the default will dump core and exit - which is not a good idea for
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4863
      end-user applications ...).
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4864
     This is especially useful, if linked-in C-libraries call abort() ..."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4865
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4866
    self enableSignal:(self sigABRT)
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4867
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4868
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4869
enableChildSignalInterrupts
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4870
    "enable childSignal interrupts 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4871
     (SIGCHLD, if the architecture supports it).
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4872
     After enabling, these signals will send the message 
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4873
     'childSignalInterrupt' to the ChildSignalInterruptHandler object."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4874
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4875
    self enableSignal:(self sigCHLD)
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4876
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4877
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4878
enableFpExceptionInterrupts
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4879
    "enable floating point exception interrupts (if the
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4880
     architecture supports it).
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4881
     After enabling, fpu-exceptions will send the message 
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4882
     'fpuExceptionInterrupt' to the FPUExceptionInterruptHandler object."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4883
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4884
    self enableSignal:(self sigFP)
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4885
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4886
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4887
enableHardSignalInterrupts
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4888
    "enable hard signal exception interrupts (trap, buserror & segm. violation).
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4889
     After enabling, these exceptions will send the message 
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4890
     'signalInterrupt' to the SignalInterruptHandler object."
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4891
855
2de3c842c687 dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  4892
    "/ leads to trouble ...
2de3c842c687 dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  4893
"/    self enableSignal:(self sigPIPE).
2de3c842c687 dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  4894
2de3c842c687 dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  4895
    "/ ... better to ignore them, and let it be handled as a writeErrorSignal.
2de3c842c687 dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  4896
    self disableSignal:(self sigPIPE).
2de3c842c687 dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  4897
1808
58ed32d318d4 handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  4898
    self enableSignal:(self sigILL).
640
be94dfc60eaa Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents: 630
diff changeset
  4899
    self enableSignal:(self sigBUS).
be94dfc60eaa Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents: 630
diff changeset
  4900
    self enableSignal:(self sigSEGV)
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4901
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4902
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4903
enableIOInterruptsOn:fd
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4904
    "turn on IO interrupts for a filedescriptor"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4905
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4906
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4907
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4908
    int ret, flags, f;
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  4909
#ifndef __signalIoInterrupt
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4910
    extern void __signalIoInterrupt();
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  4911
#endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4912
    static int firstCall = 1;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4913
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4914
#if (defined(F_GETFL) && defined(F_SETFL) && defined(FASYNC)) || defined(SYSV4)
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4915
/*
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4916
 * SIGIO/SIGPOLL - data available for I/O
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4917
 * (used to wake up waiting processes)
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4918
 */
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4919
#ifdef SIGIO
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4920
# define THESIGNAL SIGIO
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4921
#else
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4922
# ifdef SIGPOLL
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4923
#  define THESIGNAL SIGPOLL
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4924
# else
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4925
#  ifdef SIGURG
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4926
#   define THESIGNAL SIGURG
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4927
#  endif
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4928
# endif
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4929
#endif
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4930
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4931
    if (__isSmallInteger(fd)) {
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4932
	if (firstCall) {
762
cea705669628 ok, stefan was right: HAS_SIGACTION works
Claus Gittinger <cg@exept.de>
parents: 761
diff changeset
  4933
#ifdef HAS_SIGACTION
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4934
	    struct sigaction act;
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4935
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4936
	    /*
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4937
	     * Do not add SA_RESTART here. A signal can cause a
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4938
	     * thread switch, another thread can do a garbage collect
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4939
	     * and restarted system calls may write into old
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4940
	     * (collected) addresses.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  4941
	     */
1062
baa5827a7a40 Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents: 1060
diff changeset
  4942
baa5827a7a40 Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents: 1060
diff changeset
  4943
	    act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4944
	    sigemptyset(&act.sa_mask);
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4945
	    act.sa_handler = __signalIoInterrupt;
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4946
	    sigaction(THESIGNAL, &act, 0);
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4947
#else
766
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  4948
# ifdef HAS_SIGVEC
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  4949
	    struct sigvec vec;
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  4950
1062
baa5827a7a40 Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents: 1060
diff changeset
  4951
	    vec.sv_flags = SV_INTERRUPT;
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  4952
	    sigemptyset(&vec.sv_mask);
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  4953
	    vec.sv_handler = __signalIoInterrupt;
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  4954
	    sigvec(THESIGNAL, &vec, NULL);
766
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  4955
# else
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4956
	    signal(THESIGNAL, __signalIoInterrupt);
766
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  4957
# endif
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4958
#endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4959
	    firstCall = 0;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4960
	}
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4961
#undef THESIGNAL
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4962
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  4963
	f = __intVal(fd);
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4964
# if defined(SYSV4)
759
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 756
diff changeset
  4965
	ret = ioctl(f, I_SETSIG, S_INPUT | S_HIPRI | S_ERROR | S_RDNORM | S_RDBAND | S_MSG | S_HANGUP);
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4966
# else /*! SYSV4*/
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4967
	flags = fcntl(f, F_GETFL, 0);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4968
	/*
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4969
	 * if already set, there is no need for this syscall ...
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4970
	 */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4971
	if (flags & FASYNC) {
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4972
	    ret = flags;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4973
	} else {
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4974
	    ret = fcntl(f, F_SETFL, flags | FASYNC);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4975
	    if (ret >= 0) ret = flags;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4976
	}
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  4977
# endif /*!SYSV4*/
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  4978
	RETURN ( __MKSMALLINT(ret) );
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4979
    }
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4980
#endif
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4981
%}.
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4982
    "
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4983
     this error is triggered on non-integer argument
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4984
     or if the system does not support SIGIO
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4985
    "
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  4986
    ^ self primitiveFailed
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4987
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4988
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4989
enableQuitInterrupts
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4990
    "enable quitInterrupt (usually ^\) handling, and make it a userInterrupt.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4991
     (the default will dump core and exit - which is not a good idea for
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4992
      end-user applications ...)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  4993
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4994
    self enableSignal:(self sigQUIT)
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4995
!
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4996
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  4997
enableSignal:signalNumber
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4998
    "enable (Unix-)signal processing for signalNumber.
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  4999
     Dont confuse Unix signals with smalltalk signals.
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5000
     The signal will be delivered to one of the standard handlers
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5001
     (SIGINT, SIGQUIT, etc) or to a general handler, which
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5002
     sends #signalInterrupt:.
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5003
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5004
     NOTICE that signal numbers are not portable between unix
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5005
     systems - use OperatingSystem sigXXX to get the numeric value for
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5006
     a signal."
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5007
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5008
%{  /* NOCONTEXT */
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5009
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5010
#ifdef NSIG
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5011
# define SIG_LIMIT NSIG
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5012
#else
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5013
# ifdef SIGUSR2
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5014
#  define SIG_LIMIT SIGUSR2
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5015
# else
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5016
#  ifdef SIGUSR
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5017
#   define SIG_LIMIT SIGUSR
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5018
#  endif
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5019
# endif
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5020
#endif
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5021
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5022
#if defined(SIGPOLL) && !defined(SIGIO)
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5023
# define SIGIO SIGPOLL
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5024
#endif
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5025
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5026
#ifdef SIGCHLD
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5027
# define CHILD_SIGNAL   SIGCHLD
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5028
#else
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5029
# ifdef SIGCLD
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5030
#  define CHILD_SIGNAL  SIGCLD
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5031
# endif
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5032
#endif
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5033
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5034
    int sigNr;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5035
#if defined(SIGINT) || defined(SIGQUIT)
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5036
# ifndef __signalUserInterrupt
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5037
    extern void __signalUserInterrupt(SIGHANDLER_ARG);
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5038
# endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5039
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5040
#ifdef SIGFPE
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5041
# ifndef __signalFpExceptionInterrupt
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5042
    extern void __signalFpExceptionInterrupt(SIGHANDLER_ARG);
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5043
# endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5044
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5045
#ifdef SIGIO
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5046
# ifndef __signalIoInterrupt
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5047
    extern void __signalIoInterrupt(SIGHANDLER_ARG);
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5048
# endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5049
#endif
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5050
#ifdef CHILD_SIGNAL
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5051
# ifndef __signalChildInterrupt
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5052
    extern void __signalChildInterrupt(SIGHANDLER_ARG);
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5053
# endif
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5054
#endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5055
#ifdef SIGPIPE
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5056
# ifndef __signalPIPEInterrupt
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5057
    extern void __signalPIPEInterrupt(SIGHANDLER_ARG);
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5058
# endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5059
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5060
#ifdef SIGBUS
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5061
# ifndef __signalBUSInterrupt
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5062
    extern void __signalBUSInterrupt(SIGHANDLER_ARG);
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5063
# endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5064
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5065
#ifdef SIGSEGV
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5066
# ifndef __signalSEGVInterrupt
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5067
    extern void __signalSEGVInterrupt(SIGHANDLER_ARG);
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5068
# endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5069
#endif
1808
58ed32d318d4 handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  5070
#ifdef SIGILL
58ed32d318d4 handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  5071
# ifndef __signalTrapInterrupt
58ed32d318d4 handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  5072
    extern void __signalTrapInterrupt(SIGHANDLER_ARG);
58ed32d318d4 handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  5073
# endif
58ed32d318d4 handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  5074
#endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5075
#ifdef SIGALRM
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5076
# ifndef WIN32
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5077
#  ifndef __signalTimerInterrupt
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5078
    extern void __signalTimerInterrupt(SIGHANDLER_ARG);
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5079
#  endif
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5080
# endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5081
#endif
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5082
#ifndef __signalInterrupt
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5083
    extern void __signalInterrupt(SIGHANDLER_ARG);
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5084
#endif
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5085
    void (*handler)(SIGHANDLER_ARG);
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5086
252
  5087
    if (__isSmallInteger(signalNumber)
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  5088
     && ((sigNr = __intVal(signalNumber)) >= 0)
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5089
#ifdef SIG_LIMIT
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5090
     &&  (sigNr <= SIG_LIMIT)
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5091
#endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5092
    ) {
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5093
	/*
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5094
	 * standard signals are forced into standard handlers
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5095
	 * - all others go into general signalInterrupt
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5096
	 */
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5097
#if defined(SIGPOLL) && defined(SIGIO)
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5098
	if (sigNr == SIGPOLL)
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5099
	    sigNr = SIGIO;
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5100
#endif
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5101
	switch (sigNr) {
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5102
	    case 0:
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5103
		/* enabling a non-supported signal */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5104
		RETURN (self);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5105
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5106
#ifdef SIGBREAK
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5107
	    case SIGBREAK:
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5108
#endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5109
#ifdef SIGINT
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5110
	    case SIGINT:
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5111
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5112
#ifdef SIGQUIT
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5113
	    case SIGQUIT:
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5114
#endif
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5115
#if defined(SIGINT) || defined(SIGQUIT) || defined(SIGBREAK)
329
claus
parents: 322
diff changeset
  5116
		handler = __signalUserInterrupt;
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5117
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5118
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5119
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5120
#ifdef SIGFPE
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5121
	    case SIGFPE:
329
claus
parents: 322
diff changeset
  5122
		handler = __signalFpExceptionInterrupt;
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5123
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5124
#endif
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5125
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5126
#ifdef SIGPIPE
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5127
	    case SIGPIPE:
329
claus
parents: 322
diff changeset
  5128
		handler = __signalPIPEInterrupt;
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5129
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5130
#endif
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5131
#ifdef SIGBUS
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5132
	    case SIGBUS:
329
claus
parents: 322
diff changeset
  5133
		handler = __signalBUSInterrupt;
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5134
		break;
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5135
#endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5136
#ifdef SIGSEGV
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5137
	    case SIGSEGV:
329
claus
parents: 322
diff changeset
  5138
		handler = __signalSEGVInterrupt;
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5139
		break;
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5140
#endif
1982
8d4f97279e55 oops - SIGILL was never cought
Claus Gittinger <cg@exept.de>
parents: 1966
diff changeset
  5141
#ifdef SIGILL
8d4f97279e55 oops - SIGILL was never cought
Claus Gittinger <cg@exept.de>
parents: 1966
diff changeset
  5142
	    case SIGILL:
1808
58ed32d318d4 handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  5143
		handler = __signalTrapInterrupt;
58ed32d318d4 handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  5144
		break;
58ed32d318d4 handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents: 1799
diff changeset
  5145
#endif
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5146
#ifdef SIGIO
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5147
	    case SIGIO:
329
claus
parents: 322
diff changeset
  5148
		handler = __signalIoInterrupt;
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5149
		break;
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5150
#endif
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5151
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5152
#ifdef CHILD_SIGNAL
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5153
	    case CHILD_SIGNAL:
329
claus
parents: 322
diff changeset
  5154
		handler = __signalChildInterrupt;
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5155
		break;
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5156
#endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5157
#ifdef SIGALRM
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5158
# ifndef WIN32
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5159
	    case SIGALRM:
329
claus
parents: 322
diff changeset
  5160
		handler = __signalTimerInterrupt;
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5161
		break;
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5162
# endif
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  5163
#endif
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5164
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5165
	    default:
329
claus
parents: 322
diff changeset
  5166
		handler = __signalInterrupt;
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5167
		break;
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5168
	}
766
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  5169
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  5170
	{
762
cea705669628 ok, stefan was right: HAS_SIGACTION works
Claus Gittinger <cg@exept.de>
parents: 761
diff changeset
  5171
#ifdef HAS_SIGACTION
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  5172
	    struct sigaction act;
766
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  5173
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5174
	    /*
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5175
	     * Do not add SA_RESTART here. A signal can cause a
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5176
	     * thread switch, another thread can do a garbage collect
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5177
	     * and restarted system calls may write into old
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5178
	     * (collected) addresses.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5179
	     */
1062
baa5827a7a40 Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents: 1060
diff changeset
  5180
baa5827a7a40 Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents: 1060
diff changeset
  5181
	    act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
766
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  5182
	    sigemptyset(&act.sa_mask);
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  5183
	    act.sa_handler = handler;
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  5184
	    sigaction(sigNr, &act, 0);
213
3b56a17534fd *** empty log message ***
claus
parents: 204
diff changeset
  5185
#else
766
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  5186
# ifdef HAS_SIGVEC
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  5187
	    struct sigvec vec;
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  5188
1062
baa5827a7a40 Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents: 1060
diff changeset
  5189
	    vec.sv_flags = SV_INTERRUPT;
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  5190
	    sigemptyset(&vec.sv_mask);
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  5191
	    vec.sv_handler = handler;
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  5192
	    sigvec(sigNr, &vec, NULL);
766
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  5193
# else
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5194
	    (void) signal(sigNr, handler);
766
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  5195
# endif
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  5196
#endif
9d6cc2cc834e igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents: 765
diff changeset
  5197
	}
213
3b56a17534fd *** empty log message ***
claus
parents: 204
diff changeset
  5198
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5199
	/*
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5200
	 * maybe, we should return the old enable-status
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5201
	 * as boolean here ...
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5202
	 */
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  5203
	RETURN (self);
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5204
    }
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5205
%}.
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5206
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5207
    "
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5208
     this error is triggered on non-integer argument, or
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5209
     if the signal number is not in the valid range (1..NSIG)
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5210
    "
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  5211
    ^ self primitiveFailed
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  5212
!
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  5213
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5214
enableTimer:milliSeconds
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5215
    "trigger a timerInterrupt, to be signalled after some (real) time."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5216
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5217
%{  /* NOCONTEXT */
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5218
    int millis;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5219
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5220
    millis = __intVal(milliSeconds);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5221
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  5222
#if defined(ITIMER_REAL)
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5223
    {
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5224
	static int firstCall = 1;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5225
	struct itimerval dt;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5226
#ifndef __signalTimerInterrupt
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5227
	extern void __signalTimerInterrupt(SIGHANDLER_ARG);
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5228
#endif
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5229
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5230
	if (firstCall) {
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5231
# ifdef HAS_SIGACTION
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5232
	    struct sigaction act;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5233
1062
baa5827a7a40 Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents: 1060
diff changeset
  5234
	    act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5235
	    sigemptyset(&act.sa_mask);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5236
	    act.sa_handler = __signalTimerInterrupt;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5237
	    sigaction(SIGALRM, &act, 0);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5238
# else
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5239
#  ifdef HAS_SIGVEC
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5240
	    struct sigvec vec;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5241
1062
baa5827a7a40 Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents: 1060
diff changeset
  5242
	    vec.sv_flags = SV_INTERRUPT;
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5243
	    sigemptyset(&vec.sv_mask);
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5244
	    vec.sv_handler = __signalTimerInterrupt;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5245
	    sigvec(SIGALRM, &vec, NULL);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5246
#  else
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5247
	    signal(SIGALRM, __signalTimerInterrupt);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5248
#  endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5249
# endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5250
	    firstCall = 0;
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5251
	}
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5252
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5253
	dt.it_interval.tv_sec = 0;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5254
	dt.it_interval.tv_usec = 0;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5255
	dt.it_value.tv_sec = millis / 1000;
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5256
	dt.it_value.tv_usec = (millis % 1000) * 1000;  
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5257
	setitimer(ITIMER_REAL, &dt, 0);
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5258
	RETURN (true);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5259
    }
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  5260
#else
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5261
# ifdef WIN32
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5262
    {
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5263
	/*
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5264
	 * two mechanisms - which one to use ?
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5265
	 */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5266
#  ifdef USE_TimerProc
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5267
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5268
	extern VOID CALLBACK __win32TimerProc(HWND, UINT, UINT, DWORD);
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5269
	w32TimerId = SetTimer(NULL, 0, millis, __win32TimerProc);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5270
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5271
#  else /* USE_TimeProc */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5272
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5273
	extern void CALLBACK __win32TimeProc(UINT, UINT, DWORD, DWORD, DWORD, DWORD);
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5274
	timeSetEvent(millis, 5, (LPTIMECALLBACK)__win32TimeProc, 0, TIME_ONESHOT);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5275
#  endif
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5276
	RETURN (true);
640
be94dfc60eaa Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents: 630
diff changeset
  5277
    }
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5278
# endif /* WIN32 */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5279
#endif /* ITIMER_REAL */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5280
%}.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5281
    ^ false
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5282
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5283
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5284
enableUserInterrupts
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5285
    "enable userInterrupt (^C) handling;
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  5286
     when enabled, ^C in the terminal window will send the message
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  5287
     'userInterrupt' to the UserInterruptHandler object."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5288
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5289
    self enableSignal:(self sigINT).
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5290
    self enableSignal:(self sigBREAK).
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  5291
!
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  5292
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5293
interruptPending
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5294
    "return true, if an interrupt is pending. The returned value is
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5295
     invalid if interrupts are not currently blocked, since otherwise 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5296
     the interrupt is usually already handled before arriving here,
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5297
     or may be served while returning from here."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5298
2117
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5299
%{  /* NOCONTEXT */
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5300
    extern OBJ __INTERRUPTPENDING();
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5301
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5302
    RETURN ( __INTERRUPTPENDING() );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5303
%}        
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5304
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5305
2117
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5306
interruptsBlocked
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5307
    "return true, if interrupt handling is currently disabled;
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5308
     false otherwise."
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5309
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5310
%{  /* NOCONTEXT */
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5311
    extern OBJ __INTERRUPTS_BLOCKED();
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5312
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5313
    RETURN ( __INTERRUPTS_BLOCKED() );
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5314
%}
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5315
!
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  5316
704
42cb0141808d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
  5317
killProcess:processId
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  5318
    "kill a unix process.
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5319
     The process terminates immediately and has no chance to perform any cleanup actions.
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5320
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5321
     WARNING: in order to avoid zombie processes (on unix),
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5322
	      you have to fetch the processes exitstatus with
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5323
	      OperatingSystem>>getStatusOfProcess:aProcessId."
704
42cb0141808d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
  5324
42cb0141808d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
  5325
    self sendSignal:(self sigKILL) to:processId.
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  5326
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  5327
    "Modified: 28.12.1995 / 15:06:18 / stefan"
704
42cb0141808d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
  5328
!
42cb0141808d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
  5329
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5330
nameForSignal:aSignalNumber
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5331
    "for a given Unix signalnumber, return a descriptive string"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5332
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5333
    aSignalNumber == self sigHUP    ifTrue:[^ 'hangup'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5334
    aSignalNumber == self sigINT    ifTrue:[^ 'interrupt'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5335
    aSignalNumber == self sigKILL   ifTrue:[^ 'kill'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5336
    aSignalNumber == self sigQUIT   ifTrue:[^ 'quit'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5337
    aSignalNumber == self sigILL    ifTrue:[^ 'illegal instruction'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5338
    aSignalNumber == self sigTRAP   ifTrue:[^ 'trap'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5339
    aSignalNumber == self sigABRT   ifTrue:[^ 'abort'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5340
    aSignalNumber == self sigIOT    ifTrue:[^ 'iot trap'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5341
    aSignalNumber == self sigEMT    ifTrue:[^ 'emt trap'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5342
    aSignalNumber == self sigFP     ifTrue:[^ 'fp exception'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5343
    aSignalNumber == self sigBUS    ifTrue:[^ 'bus error'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5344
    aSignalNumber == self sigSEGV   ifTrue:[^ 'segmentation violation'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5345
    aSignalNumber == self sigSYS    ifTrue:[^ 'bad system call'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5346
    aSignalNumber == self sigPIPE   ifTrue:[^ 'broken pipe'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5347
    aSignalNumber == self sigALRM   ifTrue:[^ 'alarm timer'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5348
    aSignalNumber == self sigTERM   ifTrue:[^ 'termination'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5349
    aSignalNumber == self sigSTOP   ifTrue:[^ 'stop'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5350
    aSignalNumber == self sigTSTP   ifTrue:[^ 'tty stop'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5351
    aSignalNumber == self sigCONT   ifTrue:[^ 'continue'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5352
    aSignalNumber == self sigCHLD   ifTrue:[^ 'child death'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5353
    aSignalNumber == self sigTTIN   ifTrue:[^ 'background tty input'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5354
    aSignalNumber == self sigTTOU   ifTrue:[^ 'background tty output'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5355
    aSignalNumber == self sigIO     ifTrue:[^ 'io available'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5356
    aSignalNumber == self sigXCPU   ifTrue:[^ 'cpu time expired'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5357
    aSignalNumber == self sigXFSZ   ifTrue:[^ 'file size limit'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5358
    aSignalNumber == self sigVTALRM ifTrue:[^ 'virtual alarm timer'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5359
    aSignalNumber == self sigPROF   ifTrue:[^ 'profiling timer'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5360
    aSignalNumber == self sigWINCH  ifTrue:[^ 'winsize changed'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5361
    aSignalNumber == self sigLOST   ifTrue:[^ 'resource lost'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5362
    aSignalNumber == self sigUSR1   ifTrue:[^ 'user signal 1'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5363
    aSignalNumber == self sigUSR2   ifTrue:[^ 'user signal 2'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5364
    aSignalNumber == self sigMSG    ifTrue:[^ 'HFT message'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5365
    aSignalNumber == self sigPWR    ifTrue:[^ 'power-fail'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5366
    aSignalNumber == self sigPRE    ifTrue:[^ 'programming exception'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5367
    aSignalNumber == self sigGRANT  ifTrue:[^ 'HFT access wanted'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5368
    aSignalNumber == self sigRETRACT ifTrue:[^ 'HFT access relinquish'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5369
    aSignalNumber == self sigSOUND   ifTrue:[^ 'HFT sound complete'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5370
    aSignalNumber == self sigDANGER  ifTrue:[^ 'low on paging space'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5371
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5372
    "notice: many systems map SIGPOLL and/or SIGUSR onto SIGIO
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5373
	     therefore, keep SIGIO always above the two below" 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5374
    aSignalNumber == self sigPOLL   ifTrue:[^ 'io available'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5375
    aSignalNumber == self sigURG    ifTrue:[^ 'urgent'].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5376
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5377
    ^ 'unknown signal'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5378
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5379
    "
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5380
     OperatingSystem nameForSignal:9
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5381
     OperatingSystem nameForSignal:(OperatingSystem sigPOLL) 
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5382
    "
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5383
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5384
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5385
operatingSystemSignal:signalNumber
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5386
    "return the signal to be raised when an 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5387
     operatingSystem-signal occurs, or nil"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5388
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5389
    OSSignals notNil ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5390
	^ OSSignals at:signalNumber ifAbsent:[nil]
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5391
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5392
    ^ nil
10
claus
parents: 5
diff changeset
  5393
!
claus
parents: 5
diff changeset
  5394
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5395
operatingSystemSignal:signalNumber install:aSignal
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5396
    "install a signal to be raised when an operatingSystem-signal occurs"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5397
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5398
    OSSignals isNil ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5399
	OSSignals := Array new:32
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5400
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5401
    OSSignals at:signalNumber put:aSignal
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5402
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5403
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5404
sendSignal:signalNumber to:processId
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5405
    "send a unix signal to some process (maybe myself).
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5406
     Returns false if any error occurred, true otherwise.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5407
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5408
     Do not confuse UNIX signals with Smalltalk-Signals.
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5409
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5410
     WARNING: in order to avoid zombie processes (on unix),
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5411
	      you may have to fetch the processes exitstatus with
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5412
	      OperatingSystem>>getStatusOfProcess:aProcessId
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5413
	      if the signal terminates that process."
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5414
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5415
%{
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  5416
#ifndef MSDOS_LIKE
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5417
    if (__bothSmallInteger(signalNumber, processId)) {
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5418
	if (kill(__intVal(processId), __intVal(signalNumber)) < 0) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  5419
	    OperatingSystem_LastErrorNumber = __MKSMALLINT(errno);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5420
	    RETURN ( false );
216
a8abff749575 *** empty log message ***
claus
parents: 213
diff changeset
  5421
	}
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5422
	RETURN ( true );
10
claus
parents: 5
diff changeset
  5423
    }
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  5424
#endif
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5425
%}.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  5426
    "/
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  5427
    "/ either invalid argument (non-integers)
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  5428
    "/ or not supported by OS
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  5429
    "/
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  5430
    ^ self primitiveFailed
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5431
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5432
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5433
startSpyTimer
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  5434
    "trigger a spyInterrupt, to be signalled after some short (virtual) time.
359
claus
parents: 357
diff changeset
  5435
     This is used by the old MessageTally for profiling.
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  5436
     Should be changed to use real profiling timer if available.
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  5437
     On systems, where no virtual timer is available, use the real timer
359
claus
parents: 357
diff changeset
  5438
     (which is of course less correct).
claus
parents: 357
diff changeset
  5439
     OBSOLETE: the new messageTally runs as a high prio process, not using 
claus
parents: 357
diff changeset
  5440
	       spy interrupts."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5441
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5442
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5443
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5444
#ifndef __spyInterrupt
329
claus
parents: 322
diff changeset
  5445
    extern void __spyInterrupt();
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5446
#endif
10
claus
parents: 5
diff changeset
  5447
#if defined(ITIMER_VIRTUAL)
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5448
    struct itimerval dt;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5449
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  5450
# ifdef SIGVTALRM
329
claus
parents: 322
diff changeset
  5451
    signal(SIGVTALRM, __spyInterrupt);
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  5452
# else
329
claus
parents: 322
diff changeset
  5453
    signal(SIGALRM, __spyInterrupt);
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  5454
# endif
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  5455
348
claus
parents: 345
diff changeset
  5456
    dt.it_interval.tv_sec = 0;
claus
parents: 345
diff changeset
  5457
    dt.it_interval.tv_usec = 0;
claus
parents: 345
diff changeset
  5458
    dt.it_value.tv_sec = 0;
claus
parents: 345
diff changeset
  5459
    dt.it_value.tv_usec = 1000;   /* 1000 Hz */
claus
parents: 345
diff changeset
  5460
    setitimer(ITIMER_VIRTUAL, &dt, 0);
claus
parents: 345
diff changeset
  5461
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  5462
    RETURN (true);
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5463
#endif
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5464
%}
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  5465
.
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  5466
    ^ false
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5467
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5468
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5469
stopSpyTimer
359
claus
parents: 357
diff changeset
  5470
    "stop spy timing - disable spy timer.
claus
parents: 357
diff changeset
  5471
     OBSOLETE: the new messageTally runs as a high prio process, not using 
claus
parents: 357
diff changeset
  5472
	       spy interrupts."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5473
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5474
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5475
10
claus
parents: 5
diff changeset
  5476
#if defined(ITIMER_VIRTUAL)
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5477
    struct itimerval dt;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5478
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5479
    dt.it_interval.tv_sec = 0;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5480
    dt.it_interval.tv_usec = 0;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5481
    dt.it_value.tv_sec = 0;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5482
    dt.it_value.tv_usec = 0;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5483
    setitimer(ITIMER_VIRTUAL, &dt, 0);
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  5484
    RETURN (true);
10
claus
parents: 5
diff changeset
  5485
#endif
claus
parents: 5
diff changeset
  5486
%}
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  5487
.
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  5488
    ^ false
10
claus
parents: 5
diff changeset
  5489
!
claus
parents: 5
diff changeset
  5490
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  5491
terminateProcess:processId
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  5492
    "terminate a unix process.
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5493
     The process has a chance to do some cleanup.
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5494
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5495
     WARNING: in order to avoid zombie processes (on unix),
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5496
	      you may have to fetch the processes exitstatus with
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  5497
	      OperatingSystem>>getStatusOfProcess:aProcessId."
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  5498
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  5499
    self sendSignal:(self sigTERM) to:processId.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  5500
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  5501
    "Modified: 28.12.1995 / 15:05:37 / stefan"
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  5502
!
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  5503
1280
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  5504
terminateProcessGroup:processGroupId
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  5505
    "terminate a unix process group.
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  5506
     The process has a chance to do some cleanup.
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  5507
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  5508
     WARNING: in order to avoid zombie processes (on unix),
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5509
	      you may have to fetch the processes exitstatus with
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5510
	      OperatingSystem>>getStatusOfProcess:aProcessId."
1280
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  5511
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  5512
    self sendSignal:(self sigTERM) to:(processGroupId negated).
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  5513
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  5514
    "Modified: 28.12.1995 / 15:05:37 / stefan"
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  5515
    "Created: 23.4.1996 / 16:40:34 / stefan"
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  5516
!
b7ae6227f48b Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents: 1247
diff changeset
  5517
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5518
unblockInterrupts
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5519
    "enable interrupt processing - if any interrupts are pending,
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5520
     these will be handled immediately.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5521
     When unblocking interrupts, take care of nested block/unblock
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5522
     calls - you must only unblock after a blockcall if they where
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5523
     really not blocked before. See OperatingSystemclass>>blockInterrupts."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5524
%{
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5525
    __UNBLOCKINTERRUPTS();
1040
60e4c4bbbca2 return nil from unblockInterrupts (thats what the inlined code returns)
Claus Gittinger <cg@exept.de>
parents: 1034
diff changeset
  5526
    RETURN (nil);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5527
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5528
! !
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5529
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  5530
!OperatingSystem class methodsFor:'misc'!
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5531
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5532
exit
710
10d86ca4c4a6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 704
diff changeset
  5533
    "shutdown smalltalk immediately - this method does not return.
10d86ca4c4a6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 704
diff changeset
  5534
     Return 'good'-status (0) to the parent unix process."
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5535
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5536
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5537
    __mainExit(0);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5538
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5539
    "OperatingSystem exit - dont evaluate this"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5540
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5541
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5542
exit:exitCode
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5543
    "shutdown smalltalk immediately -
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5544
     returning an exit-code to the parent unix process."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5545
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5546
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5547
    int code = 1;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5548
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5549
    if (__isSmallInteger(exitCode)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  5550
	code = __intVal(exitCode);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5551
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5552
    __mainExit(code);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5553
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5554
    "OperatingSystem exit:1 - dont evaluate this"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5555
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5556
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5557
exitWithCoreDump
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5558
    "shutdown smalltalk immediately - dumping core.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5559
     This always returns 'bad'-status to the parent unix process.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5560
     Notice, that no cleanup is performed at all - you may have to
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5561
     manually remove any tempfiles.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5562
     Use this only for debugging ST/X itself"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5563
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5564
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5565
    abort();
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5566
%}
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5567
    "
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5568
     OperatingSystem exitWithCoreDump - dont evaluate this
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5569
    "
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5570
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5571
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5572
slowFork:aBoolean
1247
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  5573
    "set/clear the `avoid-fork-if-possible-because-its-slow' flag.
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  5574
     Only used internally on SYSV3 systems"
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  5575
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5576
    SlowFork := aBoolean
1247
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  5577
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  5578
    "Modified: 22.4.1996 / 13:13:09 / cg"
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5579
! !
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5580
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  5581
!OperatingSystem class methodsFor:'os queries'!
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5582
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5583
getCPUDefine
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5584
    "return a string which was used to identify this CPU type when STX was
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5585
     compiled, and which should be passed down when compiling methods.
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5586
     For example, on linux, this may be '-Di386'; on a vax, this would be '-Dvax'.
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5587
     This is normally not of interest to 'normal' users; however, it is passed
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5588
     down to the c-compiler when methods are incrementally compiled to machine code."
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5589
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5590
%{  /* NOCONTEXT */
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5591
#   ifndef CPU_DEFINE
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5592
#       define CPU_DEFINE "-DunknownCPU"
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5593
#   endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5594
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  5595
    RETURN ( __MKSTRING(CPU_DEFINE));
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5596
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5597
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5598
     OperatingSystem getCPUDefine
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5599
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5600
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5601
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5602
getCPUType
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5603
    "return a string giving the type of machine we're running on.
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5604
     Here, the machine for which ST/X was compiled is returned
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5605
     (i.e. for all x86's, the same i386 is returned).
759
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 756
diff changeset
  5606
     This may normally not be of any interest to you ..."
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5607
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5608
    |cpu|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5609
    
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5610
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5611
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5612
#   ifdef vax
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5613
#    define CPU_STRING "vax"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5614
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5615
#   ifdef mips
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5616
#    define CPU_STRING "mips"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5617
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5618
#   ifdef i386
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5619
#    define CPU_STRING "i386"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5620
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5621
#   ifdef ns32k
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5622
#    define CPU_STRING "ns32k"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5623
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5624
#   ifdef mc68k
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5625
#    define CPU_STRING "mc68k"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5626
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5627
#   ifdef mc88k
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5628
#    define CPU_STRING "mc88k"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5629
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5630
#   ifdef sparc
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5631
#    define CPU_STRING "sparc"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5632
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5633
#   ifdef hppa
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5634
#    define CPU_STRING "hppa"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5635
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5636
#   ifdef rs6000
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5637
#    define CPU_STRING "rs6000"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5638
#   endif
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5639
#   ifdef powerPC
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5640
#    define CPU_STRING "powerPC"
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5641
#   endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5642
#   ifdef alpha
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5643
#    define CPU_STRING "alpha"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5644
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5645
#   ifdef transputer
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5646
#    define CPU_STRING "transputer"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5647
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5648
#   ifdef ibm370
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5649
#    define CPU_STRING "ibm370"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5650
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5651
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5652
#   ifndef CPU_STRING
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5653
#    define CPU_STRING "unknown"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5654
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5655
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  5656
    cpu = __MKSTRING(CPU_STRING);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5657
#   undef CPU_STRING
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5658
%}.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5659
    ^ cpu
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5660
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5661
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5662
     OperatingSystem getCPUType
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5663
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5664
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5665
    "examples: are we running on a ss-10/solaris ?"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5666
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5667
     (OperatingSystem getCPUType = 'sparc') 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5668
     and:[OperatingSystem getOSType = 'solaris']
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5669
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5670
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5671
    "or on a pc/solaris ?"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5672
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5673
     (OperatingSystem getCPUType = 'i386')
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5674
     and:[OperatingSystem getOSType = 'solaris']
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5675
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5676
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5677
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5678
getCommandOutputFrom:aCommand
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5679
    "execute a simple command (such as hostname) and
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5680
     return the commands output as a string"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5681
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5682
    |p result|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5683
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5684
    ForkFailed ifFalse:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5685
	PipeStream openErrorSignal handle:[:ex |
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5686
	    ForkFailed := true.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5687
	    'OS: cannot fork/popen' errorPrintNL.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5688
	    ex return.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5689
	] do:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5690
	    p := PipeStream readingFrom:aCommand.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5691
	    p notNil ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5692
		result := p nextLine.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5693
		p close
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5694
	    ]
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5695
	]
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5696
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5697
    ^ result
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5698
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5699
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5700
getDomainName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5701
    "return the domain this host is in.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5702
     Notice:
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5703
	not all systems support this; on some, 'unknown' is returned."
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5704
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5705
    |name|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5706
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5707
    DomainName notNil ifTrue:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5708
	^ DomainName
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5709
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5710
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5711
%{  /* STACK: 2048 */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5712
#if defined(HAS_GETDOMAINNAME)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5713
    char buffer[128];
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5714
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5715
    if (getdomainname(buffer, sizeof(buffer)) == 0) {
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  5716
	name = __MKSTRING(buffer);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5717
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5718
#else
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5719
# if defined(HAS_UNAME) && defined(HAS_UTS_DOMAINNAME)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5720
    struct utsname ubuff;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5721
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5722
    if (uname(&ubuff) >= 0) {
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  5723
	name = __MKSTRING(ubuff.domainname);
1433
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  5724
    }
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  5725
# else
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  5726
#  if defined(HAS_SYSINFO) && defined(SI_SRPC_DOMAIN)
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  5727
    char buffer[256];
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  5728
    int ret;
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  5729
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  5730
    if ((ret = sysinfo(SI_SRPC_DOMAIN, buffer, sizeof(buffer))) >= 0 && ret <= sizeof(buffer)) {
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  5731
	name = __MKSTRING(buffer);
1433
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  5732
    }
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  5733
#  endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5734
# endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5735
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5736
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5737
    name isNil ifTrue:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5738
	name := self getEnvironment:'DOMAIN'.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5739
	name isNil ifTrue:[
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5740
	    name := self getCommandOutputFrom:'domainname'
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5741
	]
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5742
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5743
    name isNil ifTrue:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5744
	'OS: cannot find out domainname' errorPrintNL.
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  5745
	name := 'unknown'.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5746
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5747
    DomainName := name.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5748
    ^ name
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5749
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5750
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5751
     OperatingSystem getDomainName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5752
    "
1433
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  5753
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  5754
    "Modified: 26.4.1996 / 10:04:54 / stefan"
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5755
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5756
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5757
getEnvironment:aStringOrSymbol
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5758
    "get an environment string"
10
claus
parents: 5
diff changeset
  5759
claus
parents: 5
diff changeset
  5760
%{  /* NOCONTEXT */
claus
parents: 5
diff changeset
  5761
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5762
    char *env;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5763
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5764
    if (__isString(aStringOrSymbol) || __isSymbol(aStringOrSymbol)) {
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5765
#ifdef WIN32
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5766
	char buff[512];
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5767
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5768
	env = NULL;
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5769
	if (GetEnvironmentVariable(__stringVal(aStringOrSymbol),
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5770
				   buff,
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5771
				   sizeof(buff)-1)) {
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5772
	    env = buff;
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5773
	}
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5774
#else
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  5775
	env =  (char *)getenv(__stringVal(aStringOrSymbol));
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  5776
#endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5777
	if (env) {
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  5778
	    RETURN ( __MKSTRING(env) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5779
	}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5780
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5781
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5782
.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5783
    ^ nil
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5784
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5785
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5786
     OperatingSystem getEnvironment:'LANG'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5787
     OperatingSystem getEnvironment:'LOGIN'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5788
     OperatingSystem getEnvironment:'HOME'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5789
     OperatingSystem getEnvironment:'NNTPSERVER'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5790
     OperatingSystem getEnvironment:'MAIL'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5791
     OperatingSystem getEnvironment:'PATH'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5792
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5793
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5794
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5795
getHostName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5796
    "return the hostname we are running on - if there is
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5797
     a HOST environment variable, we are much faster here ...
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5798
     Notice:
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5799
	not all systems support this; on some, 'unknown' is returned."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5800
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5801
    |name|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5802
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5803
    HostName notNil ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5804
	^ HostName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5805
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5806
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5807
%{  /* STACK: 2048 */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5808
#if defined(HAS_GETHOSTNAME)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5809
    char buffer[128];
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5810
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5811
    if (gethostname(buffer, sizeof(buffer)) == 0) {
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  5812
	name = __MKSTRING(buffer);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5813
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5814
#else
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5815
# if defined(HAS_UNAME)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5816
    struct utsname ubuff;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5817
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5818
    if (uname(&ubuff) >= 0) {
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  5819
	name = __MKSTRING(ubuff.nodename);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5820
    }
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5821
# else
1702
777b74f65c7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  5822
#  if defined(HAS_SYSINFO) && defined(SI_HOSTNAME)
777b74f65c7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  5823
    char buffer[256];
777b74f65c7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  5824
    int ret;
777b74f65c7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  5825
 
777b74f65c7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  5826
    if ((ret = sysinfo(SI_HOSTNAME, buffer, sizeof(buffer))) >= 0 && ret <= sizeof(buffer)) {
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  5827
	name = __MKSTRING(buffer);
1702
777b74f65c7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  5828
    }
777b74f65c7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  5829
#  else
777b74f65c7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  5830
#   ifdef WIN32
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5831
    char buffer[128];
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5832
    int buffSize = sizeof(buffer);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5833
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5834
    if (GetComputerName(buffer, &buffSize) == TRUE) {
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  5835
	name = __MKSTRING(buffer);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5836
    }
1702
777b74f65c7e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  5837
#   endif
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  5838
#  endif
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  5839
# endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5840
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5841
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5842
    name isNil ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5843
	name := self getEnvironment:'HOST'.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5844
	name isNil ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5845
	    name := self getCommandOutputFrom:'hostname'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5846
	]
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5847
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5848
    name isNil ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5849
	'OS: cannot find out hostname' errorPrintNL.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5850
	name := 'unknown'.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5851
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5852
    HostName := name.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5853
    ^ name
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5854
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5855
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5856
     OperatingSystem getHostName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5857
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5858
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  5859
1034
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5860
getLocaleInfo
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5861
    "return a dictionary filled with values from the locale information;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5862
     Not all fields may be present, depending on the OS's setup and capabilities.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5863
     Possible fields are:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5864
	decimalPoint                    <String>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5865
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5866
	thousandsSep                    <String>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5867
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5868
	internationalCurrencySymbol     <String>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5869
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5870
	currencySymbol                  <String>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5871
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5872
	monetaryDecimalPoint            <String>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5873
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5874
	monetaryThousandsSeparator      <String>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5875
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5876
	positiveSign                    <String>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5877
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5878
	negativeSign                    <String>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5879
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5880
	internationalFractionalDigits   <Integer>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5881
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5882
	fractionalDigits                <Integer>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5883
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5884
	positiveSignPrecedesCurrencySymbol      <Boolean>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5885
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5886
	negativeSignPrecedesCurrencySymbol      <Boolean>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5887
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5888
	positiveSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5889
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5890
	negativeSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5891
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5892
	positiveSignPosition                            <Symbol>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5893
							one of: #parenthesesAround, 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5894
								#signPrecedes, 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5895
								#signSuceeds, 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5896
								#signPrecedesCurrencySymbol,
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5897
								#signSuceedsCurrencySymbol
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5898
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5899
	negativeSignPosition                            <like above>
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5900
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5901
     it is up to the application to deal with undefined values.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5902
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5903
     Notice, that (for now), the system does not use this information;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5904
     it should be used by applications as required.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5905
    "
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5906
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5907
    |info val|
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5908
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5909
    LocaleInfo notNil ifTrue:[
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5910
	"/ return the internal info; useful on systems which do not
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5911
	"/ support this.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5912
	^ LocaleInfo
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5913
    ].
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5914
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5915
    info := IdentityDictionary new.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5916
%{
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5917
    char *decimalPoint;         /* something like "." (US) or "," (german) */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5918
    char *thousandsSep;         /* something like "," (US) or "." (german) */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5919
    char *intCurrencySymbol;    /* international currency symbol; something like "USD "  "DM  " */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5920
    char *currencySymbol;       /* local currency symbol;         something like "USD "  "DM  " */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5921
    char *monDecimalPoint;      /* money: decimal point */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5922
    char *monThousandsSep;      /* money: thousands sep */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5923
    char *positiveSign;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5924
    char *negativeSign;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5925
    int   intFractDigits;       /* money: international digits after decPoint */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5926
    int   fractDigits;          /* money: local digits after decPoint */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5927
    int   csPosPrecedes;        /* money: 1 if currency symbol precedes a positive value; 0 if it sceeds */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5928
    int   csNegPrecedes;        /* money: 1 if currency symbol precedes a negative value; 0 if it sceeds */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5929
    int   csPosSepBySpace;      /* money: 1 if currency symbol should be separated by a space from a positive value; 0 if no space */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5930
    int   csNegSepBySpace;      /* money: 1 if currency symbol should be separated by a space from a negative value; 0 if no space */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5931
    int   csPosSignPosition;    /* money: 0: ()'s around the value & currency symbol */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5932
    int   csNegSignPosition;    /*        1: sign precedes the value & currency symbol */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5933
				/*        2: sign succeeds the value & currency symbol */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5934
				/*        3: sign immediately precedes the currency symbol */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5935
				/*        4: sign immediately suceeds the currency symbol */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5936
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5937
#if defined(HAS_LOCALECONV)
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5938
    struct lconv *conf;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5939
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5940
    conf = localeconv();
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5941
    if (conf) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5942
	decimalPoint = conf->decimal_point;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5943
	thousandsSep = conf->thousands_sep;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5944
	intCurrencySymbol = conf->int_curr_symbol;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5945
	currencySymbol = conf->currency_symbol;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5946
	monDecimalPoint = conf->mon_decimal_point;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5947
	monThousandsSep = conf->mon_thousands_sep;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5948
	positiveSign = conf->positive_sign;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5949
	negativeSign = conf->negative_sign;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5950
	intFractDigits = conf->int_frac_digits;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5951
	fractDigits = conf->frac_digits;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5952
	csPosPrecedes = conf->p_cs_precedes; 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5953
	csNegPrecedes = conf->n_cs_precedes; 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5954
	csPosSepBySpace = conf->p_sep_by_space; 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5955
	csNegSepBySpace = conf->n_sep_by_space; 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5956
	csPosSignPosition = conf->p_sign_posn;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5957
	csNegSignPosition = conf->n_sign_posn;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5958
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5959
#else
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5960
    decimalPoint = (char *)0;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5961
    thousandsSep = (char *)0;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5962
    intCurrencySymbol = (char *)0;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5963
    currencySymbol = (char *)0;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5964
    monDecimalPoint = (char *)0;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5965
    monThousandsSep = (char *)0;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5966
    positiveSign =  (char *)0;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5967
    negativeSign =(char *)0;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5968
    intFractDigits = -1;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5969
    fractDigits = -1;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5970
    csPosPrecedes = -1; 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5971
    csNegPrecedes = -1; 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5972
    csPosSepBySpace = -1; 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5973
    csNegSepBySpace = -1; 
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5974
    csPosSignPosition = -1;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5975
    csNegSignPosition = -1;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5976
#endif
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5977
    if (decimalPoint) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5978
	val = __MKSTRING(decimalPoint);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5979
	__AT_PUT_(info, @symbol(decimalPoint), val);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5980
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5981
    if (thousandsSep) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5982
	val = __MKSTRING(thousandsSep);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5983
	__AT_PUT_(info, @symbol(thousandsSeparator), val);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5984
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5985
    if (intCurrencySymbol) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5986
	val = __MKSTRING(intCurrencySymbol);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5987
	__AT_PUT_(info, @symbol(internationCurrencySymbol), val);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5988
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5989
    if (currencySymbol) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5990
	val = __MKSTRING(currencySymbol);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5991
	__AT_PUT_(info, @symbol(currencySymbol), val);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5992
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5993
    if (monDecimalPoint) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5994
	val = __MKSTRING(monDecimalPoint);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5995
	__AT_PUT_(info, @symbol(monetaryDecimalPoint), val);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5996
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5997
    if (monThousandsSep) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5998
	val = __MKSTRING(monThousandsSep);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  5999
	__AT_PUT_(info, @symbol(monetaryThousandsSeparator), val);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6000
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6001
    if (positiveSign) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6002
	val = __MKSTRING(positiveSign);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6003
	__AT_PUT_(info, @symbol(positiveSign), val);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6004
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6005
    if (negativeSign) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6006
	val = __MKSTRING(negativeSign);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6007
	__AT_PUT_(info, @symbol(negativeSign), val);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6008
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6009
    if (intFractDigits >= 0) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6010
	__AT_PUT_(info, @symbol(internationalFractionalDigits),  __MKSMALLINT(intFractDigits));
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6011
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6012
    if (fractDigits >= 0) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6013
	__AT_PUT_(info, @symbol(fractionalDigits),  __MKSMALLINT(fractDigits));
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6014
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6015
    if (csPosPrecedes >= 0) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6016
	if (csPosPrecedes == 0) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6017
	    val = false;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6018
	} else {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6019
	    val = true;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6020
	}
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6021
	__AT_PUT_(info, @symbol(positiveSignPrecedesCurrencySymbol), val );
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6022
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6023
    if (csNegPrecedes >= 0) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6024
	if (csNegPrecedes == 0) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6025
	    val = false;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6026
	} else {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6027
	    val = true;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6028
	}
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6029
	__AT_PUT_(info, @symbol(negativeSignPrecedesCurrencySymbol), val );
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6030
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6031
    if (csPosSepBySpace >= 0) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6032
	if (csPosSepBySpace == 0) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6033
	    val = false;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6034
	} else {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6035
	    val = true;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6036
	}
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6037
	__AT_PUT_(info, @symbol(positiveSignSeparatedBySpaceFromCurrencySymbol), val);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6038
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6039
    if (csNegSepBySpace >= 0) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6040
	if (csNegSepBySpace == 0) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6041
	    val = false;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6042
	} else {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6043
	    val = true;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6044
	}
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6045
	__AT_PUT_(info, @symbol(negativeSignSeparatedBySpaceFromCurrencySymbol), val);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6046
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6047
    switch (csPosSignPosition) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6048
	case 0:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6049
	    val = @symbol(parenthesesAround);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6050
	    break;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6051
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6052
	case 1:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6053
	    val = @symbol(signPrecedes);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6054
	    break;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6055
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6056
	case 2:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6057
	    val = @symbol(signSuceeds);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6058
	    break;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6059
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6060
	case 3:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6061
	    val = @symbol(signPrecedesCurrencySymbol);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6062
	    break;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6063
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6064
	case 4:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6065
	    val = @symbol(signSuceedsCurrencySymbol);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6066
	    break;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6067
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6068
	default:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6069
	    val = nil;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6070
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6071
    if (val != nil) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6072
	__AT_PUT_(info, @symbol(positiveSignPosition), val);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6073
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6074
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6075
    switch (csNegSignPosition) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6076
	case 0:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6077
	    val = @symbol(parenthesesAround);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6078
	    break;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6079
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6080
	case 1:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6081
	    val = @symbol(signPrecedes);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6082
	    break;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6083
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6084
	case 2:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6085
	    val = @symbol(signSuceeds);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6086
	    break;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6087
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6088
	case 3:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6089
	    val = @symbol(signPrecedesCurrencySymbol);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6090
	    break;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6091
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6092
	case 4:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6093
	    val = @symbol(signSuceedsCurrencySymbol);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6094
	    break;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6095
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6096
	default:
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6097
	    val = nil;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6098
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6099
    if (val != nil) {
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6100
	__AT_PUT_(info, @symbol(negativeSignPosition), val);
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6101
    }
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6102
%}.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6103
    ^ info
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6104
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6105
    "
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6106
     OperatingSystem getLocaleInfo
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6107
    "
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6108
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6109
    "Created: 23.12.1995 / 14:19:20 / cg"
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6110
!
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6111
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6112
getOSDefine
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6113
    "return a string which was used to identify this machine when stx was
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6114
     compiled, and which should be passed down when compiling methods.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6115
     For example, on linux, this is '-DLINUX'."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6116
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6117
%{  /* NOCONTEXT */
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6118
#ifdef WIN32
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6119
# ifndef OS_DEFINE
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6120
#  define OS_DEFINE "-DWIN32"
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6121
# endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6122
#endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6123
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6124
#ifndef OS_DEFINE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6125
# define OS_DEFINE "-DunknownOS"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6126
#endif
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6127
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  6128
    RETURN ( __MKSTRING(OS_DEFINE));
1987
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
  6129
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
  6130
#undef OS_DEFINE
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6131
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6132
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6133
     OperatingSystem getOSDefine
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6134
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6135
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6136
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6137
getOSType
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6138
    "return a string giving the type of OS we're running on.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6139
     This can be used to adapt programs to certain environment
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6140
     differences (for example: mail-lock strategy ...)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6141
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6142
    |os|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6143
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6144
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6145
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6146
#   ifdef MSDOS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6147
#    define OS_STRING "msdos"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6148
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6149
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6150
#   ifdef WIN32
1987
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
  6151
#    define OS_STRING "win32"
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6152
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6153
#   endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6154
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6155
#   ifdef MSWINDOWS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6156
#    define OS_STRING "mswindows"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6157
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6158
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6159
#   ifdef NT
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6160
#    define OS_STRING "nt"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6161
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6162
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6163
#   ifdef VMS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6164
#    define OS_STRING "vms"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6165
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6166
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6167
#   ifdef MVS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6168
#    define OS_STRING "mvs"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6169
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6170
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6171
#   ifdef OS2
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6172
#    define OS_STRING "os2"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6173
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6174
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6175
#   ifdef sinix
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6176
#    define OS_STRING "sinix"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6177
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6178
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6179
#   ifdef ultrix
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6180
#    define OS_STRING "ultrix"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6181
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6182
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6183
#   ifdef sco
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6184
#    define OS_STRING "sco"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6185
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6186
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6187
#   ifdef hpux
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6188
#    define OS_STRING "hpux"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6189
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6190
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6191
#   ifdef LINUX
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6192
#    define OS_STRING "linux"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6193
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6194
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6195
#   ifdef sunos
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6196
#    define OS_STRING "sunos"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6197
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6198
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6199
#   ifdef solaris
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6200
#    define OS_STRING "solaris"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6201
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6202
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6203
#   ifdef IRIS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6204
#    define OS_STRING "irix"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6205
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6206
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6207
#   ifdef aix
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6208
#    define OS_STRING "aix"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6209
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6210
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6211
#   ifdef realIX
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6212
#    define OS_STRING "realIX"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6213
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6214
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6215
    /*
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6216
     * no concrete info; become somewhat vague ...
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6217
     */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6218
#   ifndef OS_STRING
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6219
#    ifdef MACH
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6220
#     define OS_STRING "mach"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6221
#    endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6222
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6223
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6224
#   ifndef OS_STRING
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6225
#    ifdef BSD
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6226
#     define OS_STRING "bsd"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6227
#    endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6228
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6229
#    ifdef SYSV
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6230
#     ifdef SYSV3
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6231
#      define OS_STRING "sys5_3"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6232
#     else
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6233
#      ifdef SYSV4
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6234
#       define OS_STRING "sys5_4"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6235
#      else
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6236
#       define OS_STRING "sys5"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6237
#      endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6238
#     endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6239
#    endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6240
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6241
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6242
    /*
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6243
     * become very vague ...
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6244
     */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6245
#   ifndef OS_STRING
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6246
#    ifdef POSIX
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6247
#     define OS_STRING "posix"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6248
#    endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6249
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6250
#   ifndef OS_STRING
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6251
#    ifdef UNIX
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6252
#     define OS_STRING "unix"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6253
#    endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6254
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6255
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6256
#   ifndef OS_STRING
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6257
#    define OS_STRING "unknown"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6258
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6259
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  6260
    os = __MKSTRING(OS_STRING);
1987
8249e9134622 win32 changes
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
  6261
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6262
#   undef OS_STRING
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6263
%}.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6264
    ^ os
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6265
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6266
    "OperatingSystem getOSType"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6267
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6268
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6269
getProcessId
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6270
    "return the (unix-)processId"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6271
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6272
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6273
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6274
    int pid = 0;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6275
#ifdef UNIX_LIKE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6276
    pid = getpid();
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  6277
#else
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  6278
# ifdef WIN32
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  6279
    pid = GetCurrentProcessId() & 0x3FFFFFFF;
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  6280
# endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6281
#endif
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  6282
    RETURN ( __MKSMALLINT(pid) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6283
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6284
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6285
     OperatingSystem getProcessId
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6286
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6287
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6288
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6289
getSystemID
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6290
    "if supported by the OS, return the systemID;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6291
     a unique per machine identification.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6292
     WARNING:
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6293
	not all systems support this; on some, 'unknown' is returned."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6294
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6295
%{  /* NO_CONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6296
#if defined(IRIX5) && !defined(HAS_GETHOSTID)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6297
    char idBuffer[MAXSYSIDSIZE];
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6298
    int retVal;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6299
    OBJ arr;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6300
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6301
    if ((retVal = syssgi(SGI_SYSID, idBuffer)) == 0) {
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6302
	arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(MAXSYSIDSIZE);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6303
	bcopy(idBuffer, __ByteArrayInstPtr(arr)->ba_element, MAXSYSIDSIZE);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6304
	RETURN (arr);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6305
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6306
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6307
#if defined(HAS_GETHOSTID)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6308
    int runningId;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6309
    OBJ arr;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6310
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6311
    runningId = gethostid();
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6312
    arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(4);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6313
    *(int *)(__ByteArrayInstPtr(arr)->ba_element) = runningId;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6314
    RETURN (arr);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6315
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6316
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6317
    ^ 'unknown'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6318
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6319
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6320
     OperatingSystem getSystemID
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6321
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6322
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6323
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6324
getSystemInfo
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6325
    "return info on the system weare running on.
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6326
     If the system supports the uname system call, that info is returned;
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6327
     otherwise, some simulated info is returned.
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6328
 
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6329
     WARNING:
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6330
       Do not depend on the amount and contents of the returned information, some
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6331
       systems may return more/less than others. Also, the contents depends on the
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6332
       OS, for example, linux returns 'ix86', while WIN32 returns 'x86'.
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6333
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6334
       This method is mainly provided to augment error reports with some system
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6335
       information. 
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6336
       (in case of system/version specific OS errors, conditional workarounds and patches
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  6337
	may be based upon this info)
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6338
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6339
     The returned info may (or may not) contain:
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6340
	#system -> some operating system identification (irix, Linux, nt, win32s ...) 
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6341
	#version -> OS version (some os version identification)
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6342
	#release -> OS release (3.5, 1.2.1 ...)
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6343
	#node   -> some host identification (hostname)
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6344
	#domain  -> domain name (hosts domain)
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6345
	#machine -> type of machine (i586, mips ...)
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6346
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6347
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6348
    |sys node rel ver mach dom mtyp brel info|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6349
1060
119d45f975e1 increased getSystemInfos stack - just to make certain
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  6350
%{  /* STACK: 4096 */
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6351
#if defined(HAS_UNAME)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6352
    struct utsname ubuff;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6353
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6354
    if (uname(&ubuff) >= 0) {
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  6355
	sys  = __MKSTRING(ubuff.sysname);
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  6356
	node = __MKSTRING(ubuff.nodename);
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  6357
	rel  = __MKSTRING(ubuff.release);
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  6358
	ver  = __MKSTRING(ubuff.version);
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  6359
	mach = __MKSTRING(ubuff.machine);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6360
# ifdef HAS_UTS_DOMAINNAME
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  6361
	dom  = __MKSTRING(ubuff.domainname);
1675
b4cd81adda85 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1666
diff changeset
  6362
# else
b4cd81adda85 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1666
diff changeset
  6363
#  if defined(HAS_GETDOMAINNAME)
b4cd81adda85 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1666
diff changeset
  6364
	{
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  6365
	    char buffer[128];
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  6366
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  6367
	    if (getdomainname(buffer, sizeof(buffer)) == 0) {
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  6368
		dom = __MKSTRING(buffer);
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  6369
	    }
1675
b4cd81adda85 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1666
diff changeset
  6370
	}
b4cd81adda85 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1666
diff changeset
  6371
#  endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6372
# endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6373
    }
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6374
#else /* no uname */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6375
# ifdef WIN32 
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6376
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6377
    char vsnBuffer[32];
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6378
    char *s;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6379
    int winVer;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6380
    DWORD vsn;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6381
    SYSTEM_INFO sysInfo;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6382
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6383
    vsn = GetVersion();
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6384
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6385
    if (HIWORD(vsn) & 0x8000) {
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6386
	s = "win32s";
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6387
    } else {
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  6388
	s = "nt";
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6389
    }
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  6390
    sys = __MKSTRING(s);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6391
    winVer = LOWORD(vsn);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6392
    sprintf(vsnBuffer, "%d.%d", LOBYTE(winVer), HIBYTE(winVer));
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  6393
    rel = __MKSTRING(vsnBuffer);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6394
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6395
    GetSystemInfo(&sysInfo);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6396
    if (sysInfo.dwProcessorType) {
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  6397
	sprintf(vsnBuffer, "%d", sysInfo.dwProcessorType);
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  6398
	mach = __MKSTRING(vsnBuffer);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6399
    }
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6400
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6401
# endif /* WIN32 */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6402
#endif /* no uname */
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6403
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6404
    sys isNil ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6405
	sys := self getSystemType.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6406
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6407
    node isNil ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6408
	node := self getHostName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6409
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6410
    dom isNil ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6411
	dom := self getDomainName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6412
    ].
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6413
    mach isNil ifTrue:[
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6414
	mach := self getCPUType
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6415
    ].
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6416
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6417
    info := IdentityDictionary new.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6418
    info at:#system put:sys.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6419
    info at:#node put:node.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6420
    rel notNil ifTrue:[info at:#release put:rel].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6421
    ver notNil ifTrue:[info at:#version put:ver].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6422
    mach notNil ifTrue:[info at:#machine put:mach].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6423
    dom notNil ifTrue:[info at:#domain put:dom].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6424
    ^ info
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6425
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6426
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6427
     OperatingSystem getSystemInfo
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6428
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6429
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6430
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6431
getSystemType
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6432
    "return a string giving the type of system we're running on.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6433
     This is almost the same as getOSType, but the returned string
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6434
     is slightly different for some systems (i.e. iris vs. irix).
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6435
     Dont depend on this - use getOSType. I dont really see a point
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6436
     here ... 
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6437
     (except for slight differences between next/mach and other machs)"
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6438
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6439
    |sys|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6440
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6441
%{
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6442
#   ifdef NEXT
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6443
#    define SYS_STRING "next"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6444
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6445
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6446
#   ifdef IRIS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6447
#    define SYS_STRING "iris"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6448
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6449
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6450
#   ifdef WIN32 
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6451
#    define SYS_STRING  "win32"
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6452
#   endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6453
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6454
#   ifdef SYS_STRING
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  6455
     sys = __MKSTRING(SYS_STRING);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6456
#    undef SYS_STRING
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6457
#   endif
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6458
%}.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6459
    sys isNil ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6460
	^ self getOSType
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6461
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6462
    ^ sys
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6463
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6464
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6465
     OperatingSystem getSystemType
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6466
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6467
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6468
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6469
isBSDlike
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6470
    "return true, if the OS we're running on is a 'real' unix."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6471
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6472
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6473
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6474
#if defined(BSD) || defined(MACH) || defined(SYSV4)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6475
    RETURN ( true );
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  6476
#endif
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6477
%}.
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  6478
    ^ false
10
claus
parents: 5
diff changeset
  6479
!
claus
parents: 5
diff changeset
  6480
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6481
isMSDOSlike
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6482
    "return true, if the OS we're running on is dos like 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6483
     (in contrast to unix-like)."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6484
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6485
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6486
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6487
#if defined(MSDOS_LIKE)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6488
    RETURN ( true );
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6489
#endif
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6490
%}.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6491
    ^ false
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6492
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6493
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6494
isMSWINDOWSlike
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6495
    "return true, if the OS we're running on is MS-Windows like."
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6496
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6497
%{  /* NOCONTEXT */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6498
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6499
#if defined(WIN32)
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6500
    RETURN ( true );
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6501
#endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6502
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6503
%}.
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6504
    ^ false
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6505
!
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6506
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6507
isOS2like
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6508
    "return true, if the OS we're running on is OS2 like"
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6509
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6510
%{  /* NOCONTEXT */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6511
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6512
#if defined(OS2)
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6513
    RETURN (true);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6514
#endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6515
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6516
%}.
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6517
    ^ false
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6518
!
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6519
1034
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6520
isUNIXlike
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6521
    "return true, if the OS we're running on is a unix like."
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6522
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6523
%{  /* NOCONTEXT */
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6524
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6525
#if !defined(UNIX_LIKE)
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6526
    RETURN ( false );
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6527
#endif
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6528
%}.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6529
    ^ true
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6530
!
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6531
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6532
maxFileNameLength
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6533
    "return the max number of characters in a filename.
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6534
     CAVEAT:
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  6535
	 Actually, the following is somewhat wrong - some systems
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  6536
	 support different sizezs, depending on the volume.
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  6537
	 We return a somewhat conservative number here."
10
claus
parents: 5
diff changeset
  6538
claus
parents: 5
diff changeset
  6539
%{  /* NOCONTEXT */
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6540
 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6541
    /*
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6542
     * XXX: newer systems provide a query function for this ... use it
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6543
     */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6544
#   if defined(BSD) || defined(SYSV4) || defined(LONGFILENAMES)
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6545
     RETURN ( __MKSMALLINT(255) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6546
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6547
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6548
#   ifdef realIX
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6549
      RETURN ( __MKSMALLINT(127) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6550
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6551
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6552
#   ifdef SYSV
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6553
      RETURN ( __MKSMALLINT(14) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6554
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6555
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6556
#   ifdef MSDOS
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6557
     RETURN ( __MKSMALLINT(9) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6558
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6559
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6560
#   ifdef WIN32
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6561
     /*
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6562
      * mhmh - depends on the filesystem type
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6563
      */
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6564
     RETURN ( __MKSMALLINT(9) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6565
#   endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6566
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6567
    "unix default"
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6568
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6569
    ^ 14
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6570
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6571
1034
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6572
setLocaleInfo:anInfoDictionary
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6573
    "set the locale information; if set, this oerrides the OS's settings.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6574
     (internal in ST/X only - the OS's settings remain unaffected)
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6575
     See description of fields in #getLocaleInfo.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6576
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6577
     Notice, that (for now), the system does not use this information;
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6578
     it should be used by applications as required."
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6579
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6580
    LocaleInfo := anInfoDictionary
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6581
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6582
    "
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6583
     |d|
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6584
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6585
     d := IdentityDictionary new.
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6586
     d at:#decimalPoint                 put:'.'         .
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6587
     d at:#thousandsSeparator           put:','         .
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6588
     d at:#currencySymbol               put:'USD'       .
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6589
     d at:#monetaryDecimalPoint         put:'.'         .
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6590
     d at:#monetaryThousandsSeparator   put:'.'         .
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6591
     d at:#fractionalDigits             put:2           .
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6592
     d at:#positiveSign                 put:'+'         .
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6593
     d at:#negativeSign                 put:'-'         .
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6594
     d at:#positiveSignPrecedesCurrencySymbol put:true          .
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6595
     d at:#negativeSignPrecedesCurrencySymbol put:false         .
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6596
     OperatingSystem setLocaleInfo:d
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6597
    "
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6598
!
4d3ef5de3ec8 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  6599
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6600
supportsIOInterrupts
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6601
    "return true, if the OS supports IO availability interrupts 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6602
     (i.e. SIGPOLL/SIGIO).
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6603
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  6604
     Currently, this mechanism does work for SYSV4 only ..."
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6605
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6606
%{  /* NOCONTEXT */
1062
baa5827a7a40 Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents: 1060
diff changeset
  6607
#if defined(SYSV4) && defined(USE_SIGIO) && 0
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  6608
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  6609
# if defined(SIGPOLL) || defined(SIGIO)
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  6610
#  if (defined(F_GETFL) && defined(F_SETFL) && defined(FASYNC)) || defined(SYSV4)
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  6611
   /*
765
93bdb4f0e095 no, SIGIO does not work on SGI ...
Claus Gittinger <cg@exept.de>
parents: 764
diff changeset
  6612
    * currently the only system where they work is unixware SYSV4
93bdb4f0e095 no, SIGIO does not work on SGI ...
Claus Gittinger <cg@exept.de>
parents: 764
diff changeset
  6613
    * (not even on SGI ...)
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  6614
    */
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  6615
#   if !defined(NEXT)
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  6616
     RETURN (true);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6617
#   endif
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  6618
#  endif
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  6619
# endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6620
10
claus
parents: 5
diff changeset
  6621
#endif
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6622
%}.
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  6623
    ^ false
123
98771547e5ce OSSignals now here
claus
parents: 101
diff changeset
  6624
!
98771547e5ce OSSignals now here
claus
parents: 101
diff changeset
  6625
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6626
supportsNonBlockingIO
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6627
    "return true, if the OS supports nonblocking IO."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6628
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6629
%{  /* NOCONTEXT */
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  6630
#if defined(F_GETFL) && defined(F_SETFL) && defined(FNDELAY)
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6631
       RETURN (true);
754
0dcc8af63497 Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents: 714
diff changeset
  6632
#endif
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6633
%}.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6634
    ^ false
123
98771547e5ce OSSignals now here
claus
parents: 101
diff changeset
  6635
!
98771547e5ce OSSignals now here
claus
parents: 101
diff changeset
  6636
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6637
supportsSelect
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6638
    "return true, if the OS supports selecting on multiple
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6639
     filedescriptors via select."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6640
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6641
%{  /* NOCONTEXT */
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6642
#if defined(WIN32)
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6643
    RETURN (false);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6644
#endif
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6645
#if defined(sco)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6646
    /*
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6647
     * sco has a select, but its broken: always waiting 1 second
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6648
     */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6649
    RETURN(false);
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6650
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6651
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6652
.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6653
    ^ true
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6654
! !
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6655
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  6656
!OperatingSystem class methodsFor:'shared memory access'!
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6657
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6658
shmAttach:id address:addr flags:flags
1247
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6659
    "low level entry to shmat()-system call.
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6660
     Not supported on all operatingSystems"
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6661
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6662
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6663
#ifdef WANT_SHM
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6664
    void *address, *shmaddr;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6665
    int shmflg, shmid;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6666
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6667
    if (__isSmallInteger(addr)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6668
     && __bothSmallInteger(flags, id)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6669
	shmaddr = (void *) __intVal(addr);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6670
	shmflg = __intVal(flags);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6671
	shmid = __intVal(id);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6672
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6673
	address = shmat(shmid, shmaddr, shmflg);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6674
	if (address != (void *)-1) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6675
	    RETURN (__MKEXTERNALBYTES(addr));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6676
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6677
	OperatingSystem_LastErrorNumber = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6678
	RETURN (nil);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6679
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6680
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6681
%}.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  6682
    ^ self primitiveFailed
1247
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6683
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6684
    "Modified: 22.4.1996 / 13:15:12 / cg"
370
claus
parents: 369
diff changeset
  6685
!
claus
parents: 369
diff changeset
  6686
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6687
shmDetach:addr
1247
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6688
    "low level entry to shmdt()-system call.
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6689
     Not supported on all operatingSystems"
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6690
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6691
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6692
#ifdef WANT_SHM
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6693
    void *shmaddr;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6694
    int rslt;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6695
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6696
    if (__isSmallInteger(addr)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6697
	shmaddr = (void *) __intVal(addr);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6698
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6699
	rslt = shmdt(shmaddr);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6700
	if (rslt != -1) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6701
	    RETURN (true);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6702
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6703
	OperatingSystem_LastErrorNumber = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6704
	RETURN (false);
370
claus
parents: 369
diff changeset
  6705
    }
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6706
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6707
%}.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  6708
    ^ self primitiveFailed
1247
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6709
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6710
    "Modified: 22.4.1996 / 13:15:03 / cg"
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6711
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6712
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6713
shmGet:key size:size flags:flags
1247
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6714
    "low level entry to shmget()-system call.
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6715
     This is not for public use and not supported with all operatingSystems.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6716
     - use the provided wrapper class SharedExternalBytes instead."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6717
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6718
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6719
#ifdef WANT_SHM
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6720
    if (__bothSmallInteger(key, size)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6721
     && __isSmallInteger(flags)) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6722
	int rslt;
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6723
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6724
	rslt = shmget(__intVal(key), __intVal(size), __intVal(flags));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6725
	if (rslt != -1) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6726
	    RETURN (__MKSMALLINT(rslt));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6727
	}
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6728
	OperatingSystem_LastErrorNumber = __MKSMALLINT(errno);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6729
	RETURN (nil);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6730
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6731
#endif
370
claus
parents: 369
diff changeset
  6732
%}.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  6733
    ^ self primitiveFailed
1247
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6734
2716d915e84e commentary
Claus Gittinger <cg@exept.de>
parents: 1153
diff changeset
  6735
    "Modified: 22.4.1996 / 13:14:46 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  6736
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
  6737
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  6738
!OperatingSystem class methodsFor:'time and date'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  6739
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6740
computeDatePartsOf:osTime for:aBlock
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6741
    "compute year, month and day from the OS time, osTime
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6742
     and evaluate the argument, a 3-arg block with these.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6743
     Conversion is to localtime including any daylight saving adjustments."
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6744
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6745
    |year month day osSeconds|
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6746
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6747
    osSeconds := osTime // 1000.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  6748
%{
a27a279701f8 Initial revision
claus
parents:
diff changeset
  6749
    struct tm *tmPtr;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  6750
    long t;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  6751
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6752
    t = __longIntVal(osSeconds);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6753
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  6754
    tmPtr = localtime(&t);
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  6755
    year = __MKSMALLINT(tmPtr->tm_year + 1900);
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  6756
    month = __MKSMALLINT(tmPtr->tm_mon + 1);
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  6757
    day = __MKSMALLINT(tmPtr->tm_mday);
810
9b3676f51220 mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents: 809
diff changeset
  6758
%}.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  6759
    aBlock value:year value:month value:day
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6760
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6761
    "
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6762
     OperatingSystem computeDatePartsOf:0 for:[:y :m :d |
1885
219c3437ad01 added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents: 1863
diff changeset
  6763
	y printCR. m printCR. d printCR
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6764
     ]
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6765
    "
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6766
!
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6767
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6768
computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millis:millis
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6769
    "return the OS-dependent time for the given time and day. 
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6770
     The arguments are assumed to be in localtime including
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6771
     any daylight saving adjustings."
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6772
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6773
    |osSeconds|
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6774
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6775
%{
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6776
    struct tm tm;
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6777
    long t;
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6778
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6779
    if (__bothSmallInteger(y, m) 
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6780
     && __bothSmallInteger(d, h)
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6781
     && __bothSmallInteger(min, s)) {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6782
	tm.tm_hour = __intVal(h);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6783
	tm.tm_min = __intVal(min);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6784
	tm.tm_sec = __intVal(s);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6785
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6786
	tm.tm_year = __intVal(y) - 1900;
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6787
	tm.tm_mon = __intVal(m) - 1;
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6788
	tm.tm_mday = __intVal(d);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6789
	tm.tm_isdst = -1;
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6790
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6791
	t = mktime(&tm);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6792
	osSeconds = __MKUINT(t);
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6793
    }
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6794
%}.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6795
    osSeconds notNil ifTrue:[
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6796
	^ osSeconds * 1000 + millis
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6797
    ].    
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6798
    ^ self primitiveFailed
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6799
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6800
    "
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6801
     OperatingSystem computeOSTimeFromYear:1970 month:1 day:1 hour:0 minute:0 seconds:0 millis:0
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6802
    "
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6803
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6804
!
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6805
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6806
computeTimeAndDateFrom:osTime
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6807
    "given an OS-dependent time in osTime, return an Array
1511
823fcfbbb741 weekDay/yearDay start with0 in tm_ struct, but
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  6808
     containing (full-) year, month, day, hour, minute and seconds,
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6809
     offset to UTC, daylight savings time flag, milliseconds,
1511
823fcfbbb741 weekDay/yearDay start with0 in tm_ struct, but
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  6810
     dayInYear (1..) and dayInWeek (1..).
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6811
     Conversion is to localtime including any daylight saving adjustments."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6812
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6813
    |low hi year month day hours minutes seconds millis utcOffset 
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6814
     dst yDay wDay osSeconds ret|
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6815
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6816
    millis := osTime \\ 1000.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6817
    osSeconds := osTime // 1000.
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  6818
%{
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  6819
    struct tm *tmPtr;
810
9b3676f51220 mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents: 809
diff changeset
  6820
    struct tm *gmTmPtr;
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  6821
    long t;
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  6822
2073
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  6823
#if defined(HAS_NO_TIMEZONE)
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  6824
#   define TIMEZONE     tmPtr->tm_gmtoff
811
6fbd6e7fdb74 mhmh - more ultrix kludges
Claus Gittinger <cg@exept.de>
parents: 810
diff changeset
  6825
#else
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6826
# ifdef MSDOS_LIKE
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  6827
#   define TIMEZONE 0
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6828
# else
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  6829
#   define TIMEZONE     timezone
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  6830
# endif
811
6fbd6e7fdb74 mhmh - more ultrix kludges
Claus Gittinger <cg@exept.de>
parents: 810
diff changeset
  6831
#endif
6fbd6e7fdb74 mhmh - more ultrix kludges
Claus Gittinger <cg@exept.de>
parents: 810
diff changeset
  6832
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6833
    t = __longIntVal(osSeconds);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6834
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6835
    tmPtr = localtime(&t);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6836
    hours = __MKSMALLINT(tmPtr->tm_hour);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6837
    minutes = __MKSMALLINT(tmPtr->tm_min);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6838
    seconds = __MKSMALLINT(tmPtr->tm_sec);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6839
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6840
    year = __MKSMALLINT(tmPtr->tm_year + 1900);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6841
    month = __MKSMALLINT(tmPtr->tm_mon + 1);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6842
    day = __MKSMALLINT(tmPtr->tm_mday);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6843
1511
823fcfbbb741 weekDay/yearDay start with0 in tm_ struct, but
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  6844
    yDay = __MKSMALLINT(tmPtr->tm_yday+1);
1512
d4e6376dce78 weekDay fix (sunday is 0 in tm_wday)
Claus Gittinger <cg@exept.de>
parents: 1511
diff changeset
  6845
    wDay = __MKSMALLINT(tmPtr->tm_wday == 0 ? 7 : tmPtr->tm_wday);
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6846
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6847
    if (tmPtr->tm_isdst == 0) {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6848
	dst = false;
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6849
	utcOffset = __MKSMALLINT(TIMEZONE);
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6850
    } else {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6851
	dst = true;
800
067094efdaed use HAS_ALTZONE / HAS_DAYLIGHT
Claus Gittinger <cg@exept.de>
parents: 798
diff changeset
  6852
#ifdef HAS_ALTZONE
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6853
	utcOffset = __MKSMALLINT(altzone);
800
067094efdaed use HAS_ALTZONE / HAS_DAYLIGHT
Claus Gittinger <cg@exept.de>
parents: 798
diff changeset
  6854
#else
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6855
	utcOffset = __MKSMALLINT(TIMEZONE) + 3600;
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6856
#endif
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  6857
    }
241
6f30be88e314 *** empty log message ***
claus
parents: 234
diff changeset
  6858
%}.
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6859
    "I would love to have SELF-like inline objects ..."
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6860
    ret := Array new:11.
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6861
    ret at:1 put:year.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6862
    ret at:2 put:month.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6863
    ret at:3 put:day.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6864
    ret at:4 put:hours.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6865
    ret at:5 put:minutes.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6866
    ret at:6 put:seconds.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6867
    ret at:7 put:utcOffset.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6868
    ret at:8 put:dst.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6869
    ret at:9 put:millis.
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6870
    ret at:10 put:yDay.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6871
    ret at:11 put:wDay.
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6872
    ^ ret
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6873
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6874
    "
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6875
     OperatingSystem computeTimeAndDateFrom:0
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6876
    "
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6877
!
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6878
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6879
computeTimePartsOf:osTime for:aBlock
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6880
    "compute hours, minutes, seconds and milliseconds from the osTime 
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6881
     and evaluate the argument, a 4-arg block with these.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6882
     Conversion is to localtime including any daylight saving adjustments."
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6883
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6884
    |hours minutes seconds millis osSeconds|
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6885
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6886
    osSeconds := osTime // 1000.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6887
    millis := osTime \\ 1000.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6888
%{
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6889
    struct tm *tmPtr;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6890
    long t;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6891
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6892
    t = __longIntVal(osSeconds);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6893
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  6894
    tmPtr = localtime(&t);
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  6895
    hours = __MKSMALLINT(tmPtr->tm_hour);
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  6896
    minutes = __MKSMALLINT(tmPtr->tm_min);
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  6897
    seconds = __MKSMALLINT(tmPtr->tm_sec);
810
9b3676f51220 mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents: 809
diff changeset
  6898
%}.
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6899
    aBlock value:hours value:minutes value:seconds value:millis
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6900
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6901
    "
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6902
     OperatingSystem computeTimePartsOf:100 for:[:h :m :s :milli |
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6903
	h printCR. m printCR. s printCR. millis printCR
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6904
     ]
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6905
    "
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6906
!
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6907
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6908
computeUTCTimeAndDateFrom:osTime
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6909
    "given an OS-dependent time in osTime, return an Array
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6910
     containing year, month, day, hour, minute and seconds,
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6911
     offset to UTC, daylight savings time flag, milliseconds,
1511
823fcfbbb741 weekDay/yearDay start with0 in tm_ struct, but
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  6912
     dayInYear (1..) and dayInWeek (1..).
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6913
     Conversion is to UTC."
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6914
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6915
    |low hi year month day hours minutes seconds millis utcOffset 
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6916
     dst yDay wDay osSeconds ret|
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6917
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6918
    millis := osTime \\ 1000.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6919
    osSeconds := osTime // 1000.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6920
%{
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6921
    struct tm *tmPtr;
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6922
    struct tm *gmTmPtr;
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6923
    long t;
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6924
2073
4c2bdfc668c9 NEXT changes (again)
Claus Gittinger <cg@exept.de>
parents: 2000
diff changeset
  6925
#if defined(HAS_NO_TIMEZONE)
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6926
#   define TIMEZONE     tmPtr->tm_gmtoff
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6927
#else
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6928
# ifdef MSDOS_LIKE
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6929
#   define TIMEZONE 0
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6930
# else
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6931
#   define TIMEZONE     timezone
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6932
# endif
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6933
#endif
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6934
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6935
    t = __longIntVal(osSeconds);
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6936
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6937
    tmPtr = gmtime(&t);
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6938
    hours = __MKSMALLINT(tmPtr->tm_hour);
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6939
    minutes = __MKSMALLINT(tmPtr->tm_min);
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6940
    seconds = __MKSMALLINT(tmPtr->tm_sec);
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6941
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6942
    year = __MKSMALLINT(tmPtr->tm_year + 1900);
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6943
    month = __MKSMALLINT(tmPtr->tm_mon + 1);
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6944
    day = __MKSMALLINT(tmPtr->tm_mday);
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6945
1511
823fcfbbb741 weekDay/yearDay start with0 in tm_ struct, but
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
  6946
    yDay = __MKSMALLINT(tmPtr->tm_yday + 1);
1512
d4e6376dce78 weekDay fix (sunday is 0 in tm_wday)
Claus Gittinger <cg@exept.de>
parents: 1511
diff changeset
  6947
    wDay = __MKSMALLINT(tmPtr->tm_wday == 0 ? 7 : tmPtr->tm_wday);
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6948
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6949
    if (tmPtr->tm_isdst == 0) {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6950
	dst = false;
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6951
	utcOffset = __MKSMALLINT(TIMEZONE);
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6952
    } else {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6953
	dst = true;
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6954
#ifdef HAS_ALTZONE
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6955
	utcOffset = __MKSMALLINT(altzone);
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6956
#else
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  6957
	utcOffset = __MKSMALLINT(TIMEZONE) + 3600;
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6958
#endif
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6959
    }
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6960
%}.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6961
    "I would love to have SELF-like inline objects ..."
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6962
    ret := Array new:11.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6963
    ret at:1 put:year.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6964
    ret at:2 put:month.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6965
    ret at:3 put:day.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6966
    ret at:4 put:hours.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6967
    ret at:5 put:minutes.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6968
    ret at:6 put:seconds.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6969
    ret at:7 put:utcOffset.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6970
    ret at:8 put:dst.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6971
    ret at:9 put:millis.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6972
    ret at:10 put:yDay.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6973
    ret at:11 put:wDay.
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6974
    ^ ret
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6975
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6976
    "
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6977
     OperatingSystem computeUTCTimeAndDateFrom:0
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6978
    "
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6979
!
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  6980
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6981
computeUTCTimePartsOf:osTime for:aBlock
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6982
    "compute hours, minutes, seconds and milliseconds from the osTime 
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6983
     and evaluate the argument, a 4-arg block with these.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6984
     Conversion is to UTC."
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6985
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6986
    |hours minutes seconds millis osSeconds|
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6987
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6988
    osSeconds := osTime // 1000.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6989
    millis := osTime \\ 1000.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6990
%{
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6991
    struct tm *tmPtr;
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6992
    long t;
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6993
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6994
    t = __longIntVal(osSeconds);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6995
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6996
    tmPtr = gmtime(&t);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6997
    hours = __MKSMALLINT(tmPtr->tm_hour);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6998
    minutes = __MKSMALLINT(tmPtr->tm_min);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  6999
    seconds = __MKSMALLINT(tmPtr->tm_sec);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7000
%}.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7001
    aBlock value:hours value:minutes value:seconds value:millis
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7002
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7003
    "
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  7004
     OperatingSystem computeUTCTimePartsOf:100 for:[:h :m :s :milli |
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7005
	h printCR. m printCR. s printCR. milli printCR
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7006
     ]
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7007
    "
275
a76029ddaa98 *** empty log message ***
claus
parents: 252
diff changeset
  7008
!
a76029ddaa98 *** empty log message ***
claus
parents: 252
diff changeset
  7009
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7010
getMillisecondTime
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7011
    "This returns the millisecond timers value. 
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7012
     The range is limited to 0..1fffffff (i.e. the SmallInteger range) to avoid
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7013
     LargeInteger arithmetic when doing timeouts and delays.
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  7014
     Since this value is wrapping around in regular intervals, this can only be used for 
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7015
     short relative time deltas.
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7016
     Use the millisecondTimeXXX:-methods to compare and add time deltas - these know about the wrap.
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7017
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7018
     BAD DESIGN:
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7019
	This should be changed to return some instance of RelativeTime,
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7020
	and these computations moved there.
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7021
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7022
     Dont use this method in application code since it is an internal (private)
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7023
     interface. For compatibility with ST-80, use Time millisecondClockValue.
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7024
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7025
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7026
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7027
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7028
    long t;
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7029
#if !defined(HAS_GETTIMEOFDAY) && defined(SYSV) && defined(HZ)
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7030
    /* 
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7031
     * sys5 time
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7032
     */
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7033
    long ticks;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7034
    struct tms tb;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7035
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7036
    ticks = times(&tb);
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7037
    t = (ticks * 1000) / HZ;
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  7038
#else
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  7039
# ifdef WIN32
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  7040
    t = GetTickCount();
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  7041
# else
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  7042
#  ifdef MSDOS_LIKE
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  7043
    struct _timeb timebuffer;
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  7044
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  7045
    _ftime(&timebuffer);
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  7046
    t = (timebuffer.time * 1000) + timebuffer.millitm;
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  7047
#  else /* assume HAS_GETTIMEOFDAY */
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7048
    /*
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7049
     * bsd time
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7050
     */
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7051
    struct timeval tb;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7052
    struct timezone tzb;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7053
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7054
    gettimeofday(&tb, &tzb);
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7055
    t = tb.tv_sec*1000 + tb.tv_usec/1000;
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  7056
#  endif
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  7057
# endif
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  7058
#endif
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7059
    RETURN ( __MKSMALLINT(t & 0x1FFFFFFF) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7060
%}
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7061
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7062
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7063
getOSTime
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7064
    "This returns the millisecond OS time.
2000
2c12eb609e05 commentary
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  7065
     The base of the returned value is not consistent across
2c12eb609e05 commentary
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  7066
     different OS's - some return the number of millis since jan, 1st 1970;
2c12eb609e05 commentary
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  7067
     others since 1900. The Time classes are prepared for this, and 
2c12eb609e05 commentary
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  7068
     convert as appropriate.
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7069
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7070
     Dont use this method in application code since it is an internal (private)
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7071
     interface. For compatibility with ST-80, use Time>>millisecondClockValue.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7072
     or use instances of Time, Date or AbsoluteTime to work with.
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7073
    "
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7074
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7075
    |seconds millis|
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7076
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7077
%{
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7078
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7079
    long t;
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7080
#if !defined(HAS_GETTIMEOFDAY) && defined(SYSV) && defined(HZ)
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7081
    /* 
2000
2c12eb609e05 commentary
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  7082
     * sys5 time; we have to fake the information
2c12eb609e05 commentary
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  7083
     * the returned value is inexact.
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7084
     */
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7085
    int now;
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7086
    long ticks;
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7087
    struct tms tb;
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7088
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7089
    now = time(0);   /* seconds since 1970 ... */
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7090
    seconds = __MKUINT(now);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7091
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7092
    ticks = times(&tb);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7093
    t = (ticks * 1000) / HZ;
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7094
    t = t % 1000;
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7095
    millis = __MKSMALLINT(t);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7096
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7097
#else
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7098
# ifdef MSDOS_LIKE
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7099
    struct _timeb timebuffer;
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7100
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7101
    _ftime(&timebuffer);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7102
    seconds = __MKUINT(timebuffer.time);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7103
    millis = __MKSMALLINT(timebuffer.millitm);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7104
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7105
# else /* assume HAS_GETTIMEOFDAY */
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7106
    /*
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7107
     * bsd time
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7108
     */
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7109
    struct timeval tb;
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7110
    struct timezone tzb;
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7111
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7112
    gettimeofday(&tb, &tzb);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7113
    seconds = __MKUINT(tb.tv_sec);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7114
    millis = __MKSMALLINT(tb.tv_usec / 1000);
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7115
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7116
# endif
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7117
#endif
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7118
%}.
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7119
    ^ (seconds * 1000) + millis
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7120
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7121
    "
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  7122
     OperatingSystem getOSTime printCR.
1499
0df07e1d0c2f osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents: 1497
diff changeset
  7123
     Delay waitForSeconds:0.2.
1510
d7987cc00dc4 added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents: 1499
diff changeset
  7124
     OperatingSystem getOSTime printCR.
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7125
    "
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7126
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7127
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7128
maximumMillisecondTimeDelta
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7129
    "this returns the maximum delta supported by millisecondCounter
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7130
     based methods. The returned value is half the value at which the
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7131
     timer wraps."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7132
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7133
%{  /* NOCONTEXT */
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7134
    RETURN ( __MKSMALLINT(0x0FFFFFFF) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7135
%}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7136
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7137
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7138
millisecondDelay:millis
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7139
    "delay execution for millis milliseconds or until the next event
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7140
     arrives.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7141
     All lower priority threads will also sleep for the duration, 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7142
     interrupts (and therefore, higher prio processes) are
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7143
     still handled. 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7144
     Better use a Delay, to only delay the calling thread.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7145
     (however, a delay cannot be used in the event handler or scheduler)"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7146
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7147
    |now then delta|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7148
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7149
%{  /* NOCONTEXT */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7150
#ifdef WIN32
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7151
    int t = __intVal(millis);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7152
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7153
    if (t) {
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  7154
	Sleep(t);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7155
    }
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7156
    RETURN (self);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7157
#endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7158
%}.
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7159
 
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7160
    now := OperatingSystem getMillisecondTime.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7161
    then := OperatingSystem millisecondTimeAdd:now and:millis.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7162
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7163
    [OperatingSystem millisecondTime:then isAfter:now] whileTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7164
	delta := OperatingSystem millisecondTimeDeltaBetween:then and:now.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7165
	self selectOnAnyReadable:nil writable:nil exception:nil withTimeOut:delta.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7166
	now := OperatingSystem getMillisecondTime.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7167
    ]
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7168
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7169
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7170
     OperatingSystem millisecondDelay:2000
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7171
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7172
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7173
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7174
millisecondTime:msTime1 isAfter:msTime2
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7175
    "return true if msTime1 is after msTime2, false if not.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7176
     The two arguments are supposed to be millisecond times 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7177
     (such as returned getMillisecondTime) which wrap at 16r1FFFFFFF.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7178
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7179
     This should really be moved to some RelativeTime class."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7180
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7181
    (msTime1 > msTime2) ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7182
	((msTime1 - msTime2) >= 16r10000000) ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7183
	    ^ false
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7184
	].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7185
	^ true
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7186
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7187
    ((msTime2 - msTime1) > 16r10000000) ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7188
	^ true
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7189
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7190
    ^ false
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7191
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7192
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7193
millisecondTimeAdd:msTime1 and:msTime2
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7194
    "Add two millisecond times (such as returned getMillisecondTime).
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7195
     The returned value is msTime1 + msTime2 where a wrap occurs at:16r1FFFFFFF.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7196
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7197
     This should really be moved to some RelativeTime class."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7198
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7199
    |sum|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7200
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7201
    sum := msTime1 + msTime2.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7202
    (sum > 16r1FFFFFFF) ifTrue:[^ sum - 16r20000000].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7203
    (sum < 0) ifTrue:[^ sum + 16r20000000].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7204
    ^ sum
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7205
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7206
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7207
millisecondTimeDeltaBetween:msTime1 and:msTime2
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7208
    "subtract two millisecond times (such as returned getMillisecondTime)
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7209
     and return the difference. Since milli-times wrap (at 16r01FFFFFFF), 
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7210
     some special handling is built-in here.
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7211
     The returned value is msTime1 - msTime2. The returned value is invalid
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7212
     if the delta is >= 0x10000000.
63
1f0cdefb013f *** empty log message ***
claus
parents: 51
diff changeset
  7213
810
9b3676f51220 mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents: 809
diff changeset
  7214
     This should really be moved to some RelativeTime class;
9b3676f51220 mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents: 809
diff changeset
  7215
     better yet: create a subclass of Integer named LimitedRangeInteger."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7216
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7217
    (msTime1 > msTime2) ifTrue:[
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7218
	^ msTime1 - msTime2
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7219
    ].
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7220
    ^ msTime1 + 16r10000000 - msTime2
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7221
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7222
    "
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7223
     OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:1   
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7224
     OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:(16 / 3)  
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7225
     OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:1000   
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7226
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7227
     OperatingSystem millisecondTimeDeltaBetween:0 and:16r0FFFFFFF  
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7228
     OperatingSystem millisecondTimeDeltaBetween:(13/3) and:16r0FFFFFFF     
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7229
     OperatingSystem millisecondTimeDeltaBetween:999 and:16r0FFFFFFF       
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7230
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7231
     OperatingSystem millisecondTime:0 isAfter:16r0FFFFFFF    
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7232
     OperatingSystem millisecondTime:(13/3) isAfter:16r0FFFFFFF   
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7233
     OperatingSystem millisecondTime:999 isAfter:16r0FFFFFFF       
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7234
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7235
     OperatingSystem millisecondTime:0 isAfter:0          
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7236
     OperatingSystem millisecondTime:(13/3) isAfter:0  
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7237
     OperatingSystem millisecondTime:999 isAfter:0       
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7238
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7239
     OperatingSystem millisecondTime:1 isAfter:0        
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7240
     OperatingSystem millisecondTime:(13/3) isAfter:2
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7241
     OperatingSystem millisecondTime:999 isAfter:900       
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7242
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7243
     |t1 t2|
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7244
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7245
     t1 := Time millisecondClockValue.
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7246
     (Delay forMilliseconds:1) wait.   
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7247
     t2 := Time millisecondClockValue.
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7248
     OperatingSystem millisecondTimeDeltaBetween:t2 and:t1 
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7249
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7250
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7251
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7252
sleep:numberOfSeconds
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7253
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7254
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7255
    "cease ANY action for some time. This suspends the whole smalltalk
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7256
     (unix-) process for some time.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7257
     Not really useful since not even low-prio processes and interrupt
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7258
     handling will run during the sleep.
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7259
     Use either OperatingSystem>>millisecondDelay: (which makes all
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7260
     threads sleep, but handles interrupts) or use a Delay (which makes
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7261
     only the calling thread sleep)."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7262
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7263
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7264
252
  7265
    if (__isSmallInteger(numberOfSeconds)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7266
	sleep(__intVal(numberOfSeconds));
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7267
	RETURN ( self );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7268
    }
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  7269
%}.
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  7270
    "
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  7271
     argument not integer
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  7272
    "
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  7273
    ^ self primitiveFailed
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7274
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7275
    "
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7276
     OperatingSystem sleep:2
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7277
    "
10
claus
parents: 5
diff changeset
  7278
! !
claus
parents: 5
diff changeset
  7279
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  7280
!OperatingSystem class methodsFor:'users & groups'!
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7281
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7282
getEffectiveGroupID
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7283
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7284
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7285
    "return the current users (thats you) effective numeric group id.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7286
     This is only different from getGroupID, if you have ST/X running
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7287
     as a setuid program (of which you should think about twice)."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7288
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7289
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7290
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7291
#ifdef UNIX_LIKE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7292
    int uid;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7293
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7294
    uid = getegid();
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7295
    RETURN ( __MKSMALLINT(uid) );
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7296
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7297
    /* --- return same as getGroupID --- */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7298
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7299
    ^ self getGroupID
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7300
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7301
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7302
     OperatingSystem getEffectiveGroupID
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7303
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7304
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7305
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7306
getEffectiveUserID
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7307
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7308
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7309
    "return the current users (thats you) effective numeric user id.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7310
     This is only different from getUserID, if you have ST/X running
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7311
     as a setuid program (of which you should think about twice)."
10
claus
parents: 5
diff changeset
  7312
claus
parents: 5
diff changeset
  7313
%{  /* NOCONTEXT */
claus
parents: 5
diff changeset
  7314
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7315
#ifdef UNIX_LIKE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7316
    int uid;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7317
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7318
    uid = geteuid();
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7319
    RETURN ( __MKSMALLINT(uid) );
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7320
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7321
    /* --- return same as getUserID --- */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7322
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7323
    ^ self getUserID
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7324
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7325
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7326
     OperatingSystem getEffectiveUserID
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7327
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7328
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7329
1549
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7330
getFullUserNameFromID:userID
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7331
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7332
1549
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7333
    "return a string with the users full name - if available.
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7334
     If not, return the login name as a fallBack."
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7335
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7336
    |info gecos|
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7337
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7338
    info := self userInfoOf:userID.
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7339
    (info notNil
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7340
    and:[info includesKey:#gecos]) ifTrue:[
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7341
	gecos := info at:#gecos.
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7342
	(gecos includes:$,) ifTrue:[
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7343
	    ^ gecos copyTo:(gecos indexOf:$,) - 1
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7344
	].
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7345
	^ gecos
1549
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7346
    ].
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7347
    ^ self getUserNameFromID:userID
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7348
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7349
    "
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7350
     OperatingSystem getFullUserNameFromID:0 
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7351
     OperatingSystem getFullUserNameFromID:(OperatingSystem getUserID)  
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7352
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7353
     OperatingSystem getUserNameFromID:(OperatingSystem getUserID)  
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7354
    "
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7355
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7356
    "Modified: 15.7.1996 / 12:44:21 / cg"
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7357
!
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7358
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7359
getGroupID
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7360
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7361
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7362
    "return the current users (thats you) numeric group id"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7363
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7364
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7365
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7366
#ifdef UNIX_LIKE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7367
    int uid;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7368
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7369
    uid = getgid();
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7370
    RETURN ( __MKSMALLINT(uid) );
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7371
#else
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7372
# ifdef SYSTEM_HAS_GROUPS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7373
    /* ... */
10
claus
parents: 5
diff changeset
  7374
# endif
claus
parents: 5
diff changeset
  7375
#endif
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  7376
%}.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7377
    ^ 1 "just a dummy for systems which do not have userIDs"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7378
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  7379
    "
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7380
     OperatingSystem getGroupID
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7381
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7382
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7383
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7384
getGroupNameFromID:aNumber
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7385
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7386
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7387
    "return the group-name-string for a given numeric group-id"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7388
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7389
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7390
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7391
#ifdef UNIX_LIKE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7392
    struct group *g;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7393
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7394
    if (__isSmallInteger(aNumber)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7395
	g = getgrgid(__intVal(aNumber));
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7396
	if (g) {
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  7397
	    RETURN ( __MKSTRING(g->gr_name) );
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7398
	}
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7399
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7400
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7401
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7402
    ^ '???'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7403
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7404
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7405
     OperatingSystem getGroupNameFromID:0
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7406
     OperatingSystem getGroupNameFromID:10
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7407
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7408
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7409
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7410
getHomeDirectory
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7411
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7412
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7413
    "return the name of the users home directory"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7414
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7415
    ^ OperatingSystem getEnvironment:'HOME'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7416
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7417
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7418
     OperatingSystem getHomeDirectory
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7419
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7420
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7421
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7422
getLoginName
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7423
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7424
1549
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7425
    "return a string with the users login name"
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7426
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7427
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7428
    static char cachedName[64];
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7429
    static firstCall = 1;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7430
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7431
    char *name = (char *)0;
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7432
#ifdef UNIX_LIKE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7433
    if (firstCall) {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7434
	name = (char *)getlogin();
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7435
	if (! name || (name[0] == 0)) {
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7436
	    name = (char *)getenv("LOGNAME");
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7437
	}
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7438
	if (name && (strlen(name) < sizeof(cachedName))) {
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7439
	    strcpy(cachedName, name);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7440
	    firstCall = 0;
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7441
	}
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7442
    } else {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7443
	name = cachedName;
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7444
    }
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7445
#else
1632
355409cd49d8 more for NT
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
  7446
# ifdef WIN32
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7447
    if (firstCall) {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7448
	int nameSize = sizeof(cachedName);
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7449
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7450
	if (GetUserName(cachedName, &nameSize) == TRUE) {
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7451
	    name = cachedName;
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7452
	    firstCall = 0;
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7453
	}
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7454
    } else {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7455
	name = cachedName;
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7456
    }
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7457
# endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7458
#endif
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7459
    if (! name || (name[0] == 0) ) {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7460
	name = (char *)getenv("LOGNAME");
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7461
    }
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7462
    if (! name || (name[0] == 0) ) {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7463
	name = "you";
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7464
    }
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7465
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  7466
    RETURN ( __MKSTRING(name) );
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7467
%}.
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7468
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7469
     OperatingSystem getLoginName
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7470
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7471
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7472
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7473
getUserID
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7474
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7475
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7476
    "return the current users (thats you) numeric user id"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7477
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7478
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7479
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7480
#ifdef UNIX_LIKE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7481
    int uid;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7482
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7483
    uid = getuid();
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7484
    RETURN ( __MKSMALLINT(uid) );
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7485
#else
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7486
# ifdef SYSTEM_HAS_USERS
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7487
    /* ... */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7488
# endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7489
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7490
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7491
    ^ 1 "just a dummy for systems which do not have userIDs"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7492
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7493
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7494
     OperatingSystem getUserID
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  7495
    "
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7496
!
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7497
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7498
getUserNameFromID:aNumber
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7499
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7500
1549
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7501
    "return the user-name-string for a given numeric user-id.
df9d235c992e added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
  7502
     This is the login name, not the fullName."
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7503
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7504
%{  /* NOCONTEXT */
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7505
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7506
#ifdef UNIX_LIKE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7507
    struct passwd *p;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7508
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7509
    if (__isSmallInteger(aNumber)) {
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7510
	p = getpwuid(__intVal(aNumber));
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7511
	if (p) {
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  7512
	    RETURN ( __MKSTRING(p->pw_name) );
1588
0f9e80f6ae74 WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents: 1549
diff changeset
  7513
	}
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7514
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7515
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7516
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7517
    ^ '? (' , aNumber printString , ')'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7518
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7519
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7520
     OperatingSystem getUserNameFromID:0
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7521
     OperatingSystem getUserNameFromID:100
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7522
     OperatingSystem getUserNameFromID:9991 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7523
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7524
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7525
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7526
userInfoOf:aNameOrID
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7527
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7528
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7529
    "return a dictionary filled with userinfo. The argument can be either
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7530
     a string with the users name or its numeric id.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7531
     Notice, that not all systems provide (all of) this info;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7532
     DOS systems return nothing; 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7533
     non-SYSV4 systems have no age/comment.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7534
     Portable applications may want to check the systemType and NOT depend
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7535
     on all keys to be present in the returned dictionary.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7536
     Another notice: on some systems (SYSV4), the gecos field includes multiple
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7537
     entries (i.e. not just the name), separated by commas. You may want to
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7538
     extract any substring, up to the first comma to get the real life name."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7539
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7540
    |info name passw uid gid age comment
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7541
     gecos dir shell|
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7542
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7543
%{
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7544
#ifdef UNIX_LIKE
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7545
    struct passwd *buf;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7546
    int ret;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7547
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7548
    if (__isString(aNameOrID)) {
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7549
	buf = getpwnam(__stringVal(aNameOrID));
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7550
    } else if (__isSmallInteger(aNameOrID)) {
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7551
	buf = getpwuid(__intVal(aNameOrID));
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7552
    } else {
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7553
	buf = (struct passwd *)0;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7554
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7555
    if (buf) {
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  7556
	name = __MKSTRING(buf->pw_name);
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  7557
	passw = __MKSTRING(buf->pw_passwd);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7558
# ifdef SYSV4
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  7559
	age = __MKSTRING(buf->pw_age);
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  7560
	comment = __MKSTRING(buf->pw_comment);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7561
# endif
1688
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  7562
	dir = __MKSTRING(buf->pw_dir);
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  7563
	gecos = __MKSTRING(buf->pw_gecos);
8a42db1eea60 removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 1675
diff changeset
  7564
	shell = __MKSTRING(buf->pw_shell);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7565
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7566
	uid = __MKSMALLINT(buf->pw_uid);
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7567
	gid = __MKSMALLINT(buf->pw_gid);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7568
    }
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7569
#endif
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7570
%}.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7571
    info := IdentityDictionary new.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7572
    name notNil ifTrue:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7573
	info at:#name put:name.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7574
    ] ifFalse:[
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7575
	info at:#name put:'unknown'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7576
    ].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7577
    passw notNil ifTrue:[info at:#passwd put:passw].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7578
    age notNil ifTrue:[info at:#age put:age].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7579
    comment notNil ifTrue:[info at:#comment put:comment].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7580
    gecos notNil ifTrue:[info at:#gecos put:gecos].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7581
    shell notNil ifTrue:[info at:#shell put:shell].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7582
    dir notNil ifTrue:[info at:#dir put:dir].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7583
    uid notNil ifTrue:[info at:#uid put:uid].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7584
    gid  notNil ifTrue:[info at:#gid put:gid].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7585
    ^ info
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7586
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7587
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7588
     OperatingSystem userInfoOf:'root'
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7589
     OperatingSystem userInfoOf:1
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7590
     OperatingSystem userInfoOf:'claus' 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7591
     OperatingSystem userInfoOf:'fooBar' 
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7592
     OperatingSystem userInfoOf:(OperatingSystem getUserID)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7593
    "
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7594
! !
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7595
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  7596
!OperatingSystem class methodsFor:'waiting for events'!
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7597
840
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7598
blockingChildProcessWait
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7599
     "return true, if childProcessWait: blocks, if no childs are ready"
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7600
%{ /*NOCONTEXT*/
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7601
#if defined(HAS_WAITPID) || defined(HAS_WAIT3)
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7602
    RETURN(false);
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7603
#else
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7604
    RETURN(true);
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7605
#endif
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7606
%}
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7607
!
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7608
840
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7609
childProcessWait:blocking
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7610
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7611
840
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7612
    "get status changes from child processes.
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7613
     Return an OSProcessStatus or nil, if no process has terminated.
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7614
     If blocking is true, we wait until a process changed state, 
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7615
     otherwise we return immediately."
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7616
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7617
    |pid status code core|
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7618
%{
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7619
#ifdef UNIX_LIKE
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7620
    int p;
1653
51bd45bcc19d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  7621
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7622
# if defined(HAS_WAITPID)
1653
51bd45bcc19d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  7623
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7624
    int s;
1653
51bd45bcc19d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  7625
#   define __WAIT     waitpid(-1, &s, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED)
51bd45bcc19d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  7626
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7627
# else
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7628
#  if defined(HAS_WAIT3)
1653
51bd45bcc19d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  7629
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7630
    union wait s;
1653
51bd45bcc19d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  7631
#   define __WAIT      wait3(&s, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED, 0)
51bd45bcc19d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  7632
51bd45bcc19d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  7633
#  else /* neithe waitpid, nor wait3; use wait, which is blocking */
51bd45bcc19d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  7634
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7635
    int s;
1653
51bd45bcc19d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  7636
#   define __WAIT      wait(&s)
51bd45bcc19d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  7637
#   define __BLOCKING_WAIT__ 1
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7638
1654
4352c5837f37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1653
diff changeset
  7639
    if (blocking != true) {
4352c5837f37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1653
diff changeset
  7640
	/*
4352c5837f37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1653
diff changeset
  7641
	 * We do not support nonBlocking waits, so signal an error
4352c5837f37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1653
diff changeset
  7642
	 * Sorry about the goto, but with all these ifdefs ...
4352c5837f37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1653
diff changeset
  7643
	 */
4352c5837f37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1653
diff changeset
  7644
	goto done;
4352c5837f37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1653
diff changeset
  7645
    }
4352c5837f37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1653
diff changeset
  7646
#  endif /*!HAS_WAIT3*/
4352c5837f37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1653
diff changeset
  7647
# endif  /*!HAS_WAITPID*/
4352c5837f37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1653
diff changeset
  7648
2098
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7649
# if !defined(WIFEXITED)
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7650
#  define WIFEXITED(stat)      (((int)((stat)&0377))==0)
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7651
#  define WIFSIGNALED(stat)    (((int)((stat)&0377))>0&&((int)(((stat)>>8)&0377))==0)
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7652
#  define WIFSTOPPED(stat)     (((int)((stat)&0377))==0177&&((int)(((stat)>>8)&0377))!=0)
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7653
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7654
#  define WEXITSTATUS(stat)    ((int)(((stat)>>8)&0377))
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7655
#  define WTERMSIG(stat)       (((int)((stat)&0377))&0177)
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7656
#  define WSTOPSIG(stat)       ((int)(((stat)>>8)&0377))
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7657
# endif /*!WIFEXITED*/
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7658
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7659
# if !defined(WCOREDUMP)
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7660
#  define WCOREDUMP(stat)      ((int)(((stat)>>8)&0200))
8790a0a6b214 WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  7661
# endif /*!WCOREDUMP*/
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7662
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7663
# if __BLOCKING_WAIT__
1433
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  7664
    __BEGIN_INTERRUPTABLE__
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7665
# endif
1433
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  7666
840
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7667
    do {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7668
	p = __WAIT;
840
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7669
    } while (p == -1 && errno == EINTR);
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7670
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7671
# if __BLOCKING_WAIT__
1433
8b2eacaea59c Getdomainname for Unixware.
Stefan Vogel <sv@exept.de>
parents: 1422
diff changeset
  7672
    __END_INTERRUPTABLE__
1654
4352c5837f37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1653
diff changeset
  7673
#   undef __BLOCKING_WAIT__
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7674
# endif
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7675
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7676
# undef __WAIT
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7677
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7678
    if (p == 0)
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7679
	RETURN(nil)
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7680
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7681
    if (p == -1) {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7682
	if (errno == ECHILD)
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7683
	    RETURN(nil);
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7684
    } else {
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7685
	pid = __MKSMALLINT(p);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7686
	if (WIFEXITED(s)) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7687
	    status = @symbol(exit);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7688
	    code = __MKSMALLINT(WEXITSTATUS(s));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7689
	    core = WCOREDUMP(s) ? true : false;
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7690
	} else if (WIFSIGNALED(s)) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7691
	    status = @symbol(signal);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7692
	    code = __MKSMALLINT(WTERMSIG(s));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7693
	} else if (WIFSTOPPED(s)) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7694
	    status = @symbol(stop);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7695
	    code = __MKSMALLINT(WSTOPSIG(s));
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7696
	}
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7697
# if defined(WIFCONTINUED)
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7698
	else if (WIFCONTINUED(s)) {
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7699
	    status = @symbol(continue);
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7700
	} 
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7701
# endif
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7702
    }
840
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7703
done: ;
1597
f35cd92a7648 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
  7704
#endif /* UNIX_LIKE */
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7705
%}.
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7706
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7707
    pid isNil ifTrue:[
1487
349bf72ca044 nt fixes
Claus Gittinger <cg@exept.de>
parents: 1470
diff changeset
  7708
	^ self primitiveFailed
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7709
    ].
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7710
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7711
    ^ OSProcessStatus pid:pid status:status code:code core:core
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7712
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7713
    "
840
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7714
     OperatingSystem childProcessWait:false
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7715
    "
840
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7716
523533898acd Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents: 832
diff changeset
  7717
    "Created: 5.1.1996 / 16:39:14 / stefan"
827
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7718
!
3eb3911cb63e Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  7719
10
claus
parents: 5
diff changeset
  7720
readCheck:fd
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7721
    "return true, if data is available on a filedescriptor (i.e. read
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7722
     is possible without blocking)"
10
claus
parents: 5
diff changeset
  7723
claus
parents: 5
diff changeset
  7724
    (self selectOnAnyReadable:(Array with:fd)
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7725
		     writable:nil
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7726
		    exception:nil
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7727
		  withTimeOut:0) == fd
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7728
	ifTrue:[^ true].
10
claus
parents: 5
diff changeset
  7729
    ^ false
claus
parents: 5
diff changeset
  7730
!
claus
parents: 5
diff changeset
  7731
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7732
selectOn:fd1 and:fd2 withTimeOut:millis
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7733
    "wait for any fd to become ready; timeout after t milliseconds.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7734
     A zero timeout-time will immediately return (i.e. poll).
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7735
     Return fd if i/o ok, nil if timed-out or interrupted.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7736
     Obsolete:
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7737
	This is a leftover method and will vanish."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7738
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7739
    ^ self selectOnAnyReadable:(Array with:fd1 with:fd2)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7740
		      writable:(Array with:fd1 with:fd2)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7741
		     exception:nil
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7742
		   withTimeOut:millis
10
claus
parents: 5
diff changeset
  7743
!
claus
parents: 5
diff changeset
  7744
claus
parents: 5
diff changeset
  7745
selectOn:fd withTimeOut:millis
claus
parents: 5
diff changeset
  7746
    "wait for aFileDesriptor to become ready; timeout after t milliseconds.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7747
     Return true, if i/o ok, false if timed-out or interrupted.
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7748
     With 0 as timeout argument, this can be used to check for availability
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7749
     of read-data.
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7750
     Experimental."
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7751
3
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
  7752
    ^ self selectOnAnyReadable:(Array with:fd)
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7753
		      writable:(Array with:fd)
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7754
		     exception:nil
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7755
		   withTimeOut:millis
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7756
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7757
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7758
selectOnAny:fdArray withTimeOut:millis
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7759
    "wait for any fd in fdArray (an Array of integers) to become ready;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7760
     timeout after t milliseconds. An empty set will always wait.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7761
     Return first ready fd if i/o ok, nil if timed-out or interrupted.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7762
     Experimental."
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7763
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7764
    ^ self selectOnAnyReadable:fdArray
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7765
		      writable:fdArray
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7766
		     exception:nil
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7767
		   withTimeOut:millis
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7768
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7769
10
claus
parents: 5
diff changeset
  7770
selectOnAnyReadable:fdArray withTimeOut:millis
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7771
    "wait for any fd in fdArray (an Array of integers) to become ready for 
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7772
     reading. Timeout after t milliseconds. An empty set will always wait.
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7773
     A zero timeout-time will immediately return (i.e. poll).
3
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
  7774
     Return first ready fd if i/o ok, nil if timed-out or interrupted.
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
  7775
     Experimental."
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
  7776
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
  7777
    ^ self selectOnAnyReadable:fdArray 
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7778
		      writable:nil 
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7779
		     exception:nil
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7780
		   withTimeOut:millis
3
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
  7781
!
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
  7782
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7783
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray withTimeOut:millis
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7784
    "wait for any fd in readFdArray (an Array of integers) to become ready for 
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7785
     reading, writeFdArray to become ready for writing, or exceptFdArray to 
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7786
     arrive exceptional data (i.e. out-of-band data).
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7787
     Timeout after t milliseconds or, if the timeout time is 0, immediately..
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7788
     Empty fd-sets will always wait. Zero time can be used to poll file-
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7789
     descriptors (i.e. to check if I/O possible without blocking).
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7790
     Return first ready fd if I/O ok, nil if timed-out or interrupted."
3
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
  7791
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7792
%{
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7793
#ifdef MSDOS_LIKE
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7794
    /*
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7795
     * support a delay-wait only
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7796
     * (i.e. fail if any filedescriptor is selected upon)
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7797
     */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7798
    int count;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7799
    int i;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7800
    int t;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7801
    OBJ fd;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7802
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7803
    if (! __isSmallInteger(millis)) {
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7804
	goto fail;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7805
    }
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7806
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7807
    if (readFdArray != nil) {
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  7808
	if (! __isArray(readFdArray)) {
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  7809
	    goto fail;  
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7810
	}
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7811
	count = __arraySize(readFdArray);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7812
	for (i=0; i<count;i++) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7813
	    fd = __ArrayInstPtr(readFdArray)->a_element[i];
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7814
	    if (fd != nil) {
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7815
		goto fail;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7816
	    }
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7817
	}
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7818
    }
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7819
    if (writeFdArray != nil) {
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7820
	if (! __isArray(writeFdArray)) {
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7821
	    goto fail;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7822
	}
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7823
	count = __arraySize(writeFdArray);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7824
	for (i=0; i<count;i++) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7825
	    fd = __ArrayInstPtr(writeFdArray)->a_element[i];
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7826
	    if (fd != nil) {
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7827
		goto fail;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7828
	    }
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7829
	}
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7830
    }
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7831
    if (exceptFdArray != nil) {
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7832
	if (! __isArray(exceptFdArray)) {
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7833
	    goto fail;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7834
	}
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7835
	count = __arraySize(exceptFdArray);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7836
	for (i=0; i<count;i++) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7837
	    fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7838
	    if (fd != nil) {
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7839
		goto fail;
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7840
	    }
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7841
	}
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7842
    }
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7843
    t = __intVal(millis);
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7844
    if (t != 0) {
947
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  7845
	/*
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  7846
	 * delay only 
2d067b1d716c added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents: 932
diff changeset
  7847
	 */
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7848
	Sleep(t);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7849
    }
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7850
    RETURN (nil);
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7851
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7852
#else /* not MSDOS_LIKE */
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7853
    fd_set rset, wset, eset;
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7854
    struct timeval wt, et;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7855
    int t, f, maxF, i, lX, bX;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7856
    OBJ fd, retFd;
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7857
    int ret;
300
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7858
    int count;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7859
252
  7860
    if (__isSmallInteger(millis)) {
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7861
	FD_ZERO(&rset);
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7862
	FD_ZERO(&wset);
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7863
	FD_ZERO(&eset);
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7864
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7865
	maxF = -1;
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7866
	if (readFdArray != nil) {
300
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7867
	    if (! __isArray(readFdArray)) {
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7868
		goto fail;    
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7869
	    }
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7870
	    count = __arraySize(readFdArray);
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7871
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7872
	    for (i=0; i<count;i++) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7873
		fd = __ArrayInstPtr(readFdArray)->a_element[i];
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7874
		if (fd != nil) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7875
		    f = __intVal(fd);
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7876
		    if ((f >= 0) && (f < FD_SETSIZE)) {
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7877
			FD_SET(f, &rset);
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7878
			if (f > maxF) maxF = f;
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7879
		    }
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7880
		}
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7881
	    }
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7882
	}
300
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7883
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7884
	if (writeFdArray != nil) {
300
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7885
	    if (! __isArray(writeFdArray)) {
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7886
		goto fail;    
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7887
	    }
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7888
	    count = __arraySize(writeFdArray);
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7889
	    for (i=0; i<count;i++) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7890
		fd = __ArrayInstPtr(writeFdArray)->a_element[i];
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7891
		if (fd != nil) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7892
		    f = __intVal(fd);
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7893
		    if ((f >= 0) && (f < FD_SETSIZE)) {
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7894
			FD_SET(f, &wset);       
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7895
			if (f > maxF) maxF = f;
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7896
		    }
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7897
		}
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7898
	    }
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7899
	}
300
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7900
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7901
	if (exceptFdArray != nil) {
300
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7902
	    if (! __isArray(exceptFdArray)) {
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7903
		goto fail;    
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7904
	    }
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7905
	    count = __arraySize(exceptFdArray);
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7906
	    for (i=0; i<count;i++) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7907
		fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7908
		if (fd != nil) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7909
		    f = __intVal(fd);
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7910
		    if ((f >= 0) && (f < FD_SETSIZE)) {
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7911
			FD_SET(f, &eset);       
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7912
			if (f > maxF) maxF = f;
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7913
		    }
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7914
		}
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7915
	    }
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7916
	}
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7917
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7918
	t = __intVal(millis);
774
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7919
	if (t) {
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7920
	    wt.tv_sec = t / 1000;
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7921
	    wt.tv_usec = (t % 1000) * 1000;
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7922
	} else {
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7923
	    wt.tv_sec = wt.tv_usec = 0;
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7924
	}
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7925
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7926
	/*
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7927
	 * make certain, that interrupt gets us out of the select
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7928
	 */
362
claus
parents: 359
diff changeset
  7929
	__BEGIN_INTERRUPTABLE__
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7930
	errno = 0;
774
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7931
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7932
	if (t == 0) {
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7933
	    /* 
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7934
	     * if there is no timeout time, we can stay here 
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7935
	     * interruptable.
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7936
	     */
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7937
	    do {
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7938
		ret = select(maxF+1, &rset, &wset, &eset, &wt);
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7939
	    } while ((ret < 0) && (errno == EINTR));
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7940
	} else {
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7941
	    do {
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  7942
		ret = select(maxF+1, &rset, &wset, &eset, &wt);
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  7943
		/* 
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  7944
		 * for now: dont loop; if we did, we had to adjust the vt-timeval;
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  7945
		 * could otherwise stay in this loop forever ...
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  7946
		 * Premature return (before the time expired) must be handled by the caller.
774
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7947
		 * A good solution is to update the wt-timeval and redo the select.
813
1f9611434418 first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents: 811
diff changeset
  7948
		 */
774
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7949
	    } while (0 /* (ret < 0) && (errno == EINTR) */ );
e0ee05157570 selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  7950
	}
362
claus
parents: 359
diff changeset
  7951
	__END_INTERRUPTABLE__
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
  7952
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7953
	if (ret > 0) {
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7954
	    for (i=0; i <= maxF; i++) {
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7955
		if (FD_ISSET(i, &rset)
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7956
		 || FD_ISSET(i, &wset)
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7957
		 || FD_ISSET(i, &eset)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7958
		    RETURN ( __MKSMALLINT(i) );
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7959
		}
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7960
	    }
855
2de3c842c687 dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  7961
	} else {
2de3c842c687 dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  7962
	    if (ret < 0) {
2de3c842c687 dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  7963
		if (errno != EINTR) {
1058
5d010b97ecb8 added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  7964
		    fprintf(stderr, "OS: select errno = %d\n", errno);
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  7965
		    OperatingSystem_LastErrorNumber = __MKSMALLINT(errno);
855
2de3c842c687 dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  7966
		}
2de3c842c687 dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  7967
	    }
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7968
	}
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  7969
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7970
	/*
2117
460b14a6db96 added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
  7971
	 * return nil (means time expired or interrupted)
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7972
	 */
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  7973
	RETURN ( nil );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7974
    }
831
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7975
#endif /* not MSDOS_LIKE */
bc2dac4b75fb merged in NT changes
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  7976
300
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7977
fail: ;
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  7978
%}.
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  7979
    "
300
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7980
     timeout argument not integer,
fe1f742a9224 *** empty log message ***
claus
parents: 275
diff changeset
  7981
     or any fd-array nonNil and not an array
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  7982
     or not supported by OS
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
  7983
    "
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  7984
    ^ self primitiveFailed
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7985
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  7986
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7987
setBlocking:aBoolean on:fd
1845
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7988
    "{ Pragma: +optSpace }"
9d7e909b61dd some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
  7989
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7990
    "set/clear the blocking attribute - if set (which is the default)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7991
     a read on the fileDescriptor will block until data is available.
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7992
     If cleared, a read operation will immediately return with a value of
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7993
     nil."
10
claus
parents: 5
diff changeset
  7994
claus
parents: 5
diff changeset
  7995
%{  /* NOCONTEXT */
claus
parents: 5
diff changeset
  7996
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7997
    int ret, flags;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7998
    int savInt;
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  7999
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8000
#if defined(F_GETFL) && defined(F_SETFL)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8001
# if defined(FNDELAY)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8002
    if (__isSmallInteger(fd)) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  8003
	int f = __intVal(fd);
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  8004
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  8005
	flags = fcntl(f, F_GETFL, 0);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8006
	if (aBoolean == true) {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  8007
	    ret = fcntl(f, F_SETFL, flags & ~FNDELAY);
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8008
	} else {
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  8009
	    ret = fcntl(f, F_SETFL, flags | FNDELAY);
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  8010
	}
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8011
	if (ret >= 0) ret = flags;
1135
7fcefc747f00 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1132
diff changeset
  8012
	RETURN ( __MKSMALLINT(ret) );
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  8013
    }
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8014
# endif
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  8015
#endif
308
f04744ef7b5d *** empty log message ***
claus
parents: 300
diff changeset
  8016
%}.
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  8017
    "
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8018
     fd argument not integer
185
d9be85c4cfe4 more functions
claus
parents: 123
diff changeset
  8019
    "
792
06ec639ead96 changes for NT;
Claus Gittinger <cg@exept.de>
parents: 774
diff changeset
  8020
    ^ self primitiveFailed
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  8021
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  8022
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8023
writeCheck:fd
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8024
    "return true, if filedescriptor can be written without blocking"
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8025
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8026
    (self selectOnAnyReadable:nil
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8027
		     writable:(Array with:fd)
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8028
		    exception:nil
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8029
		  withTimeOut:0) == fd
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8030
	ifTrue:[^ true].
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8031
    ^ false
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  8032
! !
434
0511ecb7c818 *** empty log message ***
claus
parents: 433
diff changeset
  8033
1966
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8034
!OperatingSystem::OSProcessStatus class methodsFor:'documentation'!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8035
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8036
documentation
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8037
"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8038
    This is an auxillary class, that holds information about status changes of
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8039
    operating system processes (these are no smalltalk processes!!).
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8040
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8041
    [Instance variables:]
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8042
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8043
	pid     <Integer>       OS-Process identifier
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8044
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8045
	status  <Symbol>        either #exit #signal #stop #continue
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8046
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8047
	code    <Integer>       either exitcode or signalnumber
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8048
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8049
	core    <Boolean>       true if core has been dumped
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8050
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8051
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8052
    [author:]
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8053
	Stefan Vogel
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8054
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8055
    [see also:]
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8056
	OperatingSystem
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8057
"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8058
! !
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8059
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8060
!OperatingSystem::OSProcessStatus class methodsFor:'instance creation'!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8061
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8062
pid:pid status:status code:code core:core
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8063
    "private interface for OperatingSystem"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8064
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8065
    ^ self new pid:pid status:status code:code core:core
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8066
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8067
    "Created: 28.12.1995 / 14:16:14 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8068
    "Modified: 30.4.1996 / 18:25:00 / cg"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8069
!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8070
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8071
processCreationFailure
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8072
    "private interface for OperatingSystem"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8073
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8074
    ^ self new pid:-1 status:#failure code:-1 core:false
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8075
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8076
    "Created: 28.12.1995 / 14:35:29 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8077
    "Modified: 30.4.1996 / 18:25:05 / cg"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8078
! !
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8079
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8080
!OperatingSystem::OSProcessStatus methodsFor:'accessing'!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8081
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8082
code
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8083
    "return the exitcode / signalNumber"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8084
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8085
    ^ code
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8086
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8087
    "Created: 28.12.1995 / 14:05:07 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8088
    "Modified: 30.4.1996 / 18:26:23 / cg"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8089
!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8090
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8091
core
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8092
    "return true if core has been dumped, false otherwise"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8093
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8094
    ^ core == true
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8095
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8096
    "Modified: 28.12.1995 / 14:14:38 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8097
!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8098
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8099
pid
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8100
    "return the pid"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8101
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8102
    ^ pid
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8103
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8104
    "Created: 28.12.1995 / 14:05:07 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8105
    "Modified: 30.4.1996 / 18:26:30 / cg"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8106
!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8107
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8108
status
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8109
    "return status as a Symbol;
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8110
     one of #exit #signal #stop #continue"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8111
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8112
    ^ status
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8113
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8114
    "Created: 28.12.1995 / 14:05:07 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8115
    "Modified: 30.4.1996 / 18:26:54 / cg"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8116
! !
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8117
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8118
!OperatingSystem::OSProcessStatus methodsFor:'initialization'!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8119
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8120
pid:newPid status:newStatus code:newCode core:newCore
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8121
    pid := newPid.
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8122
    status := newStatus.
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8123
    code := newCode.
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8124
    core := newCore.
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8125
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8126
    "Created: 28.12.1995 / 14:18:22 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8127
! !
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8128
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8129
!OperatingSystem::OSProcessStatus methodsFor:'private-OS interface'!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8130
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8131
code:something
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8132
    "set the exitCode"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8133
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8134
    code := something.
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8135
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8136
    "Created: 28.12.1995 / 14:05:07 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8137
    "Modified: 30.4.1996 / 18:25:18 / cg"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8138
!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8139
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8140
core:something
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8141
    "set core"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8142
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8143
    core := something.
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8144
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8145
    "Created: 28.12.1995 / 14:05:07 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8146
!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8147
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8148
pid:something
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8149
    "set pid"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8150
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8151
    pid := something.
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8152
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8153
    "Created: 28.12.1995 / 14:05:07 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8154
!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8155
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8156
status:something
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8157
    "set status"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8158
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8159
    status := something.
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8160
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8161
    "Created: 28.12.1995 / 14:05:07 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8162
! !
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8163
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8164
!OperatingSystem::OSProcessStatus methodsFor:'queries'!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8165
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8166
couldNotExecute
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8167
    "return true when a command could not be executed"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8168
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8169
    ^ status == #exit and:[code = 127].
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8170
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8171
    "Created: 28.12.1995 / 15:43:17 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8172
    "Modified: 30.4.1996 / 18:27:03 / cg"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8173
!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8174
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8175
stillAlive
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8176
    "true if process is still alive"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8177
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8178
    ^ status == #stop or:[status == #continue]
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8179
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8180
    "Created: 28.12.1995 / 14:27:26 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8181
!
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8182
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8183
success
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8184
    "true if process terminated successfully"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8185
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8186
    ^ status == #exit and:[code = 0]
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8187
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8188
    "Created: 28.12.1995 / 14:13:05 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8189
    "Modified: 28.12.1995 / 14:13:41 / stefan"
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8190
! !
8b14cce1442b Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents: 1885
diff changeset
  8191
2080
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8192
!OperatingSystem::FileStatusInfo class methodsFor:'instance creation'!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8193
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8194
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8195
    ^ self basicNew
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8196
	type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP       
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8197
! !
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8198
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8199
!OperatingSystem::FileStatusInfo methodsFor:'accessing'!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8200
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8201
accessed
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8202
    "return accessed"
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8203
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8204
    ^ accessed!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8205
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8206
gid
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8207
    "return gid"
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8208
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8209
    ^ gid!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8210
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8211
id
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8212
    "return id"
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8213
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8214
    ^ id!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8215
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8216
mode
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8217
    "return mode"
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8218
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8219
    ^ mode!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8220
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8221
modified
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8222
    "return modified"
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8223
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8224
    ^ modified!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8225
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8226
path
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8227
    "for symbolic links only: return the path where the symbolic link points to"
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8228
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8229
    ^ path
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8230
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8231
!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8232
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8233
size
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8234
    "return size"
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8235
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8236
    ^ size!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8237
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8238
statusChanged
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8239
    "return statusChanged"
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8240
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8241
    ^ statusChanged!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8242
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8243
type
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8244
    "return type"
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8245
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8246
    ^ type!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8247
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8248
uid
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8249
    "return uid"
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8250
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8251
    ^ uid! !
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8252
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8253
!OperatingSystem::FileStatusInfo methodsFor:'backward compatibility'!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8254
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8255
at:key
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8256
    "backward compatibility access: in previous releases, IdentityDictionaries
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8257
     were used to hold my information. Allow access via key messages.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8258
     This method will vanish - use the proper access protocol."
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8259
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8260
    ^ self perform:key
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8261
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8262
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8263
! !
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8264
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8265
!OperatingSystem::FileStatusInfo methodsFor:'private accessing'!
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8266
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8267
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8268
    type := t.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8269
    mode := m.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8270
    uid := u.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8271
    gid := g.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8272
    size := s.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8273
    id := i.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8274
    accessed := aT.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8275
    modified := mT.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8276
    statusChanged := sT.
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8277
    path := lP
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8278
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8279
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8280
! !
d93d4af439d7 Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents: 2073
diff changeset
  8281
1799
0a2c5890f4f3 handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents: 1702
diff changeset
  8282
!OperatingSystem class methodsFor:'documentation'!
630
b785d23d7c5b version at the end
Claus Gittinger <cg@exept.de>
parents: 616
diff changeset
  8283
b785d23d7c5b version at the end
Claus Gittinger <cg@exept.de>
parents: 616
diff changeset
  8284
version
2126
d3da2956f380 NEXT has no waitpid
Claus Gittinger <cg@exept.de>
parents: 2117
diff changeset
  8285
    ^ '$Header: /cvs/stx/stx/libbasic/Attic/Unix.st,v 1.188 1997-01-10 15:23:40 cg Exp $'
630
b785d23d7c5b version at the end
Claus Gittinger <cg@exept.de>
parents: 616
diff changeset
  8286
! !
616
8226d2eb1e3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
  8287
OperatingSystem initialize!