author | Claus Gittinger <cg@exept.de> |
Thu, 09 Jan 1997 00:50:51 +0100 | |
changeset 2098 | 8790a0a6b214 |
parent 2080 | d93d4af439d7 |
child 2107 | 9987b837fe12 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
185 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
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 | 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 | 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 | 22 |
! |
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 | 38 |
!OperatingSystem primitiveDefinitions! |
406 | 39 |
%{ |
792 | 40 |
#define UNIX_LIKE |
41 |
||
831 | 42 |
#if defined(MSWINDOWS) || defined(OS2) || defined(MSDOS) || defined(WIN32) |
792 | 43 |
# ifndef MSDOS_LIKE |
44 |
# define MSDOS_LIKE |
|
45 |
# endif |
|
46 |
# undef UNIX_LIKE |
|
831 | 47 |
# ifdef i386 |
48 |
# define _X86_ |
|
49 |
# endif |
|
792 | 50 |
#endif |
51 |
||
52 |
#if defined(transputer) |
|
53 |
# undef MSDOS_LIKE |
|
54 |
# undef UNIX_LIKE |
|
55 |
#endif |
|
56 |
||
443 | 57 |
#if defined(_AIX) |
439 | 58 |
# ifndef WANT_REALPATH |
59 |
# define WANT_REALPATH |
|
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 | 64 |
#endif |
65 |
||
433 | 66 |
#ifdef LINUX |
1142 | 67 |
/* use inline string macros */ |
68 |
# define __STRINGDEFS__ |
|
69 |
# include <linuxIntern.h> |
|
70 |
||
439 | 71 |
# ifndef WANT_SYSTEM |
72 |
# define WANT_SYSTEM |
|
73 |
# endif |
|
443 | 74 |
# define WANT_SHM |
433 | 75 |
#endif |
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 | 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 | 97 |
/* |
98 |
* notice: although many systems' include files |
|
99 |
* already block against multiple inclusion, some |
|
100 |
* do not. Therefore, this is done here again. |
|
101 |
* (it does not hurt) |
|
102 |
*/ |
|
103 |
||
439 | 104 |
#ifdef WANT_REALPATH |
831 | 105 |
|
439 | 106 |
# include <sys/param.h> |
107 |
# define _SYS_PARAM_H_INCLUDED_ |
|
108 |
||
109 |
# include <errno.h> |
|
110 |
# define _ERRNO_H_INCLUDED_ |
|
111 |
||
112 |
# include <sys/stat.h> |
|
113 |
# define _SYS_STAT_H_INCLUDED_ |
|
443 | 114 |
|
439 | 115 |
#endif /* WANT_REALPATH */ |
116 |
||
831 | 117 |
|
118 |
||
434 | 119 |
#ifdef WANT_SHM |
443 | 120 |
extern int shmctl(), shmget(), shmdt(); |
121 |
extern char * shmat(); |
|
122 |
||
434 | 123 |
# include <sys/types.h> |
437 | 124 |
# define _SYS_TYPES_H_INCLUDED_ |
439 | 125 |
|
434 | 126 |
# include <sys/ipc.h> |
437 | 127 |
# define _SYS_IPC_H_INCLUDED_ |
439 | 128 |
|
434 | 129 |
# include <sys/shm.h> |
437 | 130 |
# define _SYS_SHM_H_INCLUDED_ |
831 | 131 |
|
439 | 132 |
#endif /* WANT_SHM */ |
434 | 133 |
|
831 | 134 |
|
434 | 135 |
#ifdef IRIX5 |
136 |
# include <sys/syssgi.h> |
|
137 |
#endif |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
138 |
|
831 | 139 |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
140 |
#ifdef transputer |
831 | 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 | 143 |
|
144 |
#else /* not transputer */ |
|
145 |
||
146 |
# ifndef _SIGNAL_H_INCLUDED_ |
|
147 |
# include <signal.h> |
|
148 |
# define _SIGNAL_H_INCLUDED_ |
|
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 | 152 |
# ifndef _SYS_TYPES_H_INCLUDED_ |
153 |
# include <sys/types.h> |
|
154 |
# define _SYS_TYPES_H_INCLUDED_ |
|
155 |
# endif |
|
156 |
# ifndef _SYS_PARAM_H_INCLUDED_ |
|
157 |
# include <sys/param.h> |
|
158 |
# define _SYS_PARAM_H_INCLUDED_ |
|
159 |
# endif |
|
160 |
# ifndef _SYS_TIMES_H_INCLUDED_ |
|
161 |
# include <sys/times.h> |
|
162 |
# define _SYS_TIMES_H_INCLUDED_ |
|
163 |
# endif |
|
164 |
# ifndef _SYS_FILE_H_INCLUDED_ |
|
165 |
# include <sys/file.h> |
|
166 |
# define _SYS_FILE_H_INCLUDED_ |
|
167 |
# endif |
|
168 |
||
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
169 |
# if ! defined(sco3_2) |
831 | 170 |
# ifndef _UNISTD_H_INCLUDED_ |
171 |
# include <unistd.h> |
|
172 |
# define _UNISTD_H_INCLUDED_ |
|
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 | 177 |
# ifndef _SYS_TIME_H_INCLUDED_ |
178 |
# include <sys/time.h> |
|
179 |
# define _SYS_TIME_H_INCLUDED_ |
|
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 | 188 |
# ifndef _TIME_H_INCLUDED_ |
189 |
# include <time.h> |
|
190 |
# define _TIME_H_INCLUDED_ |
|
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 | 201 |
# ifdef MSDOS_LIKE |
831 | 202 |
|
203 |
# ifndef _SYS_TYPES_H_INCLUDED_ |
|
1987 | 204 |
# include <types.h> |
831 | 205 |
# define _SYS_TYPES_H_INCLUDED_ |
206 |
# endif |
|
207 |
# ifndef _TIME_H_INCLUDED_ |
|
1987 | 208 |
# include <C:\mstools\h\time.h> |
831 | 209 |
# define _TIME_H_INCLUDED_ |
210 |
# endif |
|
211 |
# ifndef _SYS_TIMEB_H_INCLUDED_ |
|
1987 | 212 |
# include <timeb.h> |
831 | 213 |
# define _SYS_TIMEB_H_INCLUDED_ |
214 |
# endif |
|
215 |
||
216 |
# else /* not MSDOS_like */ |
|
217 |
||
218 |
# ifndef _SYS_TIME_H_INCLUDED_ |
|
219 |
# include <sys/time.h> |
|
220 |
# define _SYS_TIME_H_INCLUDED_ |
|
221 |
# endif |
|
222 |
# ifndef _SYS_TYPES_H_INCLUDED_ |
|
223 |
# include <sys/types.h> |
|
224 |
# define _SYS_TYPES_H_INCLUDED_ |
|
225 |
# endif |
|
226 |
||
227 |
# endif /* not MSDOS */ |
|
792 | 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 | 231 |
|
232 |
# ifndef _TIME_H_INCLUDED_ |
|
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 | 235 |
# endif |
236 |
# ifndef _SYS_SELECT_H_INCLUDED_ |
|
237 |
# include <sys/select.h> |
|
238 |
# define _SYS_SELECT_H_INCLUDED_ |
|
239 |
# endif |
|
240 |
||
792 | 241 |
# endif /* aix */ |
242 |
||
243 |
# ifndef MSDOS_LIKE |
|
244 |
# include <pwd.h> |
|
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 | 248 |
# ifndef _SYS_STAT_H_INCLUDED_ |
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 | 254 |
# ifndef WIN32 |
255 |
# include <sys/file.h> |
|
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 | 258 |
# endif |
259 |
||
260 |
# ifndef _ERRNO_H_INCLUDED_ |
|
261 |
# include <errno.h> |
|
262 |
# define _ERRNO_H_INCLUDED_ |
|
263 |
# endif |
|
264 |
||
265 |
# ifndef _STDIO_H_INCLUDED_ |
|
266 |
# include <stdio.h> |
|
267 |
# define _STDIO_H_INCLUDED_ |
|
268 |
# endif |
|
269 |
||
270 |
# ifndef _FCNTL_H_INCLUDED_ |
|
271 |
# include <fcntl.h> |
|
272 |
# define _FCNTL_H_INCLUDED_ |
|
273 |
# endif |
|
274 |
||
275 |
# ifdef WIN32 |
|
1632 | 276 |
# define USE_TimerProc |
277 |
||
278 |
# undef INT |
|
279 |
# undef Array |
|
280 |
# undef Number |
|
281 |
# undef Method |
|
282 |
# undef Point |
|
283 |
# undef Rectangle |
|
1987 | 284 |
# undef Block |
831 | 285 |
|
286 |
/* # include <windows.h> /* */ |
|
1987 | 287 |
# include <stdarg.h> /* */ |
288 |
# include <windef.h> /* */ |
|
289 |
# include <winbase.h> /* */ |
|
290 |
# include <wingdi.h> /* */ |
|
291 |
# include <winuser.h> /* */ |
|
831 | 292 |
|
1632 | 293 |
# ifndef USE_TimerProc |
1987 | 294 |
# include <mmsystem.h> /* */ |
1632 | 295 |
# else |
296 |
static UINT w32TimerId; |
|
297 |
# endif |
|
298 |
||
299 |
# ifdef __DEF_Array |
|
300 |
# define Array __DEF_Array |
|
301 |
# endif |
|
302 |
# ifdef __DEF_Number |
|
303 |
# define Number __DEF_Number |
|
304 |
# endif |
|
305 |
# ifdef __DEF_Method |
|
306 |
# define Method __DEF_Method |
|
307 |
# endif |
|
308 |
# ifdef __DEF_Point |
|
309 |
# define Point __DEF_Point |
|
310 |
# endif |
|
1987 | 311 |
# ifdef __DEF_Block |
312 |
# define Block __DEF_Block |
|
313 |
# endif |
|
1632 | 314 |
|
315 |
# define stat _stat |
|
316 |
||
317 |
# endif /* WIN32 */ |
|
831 | 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 | 362 |
# ifndef MSDOS_LIKE |
363 |
# include <sys/param.h> |
|
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 | 367 |
# define MAXPATHLEN FILENAME_MAX |
368 |
# else |
|
369 |
# define MAXPATHLEN 1024 |
|
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 | 383 |
* NeXT has no pid_t |
384 |
*/ |
|
385 |
# ifdef NEXT |
|
386 |
typedef int pid_t; |
|
387 |
# endif |
|
388 |
||
389 |
/* |
|
390 |
* some (BSD ?) have no timezone |
|
391 |
*/ |
|
392 |
# if defined(ultrix) || defined(sunos) || defined(NEXT) |
|
393 |
# define HAS_NO_TIMEZONE |
|
394 |
# endif |
|
395 |
||
396 |
/* |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
397 |
* 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
|
398 |
*/ |
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
399 |
# ifndef SA_RESTART |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
400 |
# 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
|
401 |
# endif |
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
402 |
# ifndef SA_SIGINFO |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
403 |
# 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
|
404 |
# endif |
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
405 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
406 |
# 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
|
407 |
# include <sys/wait.h> |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
408 |
# endif |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
409 |
|
1433 | 410 |
# if defined(HAS_SYSINFO) |
411 |
# include <sys/systeminfo.h> |
|
412 |
# endif |
|
413 |
||
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
414 |
#endif /* not transputer */ |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
415 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
416 |
/* |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
417 |
* 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
|
418 |
*/ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
419 |
#ifndef errno |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
420 |
extern errno; |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
421 |
#endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
422 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
423 |
/* |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
424 |
* some (old ?) systems do not define this ... |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
425 |
*/ |
675 | 426 |
#if !defined(R_OK) && !defined(_AIX) |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
427 |
# define R_OK 4 /* Test for Read permission */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
428 |
# define W_OK 2 /* Test for Write permission */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
429 |
# define X_OK 1 /* Test for eXecute permission */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
430 |
# define F_OK 0 /* Test for existence of File */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
431 |
#endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
432 |
|
832 | 433 |
#ifdef WIN32 |
434 |
# define SIGHANDLER_ARG int |
|
435 |
#else |
|
436 |
# define SIGHANDLER_ARG |
|
437 |
#endif |
|
438 |
||
1441 | 439 |
#ifdef sunos |
440 |
# define NO_WAITPID |
|
441 |
#endif |
|
442 |
||
437 | 443 |
%} |
444 |
! ! |
|
445 |
||
446 |
!OperatingSystem primitiveFunctions! |
|
447 |
%{ |
|
448 |
||
449 |
/* |
|
450 |
* some systems' system() is broken in that it does not correctly |
|
451 |
* handle EINTR and returns failure even though it actually succeeded. |
|
452 |
* (LINUX is one of them) |
|
453 |
* Here is a fixed version. If you encounter EINTR returns from |
|
454 |
* OperatingSystem>>executeCommand, you ought to define WANT_SYSTEM |
|
455 |
* in the xxxIntern.h file to get this fixed version. |
|
456 |
* |
|
457 |
* As an added BONUS, this system() enables interrupts while waiting |
|
458 |
* 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
|
459 |
* (i.e. it is RT safe) |
437 | 460 |
*/ |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
461 |
|
433 | 462 |
#if defined(WANT_SYSTEM) |
463 |
||
434 | 464 |
/* # define DPRINTF(x) printf x */ |
465 |
# define DPRINTF(x) /* nothing */ |
|
433 | 466 |
|
437 | 467 |
# ifndef _STDDEF_H_INCLUDED_ |
468 |
# include <stddef.h> |
|
469 |
# define _STDDEF_H_INCLUDED_ |
|
470 |
# endif |
|
471 |
||
472 |
# ifndef _STDLIB_H_INCLUDED_ |
|
473 |
# include <stdlib.h> |
|
474 |
# define _STDLIB_H_INCLUDED_ |
|
475 |
# endif |
|
476 |
||
477 |
# ifndef _UNISTD_H_INCLUDED_ |
|
478 |
# include <unistd.h> |
|
479 |
# define _UNISTD_H_INCLUDED_ |
|
480 |
# endif |
|
481 |
||
482 |
# ifndef _SYS_WAIT_H_INCLUDED |
|
483 |
# include <sys/wait.h> |
|
484 |
# define _SYS_WAIT_H_INCLUDED |
|
485 |
# endif |
|
486 |
||
487 |
# ifndef _SIGNAL_H_INCLUDED_ |
|
488 |
# include <signal.h> |
|
489 |
# define _SIGNAL_H_INCLUDED_ |
|
490 |
# endif |
|
491 |
||
492 |
# ifndef _SYS_TYPES_H_INCLUDED_ |
|
493 |
# include <sys/types.h> |
|
494 |
# define _SYS_TYPES_H_INCLUDED_ |
|
495 |
# endif |
|
433 | 496 |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
497 |
# if (!defined(HAVE_GNU_LD) && !defined (__ELF__)) || !defined(LINUX) |
433 | 498 |
# define __environ environ |
512 | 499 |
# if !defined(LINUX) |
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
500 |
# define __sigemptyset sigemptyset |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
501 |
# define __sigaction sigaction |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
502 |
# define __sigaddset sigaddset |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
503 |
# define __sigprocmask sigprocmask |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
504 |
# define __execve execve |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
505 |
# define __wait wait |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
506 |
# define __waitpid waitpid |
674 | 507 |
# if defined(HAS_VFORK) |
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
508 |
# define FORK vfork |
514
81fa80a953e2
system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents:
513
diff
changeset
|
509 |
# else |
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
510 |
# define FORK fork |
514
81fa80a953e2
system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents:
513
diff
changeset
|
511 |
# endif |
512 | 512 |
# endif /* ! LINUX */ |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
513 |
extern char **environ; |
433 | 514 |
# endif |
515 |
||
516 |
# define SHELL_PATH "/bin/sh" /* Path of the shell. */ |
|
517 |
# define SHELL_NAME "sh" /* Name to give it. */ |
|
518 |
||
519 |
# ifndef FORK |
|
520 |
# define FORK __fork |
|
521 |
# endif |
|
522 |
||
523 |
# ifndef CONST |
|
524 |
# ifdef __GNUC__ |
|
525 |
# define CONST const |
|
526 |
# else |
|
527 |
# define CONST /* nothing */ |
|
528 |
# endif |
|
529 |
# endif |
|
530 |
||
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
531 |
static int |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
532 |
mySystem(line) |
433 | 533 |
register CONST char *line; |
534 |
{ |
|
535 |
int status, save; |
|
536 |
pid_t pid; |
|
537 |
struct sigaction sa, intr, quit; |
|
538 |
sigset_t block, omask; |
|
539 |
||
540 |
if (line == NULL) |
|
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
541 |
return -1; |
433 | 542 |
|
543 |
sa.sa_handler = SIG_IGN; |
|
544 |
sa.sa_flags = 0; |
|
545 |
__sigemptyset (&sa.sa_mask); |
|
546 |
||
547 |
if (__sigaction (SIGINT, &sa, &intr) < 0) { |
|
548 |
DPRINTF(("1: errno=%d\n", errno)); |
|
549 |
return -1; |
|
550 |
} |
|
551 |
if (__sigaction (SIGQUIT, &sa, &quit) < 0) { |
|
552 |
save = errno; |
|
553 |
(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL); |
|
554 |
errno = save; |
|
555 |
DPRINTF(("2: errno=%d\n", errno)); |
|
556 |
return -1; |
|
557 |
} |
|
558 |
||
559 |
__sigemptyset (&block); |
|
560 |
__sigaddset (&block, SIGCHLD); |
|
561 |
save = errno; |
|
562 |
if (__sigprocmask(SIG_BLOCK, &block, &omask) < 0) { |
|
563 |
if (errno == ENOSYS) |
|
564 |
errno = save; |
|
565 |
else { |
|
566 |
save = errno; |
|
567 |
(void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL); |
|
568 |
(void) __sigaction(SIGQUIT, &quit, (struct sigaction *) NULL); |
|
569 |
errno = save; |
|
570 |
DPRINTF(("3: errno=%d\n", errno)); |
|
571 |
return -1; |
|
572 |
} |
|
573 |
} |
|
574 |
||
575 |
pid = FORK (); |
|
576 |
if (pid == (pid_t) 0) { |
|
577 |
/* Child side. */ |
|
578 |
CONST char *new_argv[4]; |
|
579 |
new_argv[0] = SHELL_NAME; |
|
580 |
new_argv[1] = "-c"; |
|
581 |
new_argv[2] = line; |
|
582 |
new_argv[3] = NULL; |
|
583 |
||
584 |
/* Restore the signals. */ |
|
585 |
(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL); |
|
586 |
(void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL); |
|
587 |
(void) __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL); |
|
588 |
||
589 |
/* Exec the shell. */ |
|
590 |
(void) __execve (SHELL_PATH, (char *CONST *) new_argv, __environ); |
|
591 |
_exit (127); |
|
592 |
} else { |
|
593 |
if (pid < (pid_t) 0) { |
|
594 |
/* The fork failed. */ |
|
595 |
DPRINTF(("4: errno=%d\n", errno)); |
|
596 |
status = -1; |
|
597 |
} else { |
|
598 |
/* Parent side. */ |
|
599 |
#ifdef NO_WAITPID |
|
600 |
pid_t child; |
|
601 |
||
602 |
do { |
|
805 | 603 |
__BEGIN_INTERRUPTABLE__ |
433 | 604 |
child = __wait (&status); |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
605 |
__END_INTERRUPTABLE__ |
805 | 606 |
if (child < 0 && errno != EINTR) { |
433 | 607 |
DPRINTF(("5: errno=%d\n", errno)); |
608 |
status = -1; |
|
609 |
break; |
|
610 |
} |
|
611 |
} while (child != pid); |
|
612 |
#else |
|
613 |
pid_t child; |
|
614 |
||
615 |
/* claus: the original did not care for EINTR here ... */ |
|
616 |
do { |
|
805 | 617 |
__BEGIN_INTERRUPTABLE__ |
433 | 618 |
child = __waitpid (pid, &status, 0); |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
619 |
__END_INTERRUPTABLE__ |
433 | 620 |
} while ((child != pid) && (errno == EINTR)); |
621 |
if (child != pid) { |
|
622 |
DPRINTF(("6: errno=%d\n", errno)); |
|
623 |
status = -1; |
|
624 |
} |
|
625 |
#endif /* NO_WAITPID */ |
|
626 |
} |
|
627 |
} |
|
628 |
save = errno; |
|
629 |
if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL) |
|
630 |
| __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL) |
|
631 |
| __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)) != 0) { |
|
632 |
if (errno == ENOSYS) { |
|
633 |
errno = save; |
|
634 |
} else { |
|
635 |
status = -1; |
|
636 |
DPRINTF(("7: errno=%d\n", errno)); |
|
637 |
} |
|
638 |
} |
|
639 |
||
640 |
return status; |
|
641 |
} |
|
1441 | 642 |
#else |
1487 | 643 |
# define __wait wait |
433 | 644 |
#endif /* WANT_SYSTEM */ |
645 |
||
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
646 |
|
433 | 647 |
/* |
648 |
* some systems do not have realpath(); |
|
649 |
* the alternative of reading from a 'pwp'-pipe |
|
650 |
* is way too slow. Here is a realpath for the rest of us. |
|
440 | 651 |
* define WANT_REALPATH in the xxxIntern-file to get it. |
433 | 652 |
*/ |
443 | 653 |
|
440 | 654 |
#if defined(HAS_REALPATH) |
655 |
# undef WANT_REALPATH |
|
656 |
#endif |
|
657 |
#if !defined(HAS_GETWD) && !defined(HAS_GETCWD) |
|
658 |
# undef WANT_REALPATH |
|
659 |
#endif |
|
660 |
||
661 |
#if defined(WANT_REALPATH) |
|
406 | 662 |
|
663 |
# ifndef NULL |
|
664 |
# define NULL (char *)0 |
|
665 |
# endif |
|
666 |
||
439 | 667 |
# define MAX_READLINKS 32 |
668 |
||
669 |
# ifndef MAXPATHLEN |
|
670 |
# define MAXPATHLEN 1024 |
|
671 |
# endif |
|
406 | 672 |
|
673 |
static |
|
674 |
char *realpath(path, resolved_path) |
|
675 |
char *path; |
|
676 |
char resolved_path []; |
|
677 |
{ |
|
678 |
char copy_path[MAXPATHLEN]; |
|
679 |
char link_path[MAXPATHLEN]; |
|
680 |
char *new_path = resolved_path; |
|
681 |
char *max_path; |
|
682 |
int readlinks = 0; |
|
683 |
int n; |
|
684 |
||
685 |
/* Make a copy of the source path since we may need to modify it. */ |
|
686 |
strcpy(copy_path, path); |
|
687 |
path = copy_path; |
|
688 |
max_path = copy_path + MAXPATHLEN - 2; |
|
689 |
/* If it's a relative pathname use getwd for starters. */ |
|
690 |
if (*path != '/') { |
|
691 |
#ifdef HAS_GETCWD |
|
692 |
getcwd(new_path, MAXPATHLEN - 1); |
|
693 |
#else |
|
694 |
getwd(new_path); |
|
695 |
#endif |
|
696 |
new_path += strlen(new_path); |
|
697 |
if (new_path[-1] != '/') |
|
698 |
*new_path++ = '/'; |
|
699 |
} |
|
700 |
else { |
|
701 |
*new_path++ = '/'; |
|
702 |
path++; |
|
703 |
} |
|
704 |
/* Expand each slash-separated pathname component. */ |
|
705 |
while (*path != '\0') { |
|
706 |
/* Ignore stray "/". */ |
|
707 |
if (*path == '/') { |
|
708 |
path++; |
|
709 |
continue; |
|
710 |
} |
|
711 |
if (*path == '.') { |
|
712 |
/* Ignore ".". */ |
|
713 |
if (path[1] == '\0' || path[1] == '/') { |
|
714 |
path++; |
|
715 |
continue; |
|
716 |
} |
|
717 |
if (path[1] == '.') { |
|
718 |
if (path[2] == '\0' || path[2] == '/') { |
|
719 |
path += 2; |
|
720 |
/* Ignore ".." at root. */ |
|
721 |
if (new_path == resolved_path + 1) |
|
722 |
continue; |
|
723 |
/* Handle ".." by backing up. */ |
|
724 |
while ((--new_path)[-1] != '/') |
|
725 |
; |
|
726 |
continue; |
|
727 |
} |
|
728 |
} |
|
729 |
} |
|
730 |
/* Safely copy the next pathname component. */ |
|
731 |
while (*path != '\0' && *path != '/') { |
|
732 |
if (path > max_path) { |
|
733 |
errno = ENAMETOOLONG; |
|
734 |
return NULL; |
|
735 |
} |
|
736 |
*new_path++ = *path++; |
|
737 |
} |
|
738 |
#ifdef S_IFLNK |
|
739 |
/* Protect against infinite loops. */ |
|
740 |
if (readlinks++ > MAX_READLINKS) { |
|
741 |
errno = ELOOP; |
|
742 |
return NULL; |
|
743 |
} |
|
744 |
/* See if latest pathname component is a symlink. */ |
|
745 |
*new_path = '\0'; |
|
746 |
n = readlink(resolved_path, link_path, MAXPATHLEN - 1); |
|
747 |
if (n < 0) { |
|
748 |
/* EINVAL means the file exists but isn't a symlink. */ |
|
749 |
if (errno != EINVAL) |
|
750 |
return NULL; |
|
751 |
} |
|
752 |
else { |
|
753 |
/* Note: readlink doesn't add the null byte. */ |
|
754 |
link_path[n] = '\0'; |
|
755 |
if (*link_path == '/') |
|
756 |
/* Start over for an absolute symlink. */ |
|
757 |
new_path = resolved_path; |
|
758 |
else |
|
759 |
/* Otherwise back up over this component. */ |
|
760 |
while (*(--new_path) != '/') |
|
761 |
; |
|
762 |
/* Safe sex check. */ |
|
763 |
if (strlen(path) + n >= MAXPATHLEN) { |
|
764 |
errno = ENAMETOOLONG; |
|
765 |
return NULL; |
|
766 |
} |
|
767 |
/* Insert symlink contents into path. */ |
|
768 |
strcat(link_path, path); |
|
769 |
strcpy(copy_path, link_path); |
|
770 |
path = copy_path; |
|
771 |
} |
|
772 |
#endif /* S_IFLNK */ |
|
773 |
*new_path++ = '/'; |
|
774 |
} |
|
775 |
/* Delete trailing slash but don't whomp a lone slash. */ |
|
776 |
if (new_path != resolved_path + 1 && new_path[-1] == '/') |
|
777 |
new_path--; |
|
778 |
/* Make sure it's null terminated. */ |
|
779 |
*new_path = '\0'; |
|
780 |
return resolved_path; |
|
781 |
} |
|
782 |
# define HAS_REALPATH |
|
783 |
#endif /* WANT_REALPATH && not HAS_REALPATH */ |
|
784 |
%} |
|
785 |
! ! |
|
786 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
787 |
!OperatingSystem class methodsFor:'documentation'! |
2 | 788 |
|
88 | 789 |
copyright |
790 |
" |
|
791 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
185 | 792 |
All Rights Reserved |
88 | 793 |
|
794 |
This software is furnished under a license and may be used |
|
795 |
only in accordance with the terms of that license and with the |
|
796 |
inclusion of the above copyright notice. This software may not |
|
797 |
be provided or otherwise made available to, or used by, any |
|
798 |
other person. No title to or ownership of the software is |
|
799 |
hereby transferred. |
|
800 |
" |
|
801 |
! |
|
802 |
||
2 | 803 |
documentation |
804 |
" |
|
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
805 |
this class realizes access to most (all ?) required operating system services; |
68 | 806 |
some of it is very specific for unix, so do not depend on |
1619 | 807 |
things available here in your applications |
808 |
- some may not be found in other OS's or be slightly different ... |
|
68 | 809 |
|
810 |
(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
|
811 |
from you - in some situations it MAY be interesting to be |
792 | 812 |
able to get down to a select or fork system call easily (at least on Unix systems). |
68 | 813 |
You decide - portability vs. functionality) |
814 |
||
1286 | 815 |
[Class variables:] |
816 |
||
1487 | 817 |
HostName <String> remembered hostname |
818 |
||
819 |
DomainName <String> remembered domainname |
|
820 |
||
821 |
LastErrorNumber <Integer> the last value of errno |
|
822 |
||
823 |
OSSignals <Array> Array of signals to be raised for corresponding |
|
824 |
OperatingSystem signals. |
|
825 |
||
826 |
ForkFailed <Boolean> set if a fork (or popen) has failed; |
|
827 |
ST/X will avoid doing more forks/popens |
|
828 |
if this flag is set, for a slightly |
|
829 |
smoother operation. |
|
830 |
||
831 |
SlowFork <Boolean> if set, fork and popen are avoided; |
|
832 |
(more or less obsolete now) |
|
833 |
||
834 |
||
835 |
ErrorSignal <Signal> Parentsignal of all OS error signals. |
|
836 |
not directly raised. |
|
837 |
||
838 |
AccessDeniedErrorSignal |
|
839 |
||
840 |
FileNotFoundErrorSignal |
|
841 |
||
842 |
LocaleInfo <Dictionary> if non nil, that is taken instead of the operating |
|
843 |
systems locale definitions (allows for overwriting |
|
844 |
these, or provide a compatible info on systems which do |
|
845 |
not support locales) |
|
1286 | 846 |
|
847 |
[author:] |
|
1487 | 848 |
Claus Gittinger |
1286 | 849 |
|
850 |
[see also:] |
|
1487 | 851 |
OSProcessStatus |
852 |
Filename Date Time |
|
853 |
ExternalStream FileStream PipeStream Socket |
|
2 | 854 |
" |
1619 | 855 |
! |
856 |
||
857 |
examples |
|
858 |
" |
|
1622 | 859 |
various queries |
1632 | 860 |
[exBegin] |
1622 | 861 |
Transcript |
1632 | 862 |
showCR:'hello ' , (OperatingSystem getLoginName) |
863 |
[exEnd] |
|
864 |
||
865 |
[exBegin] |
|
1622 | 866 |
OperatingSystem isUNIXlike ifTrue:[ |
1632 | 867 |
Transcript showCR:'this is some UNIX-like OS' |
1622 | 868 |
] ifFalse:[ |
1632 | 869 |
Transcript showCR:'this OS is not UNIX-like' |
1622 | 870 |
] |
1632 | 871 |
[exEnd] |
872 |
||
873 |
[exBegin] |
|
1622 | 874 |
Transcript |
1632 | 875 |
showCR:'this machine is called ' , OperatingSystem getHostName |
876 |
[exEnd] |
|
877 |
||
878 |
[exBegin] |
|
1622 | 879 |
Transcript |
1632 | 880 |
showCR:('this machine is in the ' |
881 |
, OperatingSystem getDomainName |
|
882 |
, ' domain') |
|
883 |
[exEnd] |
|
884 |
||
885 |
[exBegin] |
|
1622 | 886 |
Transcript |
1632 | 887 |
showCR:('this machine''s CPU is a ' |
888 |
, OperatingSystem getCPUType |
|
889 |
) |
|
890 |
[exEnd] |
|
891 |
||
892 |
[exBegin] |
|
1622 | 893 |
Transcript showCR:'executing ls command ...'. |
894 |
OperatingSystem executeCommand:'ls'. |
|
895 |
Transcript showCR:'... done.'. |
|
1632 | 896 |
[exEnd] |
1622 | 897 |
|
1621 | 898 |
locking a file |
899 |
(should be executed on two running smalltalks - not in two threads): |
|
1632 | 900 |
[exBegin] |
1621 | 901 |
|f| |
902 |
||
903 |
f := 'testFile' asFilename readWriteStream. |
|
904 |
||
905 |
10 timesRepeat:[ |
|
1632 | 906 |
'about to lock ...' printCR. |
907 |
[ |
|
908 |
OperatingSystem |
|
909 |
lockFD:(f fileDescriptor) |
|
910 |
shared:false |
|
911 |
blocking:false |
|
912 |
] whileFalse:[ |
|
913 |
'process ' print. OperatingSystem getProcessId print. ' is waiting' printCR. |
|
914 |
Delay waitForSeconds:1 |
|
915 |
]. |
|
916 |
'LOCKED ...' printCR. |
|
917 |
Delay waitForSeconds:10. |
|
918 |
'unlock ...' printCR. |
|
919 |
(OperatingSystem |
|
920 |
unlockFD:(f fileDescriptor)) printCR. |
|
921 |
Delay waitForSeconds:3. |
|
1621 | 922 |
] |
1632 | 923 |
[exBegin] |
1619 | 924 |
" |
2 | 925 |
! ! |
926 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
927 |
!OperatingSystem class methodsFor:'initialization'! |
95 | 928 |
|
929 |
initialize |
|
185 | 930 |
"initialize the class" |
931 |
||
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
932 |
ObjectMemory addDependent:self. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
933 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
934 |
ErrorSignal isNil ifTrue:[ |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
935 |
ErrorSignal := Object errorSignal newSignalMayProceed:true.. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
936 |
ErrorSignal nameClass:self message:#errorSignal. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
937 |
ErrorSignal notifierString:'OS error encountered'. |
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 |
AccessDeniedErrorSignal := ErrorSignal newSignalMayProceed:true. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
940 |
AccessDeniedErrorSignal nameClass:self message:#accessDeniedError. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
941 |
AccessDeniedErrorSignal notifierString:'OS access denied'. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
942 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
943 |
FileNotFoundErrorSignal := ErrorSignal newSignalMayProceed:true. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
944 |
FileNotFoundErrorSignal nameClass:self message:#fileNotFoundErrorSignal. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
945 |
FileNotFoundErrorSignal notifierString:'OS file not found'. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
946 |
] |
95 | 947 |
! |
948 |
||
1470 | 949 |
update:something with:aParameter from:changedObject |
1247 | 950 |
"catch image restart and flush some cached data" |
951 |
||
95 | 952 |
something == #earlyRestart ifTrue:[ |
1487 | 953 |
" |
954 |
flush cached data |
|
955 |
" |
|
956 |
HostName := nil. |
|
957 |
DomainName := nil. |
|
958 |
LastErrorNumber := nil. |
|
95 | 959 |
] |
1247 | 960 |
|
961 |
"Modified: 22.4.1996 / 13:10:43 / cg" |
|
1470 | 962 |
"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
|
963 |
"Modified: 7.1.1997 / 19:36:11 / stefan" |
95 | 964 |
! ! |
965 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
966 |
!OperatingSystem class methodsFor:'OS signal constants'! |
616 | 967 |
|
968 |
sigABRT |
|
969 |
"return the signal number for SIGABRT - 0 if not supported by OS |
|
970 |
(the numeric value is not the same across unix-systems)" |
|
971 |
||
972 |
%{ /* NOCONTEXT */ |
|
973 |
#ifdef SIGABRT |
|
1135 | 974 |
RETURN ( __MKSMALLINT(SIGABRT) ); |
616 | 975 |
#else |
1135 | 976 |
RETURN ( __MKSMALLINT(0) ); |
616 | 977 |
#endif |
978 |
%} |
|
979 |
! |
|
980 |
||
981 |
sigALRM |
|
982 |
"return the signal number for SIGALRM - 0 if not supported |
|
983 |
(the numeric value is not the same across unix-systems)" |
|
984 |
||
985 |
%{ /* NOCONTEXT */ |
|
986 |
#ifdef SIGALRM |
|
1135 | 987 |
RETURN ( __MKSMALLINT(SIGALRM) ); |
616 | 988 |
#else |
1135 | 989 |
RETURN ( __MKSMALLINT(0) ); |
616 | 990 |
#endif |
991 |
%} |
|
992 |
! |
|
993 |
||
831 | 994 |
sigBREAK |
995 |
"return the signal number for SIGBREAK - 0 if not supported. |
|
996 |
This is an MSDOS specific signal" |
|
997 |
||
998 |
%{ /* NOCONTEXT */ |
|
999 |
#ifdef SIGBREAK |
|
1135 | 1000 |
RETURN ( __MKSMALLINT(SIGBREAK) ); |
831 | 1001 |
#else |
1135 | 1002 |
RETURN ( __MKSMALLINT(0) ); |
831 | 1003 |
#endif |
1004 |
%} |
|
1005 |
! |
|
1006 |
||
616 | 1007 |
sigBUS |
1008 |
"return the signal number for SIGBUS - 0 if not supported |
|
1009 |
(the numeric value is not the same across unix-systems)" |
|
1010 |
||
1011 |
%{ /* NOCONTEXT */ |
|
1012 |
#ifdef SIGBUS |
|
1135 | 1013 |
RETURN ( __MKSMALLINT(SIGBUS) ); |
616 | 1014 |
#else |
1135 | 1015 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1016 |
#endif |
1017 |
%} |
|
1018 |
! |
|
1019 |
||
1020 |
sigCHLD |
|
1021 |
"return the signal number for SIGCHLD - 0 if not supported |
|
1022 |
(the numeric value is not the same across unix-systems)" |
|
1023 |
||
1024 |
%{ /* NOCONTEXT */ |
|
1025 |
#if defined(SIGCHLD) |
|
1135 | 1026 |
RETURN ( __MKSMALLINT(SIGCHLD) ); |
616 | 1027 |
#else |
1028 |
# if defined(SIGCLD) |
|
1135 | 1029 |
RETURN ( __MKSMALLINT(SIGCLD) ); |
616 | 1030 |
# else |
1135 | 1031 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1032 |
# endif |
1033 |
#endif |
|
1034 |
%} |
|
1035 |
! |
|
1036 |
||
1037 |
sigCONT |
|
1038 |
"return the signal number for SIGCONT - 0 if not supported |
|
1039 |
(the numeric value is not the same across unix-systems)" |
|
1040 |
||
1041 |
%{ /* NOCONTEXT */ |
|
1042 |
#if defined(SIGCONT) |
|
1135 | 1043 |
RETURN ( __MKSMALLINT(SIGCONT) ); |
616 | 1044 |
#else |
1135 | 1045 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1046 |
#endif |
1047 |
%} |
|
1048 |
! |
|
1049 |
||
1050 |
sigDANGER |
|
1051 |
"return the signal number for SIGDANGER - 0 if not supported |
|
1052 |
(seems to be an AIX special)" |
|
1053 |
||
1054 |
%{ /* NOCONTEXT */ |
|
710 | 1055 |
#if defined(SIGDANGER) |
1135 | 1056 |
RETURN ( __MKSMALLINT(SIGDANGER) ); |
616 | 1057 |
#else |
1135 | 1058 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1059 |
#endif |
1060 |
%} |
|
1061 |
! |
|
1062 |
||
1063 |
sigEMT |
|
1064 |
"return the signal number for SIGEMT - 0 if not supported by OS |
|
1065 |
(the numeric value is not the same across unix-systems)" |
|
1066 |
||
1067 |
%{ /* NOCONTEXT */ |
|
1068 |
#ifdef SIGEMT |
|
1135 | 1069 |
RETURN ( __MKSMALLINT(SIGEMT) ); |
616 | 1070 |
#else |
1135 | 1071 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1072 |
#endif |
1073 |
%} |
|
1074 |
! |
|
1075 |
||
1076 |
sigFP |
|
1077 |
"return the signal number for SIGFP - 0 if not supported by OS |
|
1078 |
(the numeric value is not the same across unix-systems)" |
|
1079 |
||
1080 |
%{ /* NOCONTEXT */ |
|
1081 |
#ifdef SIGFPE |
|
1135 | 1082 |
RETURN ( __MKSMALLINT(SIGFPE) ); |
616 | 1083 |
#else |
1135 | 1084 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1085 |
#endif |
1086 |
%} |
|
1087 |
! |
|
1088 |
||
1089 |
sigGRANT |
|
1090 |
"return the signal number for SIGGRANT - 0 if not supported |
|
1091 |
(seems to be an AIX special)" |
|
1092 |
||
1093 |
%{ /* NOCONTEXT */ |
|
1094 |
#if defined(SIGGRANT) |
|
1135 | 1095 |
RETURN ( __MKSMALLINT(SIGGRANT) ); |
616 | 1096 |
#else |
1135 | 1097 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1098 |
#endif |
1099 |
%} |
|
1100 |
! |
|
1101 |
||
1102 |
sigHUP |
|
1103 |
"return the signal number for SIGHUP |
|
1104 |
(the numeric value is not the same across unix-systems)" |
|
1105 |
||
1106 |
%{ /* NOCONTEXT */ |
|
1107 |
#ifdef SIGHUP |
|
1135 | 1108 |
RETURN ( __MKSMALLINT(SIGHUP) ); |
616 | 1109 |
#else |
1135 | 1110 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1111 |
#endif |
1112 |
%} |
|
1113 |
! |
|
1114 |
||
1115 |
sigILL |
|
1116 |
"return the signal number for SIGILL - 0 if not supported by OS |
|
1117 |
(the numeric value is not the same across unix-systems)" |
|
1118 |
||
1119 |
%{ /* NOCONTEXT */ |
|
1120 |
#ifdef SIGILL |
|
1135 | 1121 |
RETURN ( __MKSMALLINT(SIGILL) ); |
616 | 1122 |
#else |
1135 | 1123 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1124 |
#endif |
1125 |
%} |
|
1126 |
! |
|
1127 |
||
1128 |
sigINT |
|
1129 |
"return the signal number for SIGINT |
|
1130 |
(the numeric value is not the same across unix-systems)" |
|
1131 |
||
1132 |
%{ /* NOCONTEXT */ |
|
1133 |
#ifdef SIGINT |
|
1135 | 1134 |
RETURN ( __MKSMALLINT(SIGINT) ); |
616 | 1135 |
#else |
1135 | 1136 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1137 |
#endif |
1138 |
%} |
|
1139 |
! |
|
1140 |
||
1141 |
sigIO |
|
1142 |
"return the signal number for SIGIO - 0 if not supported |
|
1143 |
(the numeric value is not the same across unix-systems)" |
|
1144 |
||
1145 |
%{ /* NOCONTEXT */ |
|
1146 |
#if defined(SIGIO) |
|
1135 | 1147 |
RETURN ( __MKSMALLINT(SIGIO) ); |
616 | 1148 |
#else |
1135 | 1149 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1150 |
#endif |
1151 |
%} |
|
1152 |
! |
|
1153 |
||
1154 |
sigIOT |
|
1155 |
"return the signal number for SIGIOT - 0 if not supported by OS |
|
1156 |
(the numeric value is not the same across unix-systems)" |
|
1157 |
||
1158 |
%{ /* NOCONTEXT */ |
|
1159 |
#ifdef SIGIOT |
|
1135 | 1160 |
RETURN ( __MKSMALLINT(SIGIOT) ); |
616 | 1161 |
#else |
1135 | 1162 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1163 |
#endif |
1164 |
%} |
|
1165 |
! |
|
1166 |
||
1167 |
sigKILL |
|
1168 |
"return the signal number for SIGKILL |
|
1169 |
(the numeric value is not the same across unix-systems)" |
|
1170 |
||
1171 |
%{ /* NOCONTEXT */ |
|
1172 |
#ifdef SIGKILL |
|
1135 | 1173 |
RETURN ( __MKSMALLINT(SIGKILL) ); |
616 | 1174 |
#else |
1135 | 1175 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1176 |
#endif |
1177 |
%} |
|
1178 |
! |
|
1179 |
||
1180 |
sigLOST |
|
1181 |
"return the signal number for SIGLOST - 0 if not supported |
|
1182 |
(the numeric value is not the same across unix-systems)" |
|
1183 |
||
1184 |
%{ /* NOCONTEXT */ |
|
1185 |
#if defined(SIGLOST) |
|
1135 | 1186 |
RETURN ( __MKSMALLINT(SIGLOST) ); |
616 | 1187 |
#else |
1135 | 1188 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1189 |
#endif |
1190 |
%} |
|
1191 |
! |
|
1192 |
||
1193 |
sigMIGRATE |
|
1194 |
"return the signal number for SIGMIGRATE - 0 if not supported |
|
1195 |
(seems to be an AIX special)" |
|
1196 |
||
1197 |
%{ /* NOCONTEXT */ |
|
1198 |
#if defined(SIGMIGRATE) |
|
1135 | 1199 |
RETURN ( __MKSMALLINT(SIGMIGRATE) ); |
616 | 1200 |
#else |
1135 | 1201 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1202 |
#endif |
1203 |
%} |
|
1204 |
! |
|
1205 |
||
1206 |
sigMSG |
|
1207 |
"return the signal number for SIGMSG - 0 if not supported |
|
1208 |
(seems to be an AIX special)" |
|
1209 |
||
1210 |
%{ /* NOCONTEXT */ |
|
1211 |
#if defined(SIGMSG) |
|
1135 | 1212 |
RETURN ( __MKSMALLINT(SIGMSG) ); |
616 | 1213 |
#else |
1135 | 1214 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1215 |
#endif |
1216 |
%} |
|
1217 |
! |
|
1218 |
||
1219 |
sigPIPE |
|
1220 |
"return the signal number for SIGPIPE - 0 if not supported |
|
1221 |
(the numeric value is not the same across unix-systems)" |
|
1222 |
||
1223 |
%{ /* NOCONTEXT */ |
|
1224 |
#ifdef SIGPIPE |
|
1135 | 1225 |
RETURN ( __MKSMALLINT(SIGPIPE) ); |
616 | 1226 |
#else |
1135 | 1227 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1228 |
#endif |
1229 |
%} |
|
1230 |
! |
|
1231 |
||
1232 |
sigPOLL |
|
1233 |
"return the signal number for SIGPOLL - 0 if not supported |
|
1234 |
(the numeric value is not the same across unix-systems)" |
|
1235 |
||
1236 |
%{ /* NOCONTEXT */ |
|
1237 |
#if defined(SIGPOLL) |
|
1135 | 1238 |
RETURN ( __MKSMALLINT(SIGPOLL) ); |
616 | 1239 |
#else |
1135 | 1240 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1241 |
#endif |
1242 |
%} |
|
1243 |
! |
|
1244 |
||
1245 |
sigPRE |
|
1246 |
"return the signal number for SIGPRE - 0 if not supported |
|
1247 |
(seems to be an AIX special)" |
|
1248 |
||
1249 |
%{ /* NOCONTEXT */ |
|
1250 |
#if defined(SIGPRE) |
|
1135 | 1251 |
RETURN ( __MKSMALLINT(SIGPRE) ); |
616 | 1252 |
#else |
1135 | 1253 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1254 |
#endif |
1255 |
%} |
|
1256 |
! |
|
1257 |
||
1258 |
sigPROF |
|
1259 |
"return the signal number for SIGPROF - 0 if not supported |
|
1260 |
(the numeric value is not the same across unix-systems)" |
|
1261 |
||
1262 |
%{ /* NOCONTEXT */ |
|
1263 |
#if defined(SIGPROF) |
|
1135 | 1264 |
RETURN ( __MKSMALLINT(SIGPROF) ); |
616 | 1265 |
#else |
1135 | 1266 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1267 |
#endif |
1268 |
%} |
|
1269 |
! |
|
1270 |
||
1271 |
sigPWR |
|
1272 |
"return the signal number for SIGPWR - 0 if not supported |
|
1273 |
(not available on all systems)" |
|
1274 |
||
1275 |
%{ /* NOCONTEXT */ |
|
1276 |
#if defined(SIGPWR) |
|
1135 | 1277 |
RETURN ( __MKSMALLINT(SIGPWR) ); |
616 | 1278 |
#else |
1135 | 1279 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1280 |
#endif |
1281 |
%} |
|
1282 |
! |
|
1283 |
||
1284 |
sigQUIT |
|
1285 |
"return the signal number for SIGQUIT |
|
1286 |
(the numeric value is not the same across unix-systems)" |
|
1287 |
||
1288 |
%{ /* NOCONTEXT */ |
|
1289 |
#ifdef SIGQUIT |
|
1135 | 1290 |
RETURN ( __MKSMALLINT(SIGQUIT) ); |
616 | 1291 |
#else |
1135 | 1292 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1293 |
#endif |
1294 |
%} |
|
1295 |
! |
|
1296 |
||
1297 |
sigRETRACT |
|
1298 |
"return the signal number for SIGRETRACT - 0 if not supported |
|
1299 |
(seems to be an AIX special)" |
|
1300 |
||
1301 |
%{ /* NOCONTEXT */ |
|
1302 |
#if defined(SIGRETRACT) |
|
1135 | 1303 |
RETURN ( __MKSMALLINT(SIGRETRACT) ); |
616 | 1304 |
#else |
1135 | 1305 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1306 |
#endif |
1307 |
%} |
|
1308 |
! |
|
1309 |
||
1310 |
sigSAK |
|
1311 |
"return the signal number for SIGSAK - 0 if not supported |
|
1312 |
(seems to be an AIX special)" |
|
1313 |
||
1314 |
%{ /* NOCONTEXT */ |
|
1315 |
#if defined(SIGSAK) |
|
1135 | 1316 |
RETURN ( __MKSMALLINT(SIGSAK) ); |
616 | 1317 |
#else |
1135 | 1318 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1319 |
#endif |
1320 |
%} |
|
1321 |
! |
|
1322 |
||
1323 |
sigSEGV |
|
1324 |
"return the signal number for SIGSEGV - 0 if not supported |
|
1325 |
(the numeric value is not the same across unix-systems)" |
|
1326 |
||
1327 |
%{ /* NOCONTEXT */ |
|
1328 |
#ifdef SIGSEGV |
|
1135 | 1329 |
RETURN ( __MKSMALLINT(SIGSEGV) ); |
616 | 1330 |
#else |
1135 | 1331 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1332 |
#endif |
1333 |
%} |
|
1334 |
! |
|
1335 |
||
1336 |
sigSOUND |
|
1337 |
"return the signal number for SIGSOUND - 0 if not supported |
|
1338 |
(seems to be an AIX special)" |
|
1339 |
||
1340 |
%{ /* NOCONTEXT */ |
|
1341 |
#if defined(SIGSOUND) |
|
1135 | 1342 |
RETURN ( __MKSMALLINT(SIGSOUND) ); |
616 | 1343 |
#else |
1135 | 1344 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1345 |
#endif |
1346 |
%} |
|
1347 |
! |
|
1348 |
||
1349 |
sigSTOP |
|
1350 |
"return the signal number for SIGSTOP - 0 if not supported |
|
1351 |
(the numeric value is not the same across unix-systems)" |
|
1352 |
||
1353 |
%{ /* NOCONTEXT */ |
|
1354 |
#if defined(SIGSTOP) |
|
1135 | 1355 |
RETURN ( __MKSMALLINT(SIGSTOP) ); |
616 | 1356 |
#else |
1135 | 1357 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1358 |
#endif |
1359 |
%} |
|
1360 |
! |
|
1361 |
||
1362 |
sigSYS |
|
1363 |
"return the signal number for SIGSYS - 0 if not supported |
|
1364 |
(the numeric value is not the same across unix-systems)" |
|
1365 |
||
1366 |
%{ /* NOCONTEXT */ |
|
1367 |
#ifdef SIGSYS |
|
1135 | 1368 |
RETURN ( __MKSMALLINT(SIGSYS) ); |
616 | 1369 |
#else |
1135 | 1370 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1371 |
#endif |
1372 |
%} |
|
1373 |
! |
|
1374 |
||
1375 |
sigTERM |
|
1376 |
"return the signal number for SIGTERM - 0 if not supported |
|
1377 |
(the numeric value is not the same across unix-systems)" |
|
1378 |
||
1379 |
%{ /* NOCONTEXT */ |
|
1380 |
#ifdef SIGTERM |
|
1135 | 1381 |
RETURN ( __MKSMALLINT(SIGTERM) ); |
616 | 1382 |
#else |
1135 | 1383 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1384 |
#endif |
1385 |
%} |
|
1386 |
! |
|
1387 |
||
1388 |
sigTRAP |
|
1389 |
"return the signal number for SIGTRAP - 0 if not supported by OS |
|
1390 |
(the numeric value is not the same across unix-systems)" |
|
1391 |
||
1392 |
%{ /* NOCONTEXT */ |
|
1393 |
#ifdef SIGTRAP |
|
1135 | 1394 |
RETURN ( __MKSMALLINT(SIGTRAP) ); |
616 | 1395 |
#else |
1135 | 1396 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1397 |
#endif |
1398 |
%} |
|
1399 |
! |
|
1400 |
||
1401 |
sigTSTP |
|
1402 |
"return the signal number for SIGTSTP - 0 if not supported |
|
1403 |
(the numeric value is not the same across unix-systems)" |
|
1404 |
||
1405 |
%{ /* NOCONTEXT */ |
|
1406 |
#if defined(SIGTSTP) |
|
1135 | 1407 |
RETURN ( __MKSMALLINT(SIGTSTP) ); |
616 | 1408 |
#else |
1135 | 1409 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1410 |
#endif |
1411 |
%} |
|
1412 |
! |
|
1413 |
||
1414 |
sigTTIN |
|
1415 |
"return the signal number for SIGTTIN - 0 if not supported |
|
1416 |
(the numeric value is not the same across unix-systems)" |
|
1417 |
||
1418 |
%{ /* NOCONTEXT */ |
|
1419 |
#if defined(SIGTTIN) |
|
1135 | 1420 |
RETURN ( __MKSMALLINT(SIGTTIN) ); |
616 | 1421 |
#else |
1135 | 1422 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1423 |
#endif |
1424 |
%} |
|
1425 |
! |
|
1426 |
||
1427 |
sigTTOU |
|
1428 |
"return the signal number for SIGTTOU - 0 if not supported |
|
1429 |
(the numeric value is not the same across unix-systems)" |
|
1430 |
||
1431 |
%{ /* NOCONTEXT */ |
|
1432 |
#if defined(SIGTTOU) |
|
1135 | 1433 |
RETURN ( __MKSMALLINT(SIGTTOU) ); |
616 | 1434 |
#else |
1135 | 1435 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1436 |
#endif |
1437 |
%} |
|
1438 |
! |
|
1439 |
||
1440 |
sigURG |
|
1441 |
"return the signal number for SIGURG - 0 if not supported |
|
1442 |
(the numeric value is not the same across unix-systems)" |
|
1443 |
||
1444 |
%{ /* NOCONTEXT */ |
|
1445 |
#if defined(SIGURG) |
|
1135 | 1446 |
RETURN ( __MKSMALLINT(SIGURG) ); |
616 | 1447 |
#else |
1135 | 1448 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1449 |
#endif |
1450 |
%} |
|
1451 |
! |
|
1452 |
||
1453 |
sigUSR1 |
|
1454 |
"return the signal number for SIGUSR1 - 0 if not supported |
|
1455 |
(the numeric value is not the same across unix-systems)" |
|
1456 |
||
1457 |
%{ /* NOCONTEXT */ |
|
1458 |
#if defined(SIGUSR1) |
|
1135 | 1459 |
RETURN ( __MKSMALLINT(SIGUSR1) ); |
616 | 1460 |
#else |
1135 | 1461 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1462 |
#endif |
1463 |
%} |
|
1464 |
! |
|
1465 |
||
1466 |
sigUSR2 |
|
1467 |
"return the signal number for SIGUSR2 - 0 if not supported |
|
1468 |
(the numeric value is not the same across unix-systems)" |
|
1469 |
||
1470 |
%{ /* NOCONTEXT */ |
|
1471 |
#if defined(SIGUSR2) |
|
1135 | 1472 |
RETURN ( __MKSMALLINT(SIGUSR2) ); |
616 | 1473 |
#else |
1135 | 1474 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1475 |
#endif |
1476 |
%} |
|
1477 |
! |
|
1478 |
||
1479 |
sigVTALRM |
|
1480 |
"return the signal number for SIGVTALRM - 0 if not supported |
|
1481 |
(the numeric value is not the same across unix-systems)" |
|
1482 |
||
1483 |
%{ /* NOCONTEXT */ |
|
1484 |
#if defined(SIGVTALRM) |
|
1135 | 1485 |
RETURN ( __MKSMALLINT(SIGVTALRM) ); |
616 | 1486 |
#else |
1135 | 1487 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1488 |
#endif |
1489 |
%} |
|
1490 |
! |
|
1491 |
||
1492 |
sigWINCH |
|
1493 |
"return the signal number for SIGWINCH - 0 if not supported |
|
1494 |
(the numeric value is not the same across unix-systems)" |
|
1495 |
||
1496 |
%{ /* NOCONTEXT */ |
|
1497 |
#if defined(SIGWINCH) |
|
1135 | 1498 |
RETURN ( __MKSMALLINT(SIGWINCH) ); |
616 | 1499 |
#else |
1135 | 1500 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1501 |
#endif |
1502 |
%} |
|
1503 |
! |
|
1504 |
||
1505 |
sigXCPU |
|
1506 |
"return the signal number for SIGXCPU - 0 if not supported |
|
1507 |
(the numeric value is not the same across unix-systems)" |
|
1508 |
||
1509 |
%{ /* NOCONTEXT */ |
|
1510 |
#if defined(SIGXCPU) |
|
1135 | 1511 |
RETURN ( __MKSMALLINT(SIGXCPU) ); |
616 | 1512 |
#else |
1135 | 1513 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1514 |
#endif |
1515 |
%} |
|
1516 |
! |
|
1517 |
||
1518 |
sigXFSZ |
|
1519 |
"return the signal number for SIGXFSZ - 0 if not supported |
|
1520 |
(the numeric value is not the same across unix-systems)" |
|
1521 |
||
1522 |
%{ /* NOCONTEXT */ |
|
1523 |
#if defined(SIGXFSZ) |
|
1135 | 1524 |
RETURN ( __MKSMALLINT(SIGXFSZ) ); |
616 | 1525 |
#else |
1135 | 1526 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1527 |
#endif |
1528 |
%} |
|
1529 |
! ! |
|
1530 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
1531 |
!OperatingSystem class methodsFor:'Signal constants'! |
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1532 |
|
616 | 1533 |
accessDeniedErrorSignal |
1534 |
"return the signal raised when a (file-) access is denied." |
|
1535 |
||
1536 |
^ AccessDeniedErrorSignal |
|
1537 |
! |
|
1538 |
||
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1539 |
errorSignal |
1247 | 1540 |
"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
|
1541 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1542 |
^ ErrorSignal |
1247 | 1543 |
|
1544 |
"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
|
1545 |
! |
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 |
fileNotFoundErrorSignal |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1548 |
"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
|
1549 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1550 |
^ FileNotFoundErrorSignal |
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 |
|
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
1553 |
!OperatingSystem class methodsFor:'error messages'! |
1 | 1554 |
|
1153
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1555 |
clearLastErrorNumber |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1556 |
"return the last errors number. |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1557 |
See also: #lastErrorSymbol and #lastErrorString. |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1558 |
Notice: having a single error number is a bad idea in a multithreaded |
1487 | 1559 |
environment - this interface will change." |
1153
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1560 |
|
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1561 |
LastErrorNumber := nil. |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1562 |
|
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1563 |
" |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1564 |
OperatingSystem clearLastErrorNumber |
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 |
|
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1567 |
"Created: 12.4.1996 / 09:28:58 / stefan" |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1568 |
"Modified: 12.4.1996 / 09:38:51 / stefan" |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1569 |
! |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1570 |
|
85 | 1571 |
currentErrorNumber |
68 | 1572 |
"returns the OS's last error nr (i.e. the value of errno). |
1573 |
Notice, that the value of this flag is only valid immediately |
|
1574 |
after the error occurred - it gets updated with every other |
|
85 | 1575 |
request to the OS. |
1576 |
Use lastErrorNumber - currentErrorNumber is invalidated by |
|
1577 |
many, many internal calls." |
|
68 | 1578 |
|
1579 |
%{ /* NOCONTEXT */ |
|
1580 |
||
1135 | 1581 |
RETURN ( __MKSMALLINT(errno) ); |
68 | 1582 |
%} |
1583 |
" |
|
85 | 1584 |
OperatingSystem currentErrorNumber |
1585 |
" |
|
1586 |
! |
|
1587 |
||
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1588 |
errorNumberFor:aSymbol |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1589 |
"given a symbolic error, return the numeric; |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1590 |
(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
|
1591 |
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
|
1592 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1593 |
%{ /* NOCONTEXT */ |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1594 |
OBJ sym = aSymbol; |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1595 |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1596 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1597 |
* POSIX errnos - these should be defined |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1598 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1599 |
#ifdef EPERM |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1600 |
if (sym == @symbol(EPERM)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1601 |
RETURN ( __MKSMALLINT(EPERM) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1602 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1603 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1604 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1605 |
#ifdef ENOENT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1606 |
if (sym == @symbol(ENOENT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1607 |
RETURN ( __MKSMALLINT(ENOENT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1608 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1609 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1610 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1611 |
#ifdef ESRCH |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1612 |
if (sym == @symbol(ESRCH)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1613 |
RETURN ( __MKSMALLINT(ESRCH) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1614 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1615 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1616 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1617 |
#ifdef EINTR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1618 |
if (sym == @symbol(EINTR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1619 |
RETURN ( __MKSMALLINT(EINTR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1620 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1621 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1622 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1623 |
#ifdef EIO |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1624 |
if (sym == @symbol(EIO)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1625 |
RETURN ( __MKSMALLINT(EIO) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1626 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1627 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1628 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1629 |
#ifdef ENXIO |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1630 |
if (sym == @symbol(ENXIO)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1631 |
RETURN ( __MKSMALLINT(ENXIO) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1632 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1633 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1634 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1635 |
#ifdef E2BIG |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1636 |
if (sym == @symbol(E2BIG)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1637 |
RETURN ( __MKSMALLINT(E2BIG) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1638 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1639 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1640 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1641 |
#ifdef ENOEXEC |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1642 |
if (sym == @symbol(ENOEXEC)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1643 |
RETURN ( __MKSMALLINT(ENOEXEC) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1644 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1645 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1646 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1647 |
#ifdef EBADF |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1648 |
if (sym == @symbol(EBADF)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1649 |
RETURN ( __MKSMALLINT(EBADF) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1650 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1651 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1652 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1653 |
#ifdef ECHILD |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1654 |
if (sym == @symbol(ECHILD)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1655 |
RETURN ( __MKSMALLINT(ECHILD) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1656 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1657 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1658 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1659 |
#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
|
1660 |
if (sym == @symbol(EAGAIN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1661 |
RETURN ( __MKSMALLINT(EAGAIN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1662 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1663 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1664 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1665 |
#ifdef ENOMEM |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1666 |
if (sym == @symbol(ENOMEM)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1667 |
RETURN ( __MKSMALLINT(ENOMEM) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1668 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1669 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1670 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1671 |
#ifdef EACCES |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1672 |
if (sym == @symbol(EACCES)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1673 |
RETURN ( __MKSMALLINT(EACCES) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1674 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1675 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1676 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1677 |
#ifdef EFAULT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1678 |
if (sym == @symbol(EFAULT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1679 |
RETURN ( __MKSMALLINT(EFAULT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1680 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1681 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1682 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1683 |
#ifdef EBUSY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1684 |
if (sym == @symbol(EBUSY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1685 |
RETURN ( __MKSMALLINT(EBUSY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1686 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1687 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1688 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1689 |
#ifdef EXDEV |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1690 |
if (sym == @symbol(EXDEV)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1691 |
RETURN ( __MKSMALLINT(EXDEV) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1692 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1693 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1694 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1695 |
#ifdef ENODEV |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1696 |
if (sym == @symbol(ENODEV)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1697 |
RETURN ( __MKSMALLINT(ENODEV) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1698 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1699 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1700 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1701 |
#ifdef ENOTDIR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1702 |
if (sym == @symbol(ENOTDIR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1703 |
RETURN ( __MKSMALLINT(ENOTDIR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1704 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1705 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1706 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1707 |
#ifdef EISDIR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1708 |
if (sym == @symbol(EISDIR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1709 |
RETURN ( __MKSMALLINT(EISDIR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1710 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1711 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1712 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1713 |
#ifdef EINVAL |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1714 |
if (sym == @symbol(EINVAL)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1715 |
RETURN ( __MKSMALLINT(EINVAL) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1716 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1717 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1718 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1719 |
#ifdef ENFILE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1720 |
if (sym == @symbol(ENFILE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1721 |
RETURN ( __MKSMALLINT(ENFILE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1722 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1723 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1724 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1725 |
#ifdef EMFILE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1726 |
if (sym == @symbol(EMFILE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1727 |
RETURN ( __MKSMALLINT(EMFILE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1728 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1729 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1730 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1731 |
#ifdef ENOTTY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1732 |
if (sym == @symbol(ENOTTY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1733 |
RETURN ( __MKSMALLINT(ENOTTY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1734 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1735 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1736 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1737 |
#ifdef EFBIG |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1738 |
if (sym == @symbol(EFBIG)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1739 |
RETURN ( __MKSMALLINT(EFBIG) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1740 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1741 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1742 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1743 |
#ifdef ENOSPC |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1744 |
if (sym == @symbol(ENOSPC)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1745 |
RETURN ( __MKSMALLINT(ENOSPC) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1746 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1747 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1748 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1749 |
#ifdef ESPIPE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1750 |
if (sym == @symbol(ESPIPE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1751 |
RETURN ( __MKSMALLINT(ESPIPE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1752 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1753 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1754 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1755 |
#ifdef EROFS |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1756 |
if (sym == @symbol(EROFS)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1757 |
RETURN ( __MKSMALLINT(EROFS) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1758 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1759 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1760 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1761 |
#ifdef EMLINK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1762 |
if (sym == @symbol(EMLINK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1763 |
RETURN ( __MKSMALLINT(EMLINK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1764 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1765 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1766 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1767 |
#ifdef EPIPE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1768 |
if (sym == @symbol(EPIPE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1769 |
RETURN ( __MKSMALLINT(EPIPE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1770 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1771 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1772 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1773 |
#ifdef EDOM |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1774 |
if (sym == @symbol(EDOM)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1775 |
RETURN ( __MKSMALLINT(EDOM) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1776 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1777 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1778 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1779 |
#ifdef ERANGE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1780 |
if (sym == @symbol(ERANGE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1781 |
RETURN ( __MKSMALLINT(ERANGE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1782 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1783 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1784 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1785 |
#ifdef EDEADLK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1786 |
if (sym == @symbol(EDEADLK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1787 |
RETURN ( __MKSMALLINT(EDEADLK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1788 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1789 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1790 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1791 |
#ifdef ENAMETOOLONG |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1792 |
if (sym == @symbol(ENAMETOOLONG)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1793 |
RETURN ( __MKSMALLINT(ENAMETOOLONG) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1794 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1795 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1796 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1797 |
#ifdef ENOLCK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1798 |
if (sym == @symbol(ENOLCK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1799 |
RETURN ( __MKSMALLINT(ENOLCK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1800 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1801 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1802 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1803 |
#ifdef ENOSYS |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1804 |
if (sym == @symbol(ENOSYS)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1805 |
RETURN ( __MKSMALLINT(ENOSYS) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1806 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1807 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1808 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1809 |
#ifdef ENOTEMPTY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1810 |
if (sym == @symbol(ENOTEMPTY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1811 |
RETURN ( __MKSMALLINT(ENOTEMPTY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1812 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1813 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1814 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1815 |
#ifdef EEXIST |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1816 |
if (sym == @symbol(EEXIST)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1817 |
RETURN ( __MKSMALLINT(EEXIST) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1818 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1819 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1820 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1821 |
#ifdef EILSEQ |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1822 |
if (sym == @symbol(EILSEQ)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1823 |
RETURN ( __MKSMALLINT(EILSEQ) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1824 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1825 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1826 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1827 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1828 |
* XPG3 errnos - defined on most systems |
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 |
#ifdef ENOTBLK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1831 |
if (sym == @symbol(ENOTBLK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1832 |
RETURN ( __MKSMALLINT(ENOTBLK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1833 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1834 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1835 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1836 |
#ifdef ETXTBSY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1837 |
if (sym == @symbol(ETXTBSY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1838 |
RETURN ( __MKSMALLINT(ETXTBSY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1839 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1840 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1841 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1842 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1843 |
* some others |
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 |
#ifdef EWOULDBLOCK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1846 |
if (sym == @symbol(EWOULDBLOCK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1847 |
RETURN ( __MKSMALLINT(EWOULDBLOCK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1848 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1849 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1850 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1851 |
#ifdef ENOMSG |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1852 |
if (sym == @symbol(ENOMSG)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1853 |
RETURN ( __MKSMALLINT(ENOMSG) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1854 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1855 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1856 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1857 |
#ifdef ELOOP |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1858 |
if (sym == @symbol(ELOOP)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1859 |
RETURN ( __MKSMALLINT(ELOOP) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1860 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1861 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1862 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1863 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1864 |
* some stream errors |
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 |
#ifdef ETIME |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1867 |
if (sym == @symbol(ETIME)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1868 |
RETURN ( __MKSMALLINT(ETIME) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1869 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1870 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1871 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1872 |
#ifdef ENOSR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1873 |
if (sym == @symbol(ENOSR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1874 |
RETURN ( __MKSMALLINT(ENOSR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1875 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1876 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1877 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1878 |
#ifdef ENOSTR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1879 |
if (sym == @symbol(ENOSTR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1880 |
RETURN ( __MKSMALLINT(ENOSTR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1881 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1882 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1883 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1884 |
#ifdef ECOMM |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1885 |
if (sym == @symbol(ECOMM)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1886 |
RETURN ( __MKSMALLINT(ECOMM) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1887 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1888 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1889 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1890 |
#ifdef EPROTO |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1891 |
if (sym == @symbol(EPROTO)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1892 |
RETURN ( __MKSMALLINT(EPROTO) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1893 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1894 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1895 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1896 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1897 |
* nfs errors |
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 |
#ifdef ESTALE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1900 |
if (sym == @symbol(ESTALE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1901 |
RETURN ( __MKSMALLINT(ESTALE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1902 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1903 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1904 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1905 |
#ifdef EREMOTE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1906 |
if (sym == @symbol(EREMOTE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1907 |
RETURN ( __MKSMALLINT(EREMOTE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1908 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1909 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1910 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1911 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1912 |
* some networking errors |
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 |
#ifdef EINPROGRESS |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1915 |
if (sym == @symbol(EINPROGRESS)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1916 |
RETURN ( __MKSMALLINT(EINPROGRESS) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1917 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1918 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1919 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1920 |
#ifdef EALREADY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1921 |
if (sym == @symbol(EALREADY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1922 |
RETURN ( __MKSMALLINT(EALREADY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1923 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1924 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1925 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1926 |
#ifdef ENOTSOCK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1927 |
if (sym == @symbol(ENOTSOCK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1928 |
RETURN ( __MKSMALLINT(ENOTSOCK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1929 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1930 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1931 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1932 |
#ifdef EDESTADDRREQ |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1933 |
if (sym == @symbol(EDESTADDRREQ)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1934 |
RETURN ( __MKSMALLINT(EDESTADDRREQ) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1935 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1936 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1937 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1938 |
#ifdef EMSGSIZE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1939 |
if (sym == @symbol(EMSGSIZE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1940 |
RETURN ( __MKSMALLINT(EMSGSIZE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1941 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1942 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1943 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1944 |
#ifdef EPROTOTYPE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1945 |
if (sym == @symbol(EPROTOTYPE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1946 |
RETURN ( __MKSMALLINT(EPROTOTYPE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1947 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1948 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1949 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1950 |
#ifdef ENOPROTOOPT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1951 |
if (sym == @symbol(ENOPROTOOPT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1952 |
RETURN ( __MKSMALLINT(ENOPROTOOPT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1953 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1954 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1955 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1956 |
#ifdef EPROTONOSUPPORT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1957 |
if (sym == @symbol(EPROTONOSUPPORT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1958 |
RETURN ( __MKSMALLINT(EPROTONOSUPPORT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1959 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1960 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1961 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1962 |
#ifdef ESOCKTNOSUPPORT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1963 |
if (sym == @symbol(ESOCKTNOSUPPORT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1964 |
RETURN ( __MKSMALLINT(ESOCKTNOSUPPORT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1965 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1966 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1967 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1968 |
#ifdef EOPNOTSUPP |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1969 |
if (sym == @symbol(EOPNOTSUPP)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1970 |
RETURN ( __MKSMALLINT(EOPNOTSUPP) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1971 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1972 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1973 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1974 |
#ifdef EPFNOSUPPORT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1975 |
if (sym == @symbol(EPFNOSUPPORT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1976 |
RETURN ( __MKSMALLINT(EPFNOSUPPORT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1977 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1978 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1979 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1980 |
#ifdef EAFNOSUPPORT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1981 |
if (sym == @symbol(EAFNOSUPPORT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1982 |
RETURN ( __MKSMALLINT(EAFNOSUPPORT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1983 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1984 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1985 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1986 |
#ifdef EADDRINUSE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1987 |
if (sym == @symbol(EADDRINUSE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1988 |
RETURN ( __MKSMALLINT(EADDRINUSE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1989 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1990 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1991 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1992 |
#ifdef EADDRNOTAVAIL |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1993 |
if (sym == @symbol(EADDRNOTAVAIL)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1994 |
RETURN ( __MKSMALLINT(EADDRNOTAVAIL) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1995 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1996 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1997 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1998 |
#ifdef ETIMEDOUT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1999 |
if (sym == @symbol(ETIMEDOUT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2000 |
RETURN ( __MKSMALLINT(ETIMEDOUT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2001 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2002 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2003 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2004 |
#ifdef ECONNREFUSED |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2005 |
if (sym == @symbol(ECONNREFUSED)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2006 |
RETURN ( __MKSMALLINT(ECONNREFUSED) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2007 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2008 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2009 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2010 |
#ifdef ENETDOWN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2011 |
if (sym == @symbol(ENETDOWN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2012 |
RETURN ( __MKSMALLINT(ENETDOWN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2013 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2014 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2015 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2016 |
#ifdef ENETUNREACH |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2017 |
if (sym == @symbol(ENETUNREACH)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2018 |
RETURN ( __MKSMALLINT(ENETUNREACH) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2019 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2020 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2021 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2022 |
#ifdef ENETRESET |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2023 |
if (sym == @symbol(ENETRESET)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2024 |
RETURN ( __MKSMALLINT(ENETRESET) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2025 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2026 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2027 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2028 |
#ifdef ECONNABORTED |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2029 |
if (sym == @symbol(ECONNABORTED)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2030 |
RETURN ( __MKSMALLINT(ECONNABORTED) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2031 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2032 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2033 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2034 |
#ifdef ECONNRESET |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2035 |
if (sym == @symbol(ECONNRESET)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2036 |
RETURN ( __MKSMALLINT(ECONNRESET) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2037 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2038 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2039 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2040 |
#ifdef EISCONN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2041 |
if (sym == @symbol(EISCONN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2042 |
RETURN ( __MKSMALLINT(EISCONN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2043 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2044 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2045 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2046 |
#ifdef ENOTCONN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2047 |
if (sym == @symbol(ENOTCONN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2048 |
RETURN ( __MKSMALLINT(ENOTCONN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2049 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2050 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2051 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2052 |
#ifdef ESHUTDOWN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2053 |
if (sym == @symbol(ESHUTDOWN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2054 |
RETURN ( __MKSMALLINT(ESHUTDOWN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2055 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2056 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2057 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2058 |
#ifdef EHOSTDOWN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2059 |
if (sym == @symbol(EHOSTDOWN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2060 |
RETURN ( __MKSMALLINT(EHOSTDOWN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2061 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2062 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2063 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2064 |
#ifdef EHOSTUNREACH |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2065 |
if (sym == @symbol(EHOSTUNREACH)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2066 |
RETURN ( __MKSMALLINT(EHOSTUNREACH) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2067 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2068 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2069 |
%}. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2070 |
^ -1 |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2071 |
! |
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 |
errorSymbolAndTextForNumber:errNr |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2074 |
"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
|
2075 |
(as returned by a system call). |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2076 |
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
|
2077 |
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
|
2078 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2079 |
|sym text| |
1 | 2080 |
|
77 | 2081 |
%{ |
2082 |
/* claus: |
|
2083 |
* I made this some primitive code, since errnos are not |
|
2084 |
* standard across unixes |
|
2085 |
*/ |
|
2086 |
char *msg = "unknown error"; |
|
2087 |
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
|
2088 |
OBJ eno = errNr; |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2089 |
|
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2090 |
if (__isSmallInteger(eno)) { |
1135 | 2091 |
switch (__intVal(eno)) { |
185 | 2092 |
/* |
2093 |
* POSIX errnos - these should be defined |
|
2094 |
*/ |
|
443 | 2095 |
#ifdef EPERM |
185 | 2096 |
case EPERM: |
2097 |
msg = "Operation not permitted"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2098 |
sym = @symbol(EPERM); |
185 | 2099 |
break; |
443 | 2100 |
#endif |
2101 |
#ifdef ENOENT |
|
185 | 2102 |
case ENOENT: |
2103 |
msg = "No such file or directory"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2104 |
sym = @symbol(ENOENT); |
185 | 2105 |
break; |
443 | 2106 |
#endif |
2107 |
#ifdef ESRCH |
|
185 | 2108 |
case ESRCH: |
2109 |
msg = "No such process"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2110 |
sym = @symbol(ESRCH); |
185 | 2111 |
break; |
443 | 2112 |
#endif |
2113 |
#ifdef EINTR |
|
185 | 2114 |
case EINTR: |
2115 |
msg = "Interrupted system call"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2116 |
sym = @symbol(EINTR); |
185 | 2117 |
break; |
443 | 2118 |
#endif |
2119 |
#ifdef EIO |
|
185 | 2120 |
case EIO: |
2121 |
msg = "I/O error"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2122 |
sym = @symbol(EIO); |
185 | 2123 |
break; |
443 | 2124 |
#endif |
2125 |
#ifdef ENXIO |
|
185 | 2126 |
case ENXIO: |
2127 |
msg = "No such device or address"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2128 |
sym = @symbol(ENXIO); |
185 | 2129 |
break; |
443 | 2130 |
#endif |
2131 |
#ifdef E2BIG |
|
185 | 2132 |
case E2BIG: |
2133 |
msg = "Arg list too long"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2134 |
sym = @symbol(E2BIG); |
185 | 2135 |
break; |
443 | 2136 |
#endif |
2137 |
#ifdef ENOEXEC |
|
185 | 2138 |
case ENOEXEC: |
2139 |
msg = "Exec format error"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2140 |
sym = @symbol(ENOEXEC); |
185 | 2141 |
break; |
443 | 2142 |
#endif |
2143 |
#ifdef EBADF |
|
185 | 2144 |
case EBADF: |
2145 |
msg = "Bad file number"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2146 |
sym = @symbol(EBADF); |
185 | 2147 |
break; |
443 | 2148 |
#endif |
2149 |
#ifdef ECHILD |
|
185 | 2150 |
case ECHILD: |
2151 |
msg = "No child processes"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2152 |
sym = @symbol(ECHILD); |
185 | 2153 |
break; |
443 | 2154 |
#endif |
77 | 2155 |
#if !defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN) |
185 | 2156 |
case EAGAIN: |
2157 |
msg = "Try again"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2158 |
sym = @symbol(EAGAIN); |
185 | 2159 |
break; |
77 | 2160 |
#endif |
443 | 2161 |
#ifdef ENOMEM |
185 | 2162 |
case ENOMEM: |
2163 |
msg = "Out of memory"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2164 |
sym = @symbol(ENOMEM); |
185 | 2165 |
break; |
443 | 2166 |
#endif |
2167 |
#ifdef EACCES |
|
185 | 2168 |
case EACCES: |
2169 |
msg = "Permission denied"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2170 |
sym = @symbol(EACCES); |
185 | 2171 |
break; |
443 | 2172 |
#endif |
2173 |
#ifdef EFAULT |
|
185 | 2174 |
case EFAULT: |
2175 |
msg = "Bad address"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2176 |
sym = @symbol(EFAULT); |
185 | 2177 |
break; |
443 | 2178 |
#endif |
2179 |
#ifdef EBUSY |
|
185 | 2180 |
case EBUSY: |
2181 |
msg = "Device or resource busy"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2182 |
sym = @symbol(EBUSY); |
185 | 2183 |
break; |
443 | 2184 |
#endif |
2185 |
#ifdef EEXIST |
|
185 | 2186 |
case EEXIST: |
2187 |
msg = "File exists"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2188 |
sym = @symbol(EEXIST); |
185 | 2189 |
break; |
443 | 2190 |
#endif |
2191 |
#ifdef EXDEV |
|
185 | 2192 |
case EXDEV: |
2193 |
msg = "Cross-device link"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2194 |
sym = @symbol(EXDEV); |
185 | 2195 |
break; |
443 | 2196 |
#endif |
2197 |
#ifdef ENODEV |
|
185 | 2198 |
case ENODEV: |
2199 |
msg = "No such device"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2200 |
sym = @symbol(ENODEV); |
185 | 2201 |
break; |
443 | 2202 |
#endif |
2203 |
#ifdef ENOTDIR |
|
185 | 2204 |
case ENOTDIR: |
2205 |
msg = "Not a directory"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2206 |
sym = @symbol(ENOTDIR); |
185 | 2207 |
break; |
443 | 2208 |
#endif |
2209 |
#ifdef EISDIR |
|
185 | 2210 |
case EISDIR: |
2211 |
msg = "Is a directory"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2212 |
sym = @symbol(EISDIR); |
185 | 2213 |
break; |
443 | 2214 |
#endif |
2215 |
#ifdef EINVAL |
|
185 | 2216 |
case EINVAL: |
2217 |
msg = "Invalid argument"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2218 |
sym = @symbol(EINVAL); |
185 | 2219 |
break; |
443 | 2220 |
#endif |
2221 |
#ifdef ENFILE |
|
185 | 2222 |
case ENFILE: |
2223 |
msg = "File table overflow"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2224 |
sym = @symbol(ENFILE); |
185 | 2225 |
break; |
443 | 2226 |
#endif |
2227 |
#ifdef EMFILE |
|
185 | 2228 |
case EMFILE: |
2229 |
msg = "Too many open files"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2230 |
sym = @symbol(EMFILE); |
185 | 2231 |
break; |
443 | 2232 |
#endif |
2233 |
#ifdef ENOTTY |
|
185 | 2234 |
case ENOTTY: |
2235 |
msg = "Not a typewriter"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2236 |
sym = @symbol(ENOTTY); |
185 | 2237 |
break; |
443 | 2238 |
#endif |
2239 |
#ifdef EFBIG |
|
185 | 2240 |
case EFBIG: |
2241 |
msg = "File too large"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2242 |
sym = @symbol(EFBIG); |
185 | 2243 |
break; |
443 | 2244 |
#endif |
2245 |
#ifdef ENOSPC |
|
185 | 2246 |
case ENOSPC: |
2247 |
msg = "No space left on device"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2248 |
sym = @symbol(ENOSPC); |
185 | 2249 |
break; |
443 | 2250 |
#endif |
2251 |
#ifdef ESPIPE |
|
185 | 2252 |
case ESPIPE: |
2253 |
msg = "Illegal seek"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2254 |
sym = @symbol(ESPIPE); |
185 | 2255 |
break; |
443 | 2256 |
#endif |
2257 |
#ifdef EROFS |
|
185 | 2258 |
case EROFS: |
2259 |
msg = "Read-only file system"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2260 |
sym = @symbol(EROFS); |
185 | 2261 |
break; |
443 | 2262 |
#endif |
2263 |
#ifdef EMLINK |
|
185 | 2264 |
case EMLINK: |
2265 |
msg = "Too many links"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2266 |
sym = @symbol(EMLINK); |
185 | 2267 |
break; |
443 | 2268 |
#endif |
2269 |
#ifdef EPIPE |
|
185 | 2270 |
case EPIPE: |
2271 |
msg = "Broken pipe"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2272 |
sym = @symbol(EPIPE); |
185 | 2273 |
break; |
443 | 2274 |
#endif |
2275 |
#ifdef EDOM |
|
185 | 2276 |
case EDOM: |
2277 |
msg = "Math argument out of domain"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2278 |
sym = @symbol(EDOM); |
185 | 2279 |
break; |
443 | 2280 |
#endif |
2281 |
#ifdef ERANGE |
|
185 | 2282 |
case ERANGE: |
2283 |
msg = "Math result not representable"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2284 |
sym = @symbol(ERANGE); |
185 | 2285 |
break; |
443 | 2286 |
#endif |
77 | 2287 |
#ifdef EDEADLK |
308 | 2288 |
# if EDEADLK != EWOULDBLOCK |
185 | 2289 |
case EDEADLK: |
2290 |
msg = "Resource deadlock would occur"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2291 |
sym = @symbol(EDEADLK); |
185 | 2292 |
break; |
308 | 2293 |
# endif |
77 | 2294 |
#endif |
2295 |
#ifdef ENAMETOOLONG |
|
185 | 2296 |
case ENAMETOOLONG: |
2297 |
msg = "File name too long"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2298 |
sym = @symbol(ENAMETOOLONG); |
185 | 2299 |
break; |
77 | 2300 |
#endif |
2301 |
#ifdef ENOLCK |
|
185 | 2302 |
case ENOLCK: |
2303 |
msg = "No record locks available"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2304 |
sym = @symbol(ENOLCK); |
185 | 2305 |
break; |
77 | 2306 |
#endif |
2307 |
#ifdef ENOSYS |
|
185 | 2308 |
case ENOSYS: |
2309 |
msg = "Function not implemented"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2310 |
sym = @symbol(ENOSYS); |
185 | 2311 |
break; |
77 | 2312 |
#endif |
359 | 2313 |
#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST) |
185 | 2314 |
case ENOTEMPTY: |
2315 |
msg = "Directory not empty"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2316 |
sym = @symbol(ENOTEMPTY); |
185 | 2317 |
break; |
77 | 2318 |
#endif |
2319 |
#ifdef EILSEQ |
|
185 | 2320 |
case EILSEQ: |
2321 |
msg = "Illegal byte sequence"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2322 |
sym = @symbol(EILSEQ); |
185 | 2323 |
break; |
77 | 2324 |
#endif |
185 | 2325 |
/* |
2326 |
* XPG3 errnos - defined on most systems |
|
2327 |
*/ |
|
77 | 2328 |
#ifdef ENOTBLK |
185 | 2329 |
case ENOTBLK: |
2330 |
msg = "Block device required"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2331 |
sym = @symbol(ENOTBLK); |
185 | 2332 |
break; |
77 | 2333 |
#endif |
2334 |
#ifdef ETXTBSY |
|
185 | 2335 |
case ETXTBSY: |
2336 |
msg = "Text file busy"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2337 |
sym = @symbol(ETXTBSY); |
185 | 2338 |
break; |
77 | 2339 |
#endif |
185 | 2340 |
/* |
2341 |
* some others |
|
2342 |
*/ |
|
77 | 2343 |
#ifdef EWOULDBLOCK |
185 | 2344 |
case EWOULDBLOCK: |
2345 |
msg = "Operation would block"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2346 |
sym = @symbol(EWOULDBLOCK); |
185 | 2347 |
break; |
77 | 2348 |
#endif |
2349 |
#ifdef ENOMSG |
|
185 | 2350 |
case ENOMSG: |
2351 |
msg = "No message of desired type"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2352 |
sym = @symbol(ENOMSG); |
185 | 2353 |
break; |
77 | 2354 |
#endif |
2355 |
#ifdef ELOOP |
|
185 | 2356 |
case ELOOP: |
2357 |
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
|
2358 |
sym = @symbol(ELOOP); |
185 | 2359 |
break; |
77 | 2360 |
#endif |
2361 |
||
185 | 2362 |
/* |
2363 |
* some stream errors |
|
2364 |
*/ |
|
77 | 2365 |
#ifdef ETIME |
185 | 2366 |
case ETIME: |
2367 |
msg = "Timer expired"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2368 |
sym = @symbol(ETIME); |
185 | 2369 |
break; |
77 | 2370 |
#endif |
2371 |
#ifdef ENOSR |
|
185 | 2372 |
case ENOSR: |
2373 |
msg = "Out of streams resources"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2374 |
sym = @symbol(ENOSR); |
185 | 2375 |
break; |
77 | 2376 |
#endif |
2377 |
#ifdef ENOSTR |
|
185 | 2378 |
case ENOSTR: |
2379 |
msg = "Device not a stream"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2380 |
sym = @symbol(ENOSTR); |
185 | 2381 |
break; |
77 | 2382 |
#endif |
2383 |
#ifdef ECOMM |
|
185 | 2384 |
case ECOMM: |
2385 |
msg = "Communication error on send"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2386 |
sym = @symbol(ECOMM); |
185 | 2387 |
break; |
77 | 2388 |
#endif |
2389 |
#ifdef EPROTO |
|
185 | 2390 |
case EPROTO: |
2391 |
msg = "Protocol error"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2392 |
sym = @symbol(EPROTO); |
185 | 2393 |
break; |
77 | 2394 |
#endif |
185 | 2395 |
/* |
2396 |
* nfs errors |
|
2397 |
*/ |
|
77 | 2398 |
#ifdef ESTALE |
185 | 2399 |
case ESTALE: |
2400 |
msg = "Stale NFS file handle"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2401 |
sym = @symbol(ESTALE); |
185 | 2402 |
break; |
77 | 2403 |
#endif |
2404 |
#ifdef EREMOTE |
|
185 | 2405 |
case EREMOTE: |
2406 |
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
|
2407 |
sym = @symbol(EREMOTE); |
185 | 2408 |
break; |
77 | 2409 |
#endif |
185 | 2410 |
/* |
2411 |
* some networking errors |
|
2412 |
*/ |
|
77 | 2413 |
#ifdef EINPROGRESS |
185 | 2414 |
case EINPROGRESS: |
2415 |
msg = "Operation now in progress"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2416 |
sym = @symbol(EINPROGRESS); |
185 | 2417 |
break; |
77 | 2418 |
#endif |
2419 |
#ifdef EALREADY |
|
185 | 2420 |
case EALREADY: |
2421 |
msg = "Operation already in progress"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2422 |
sym = @symbol(EALREADY); |
185 | 2423 |
break; |
77 | 2424 |
#endif |
2425 |
#ifdef ENOTSOCK |
|
185 | 2426 |
case ENOTSOCK: |
2427 |
msg = "Socket operation on non-socket"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2428 |
sym = @symbol(ENOTSOCK); |
185 | 2429 |
break; |
77 | 2430 |
#endif |
2431 |
#ifdef EDESTADDRREQ |
|
185 | 2432 |
case EDESTADDRREQ: |
2433 |
msg = "Destination address required"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2434 |
sym = @symbol(EDESTADDRREQ); |
185 | 2435 |
break; |
77 | 2436 |
#endif |
2437 |
#ifdef EMSGSIZE |
|
185 | 2438 |
case EMSGSIZE: |
2439 |
msg = "Message too long"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2440 |
sym = @symbol(EMSGSIZE); |
185 | 2441 |
break; |
77 | 2442 |
#endif |
2443 |
#ifdef EPROTOTYPE |
|
185 | 2444 |
case EPROTOTYPE: |
2445 |
msg = "Protocol wrong type for socket"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2446 |
sym = @symbol(EPROTOTYPE); |
185 | 2447 |
break; |
77 | 2448 |
#endif |
2449 |
#ifdef ENOPROTOOPT |
|
185 | 2450 |
case ENOPROTOOPT: |
2451 |
msg = "Protocol not available"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2452 |
sym = @symbol(ENOPROTOOPT); |
185 | 2453 |
break; |
77 | 2454 |
#endif |
2455 |
#ifdef EPROTONOSUPPORT |
|
185 | 2456 |
case EPROTONOSUPPORT: |
2457 |
msg = "Protocol not supported"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2458 |
sym = @symbol(EPROTONOSUPPORT); |
185 | 2459 |
break; |
77 | 2460 |
#endif |
2461 |
#ifdef ESOCKTNOSUPPORT |
|
185 | 2462 |
case ESOCKTNOSUPPORT: |
2463 |
msg = "Socket type not supported"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2464 |
sym = @symbol(ESOCKTNOSUPPORT); |
185 | 2465 |
break; |
77 | 2466 |
#endif |
2467 |
#ifdef EOPNOTSUPP |
|
185 | 2468 |
case EOPNOTSUPP: |
2469 |
msg = "Operation not supported on socket"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2470 |
sym = @symbol(EOPNOTSUPP); |
185 | 2471 |
break; |
77 | 2472 |
#endif |
2473 |
#ifdef EPFNOSUPPORT |
|
185 | 2474 |
case EPFNOSUPPORT: |
2475 |
msg = "Protocol family not supported"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2476 |
sym = @symbol(EPFNOSUPPORT); |
185 | 2477 |
break; |
77 | 2478 |
#endif |
2479 |
#ifdef EAFNOSUPPORT |
|
185 | 2480 |
case EAFNOSUPPORT: |
2481 |
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
|
2482 |
sym = @symbol(EAFNOSUPPORT); |
185 | 2483 |
break; |
77 | 2484 |
#endif |
2485 |
#ifdef EADDRINUSE |
|
185 | 2486 |
case EADDRINUSE: |
2487 |
msg = "Address already in use"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2488 |
sym = @symbol(EADDRINUSE); |
185 | 2489 |
break; |
77 | 2490 |
#endif |
2491 |
#ifdef EADDRNOTAVAIL |
|
185 | 2492 |
case EADDRNOTAVAIL: |
2493 |
msg = "Can\'t assign requested address"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2494 |
sym = @symbol(EADDRNOTAVAIL); |
185 | 2495 |
break; |
77 | 2496 |
#endif |
2497 |
#ifdef ETIMEDOUT |
|
185 | 2498 |
case ETIMEDOUT: |
2499 |
msg = "Connection timed out"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2500 |
sym = @symbol(ETIMEDOUT); |
185 | 2501 |
break; |
77 | 2502 |
#endif |
2503 |
#ifdef ECONNREFUSED |
|
185 | 2504 |
case ECONNREFUSED: |
2505 |
msg = "Connection refused"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2506 |
sym = @symbol(ECONNREFUSED); |
185 | 2507 |
break; |
77 | 2508 |
#endif |
362 | 2509 |
#ifdef ENETDOWN |
2510 |
case ENETDOWN: |
|
2511 |
msg = "Network is down"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2512 |
sym = @symbol(ENETDOWN); |
362 | 2513 |
break; |
2514 |
#endif |
|
2515 |
#ifdef ENETUNREACH |
|
2516 |
case ENETUNREACH: |
|
2517 |
msg = "Network is unreachable"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2518 |
sym = @symbol(ENETUNREACH); |
362 | 2519 |
break; |
2520 |
#endif |
|
2521 |
#ifdef ENETRESET |
|
2522 |
case ENETRESET: |
|
2523 |
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
|
2524 |
sym = @symbol(ENETRESET); |
362 | 2525 |
break; |
2526 |
#endif |
|
2527 |
#ifdef ECONNABORTED |
|
2528 |
case ECONNABORTED: |
|
2529 |
msg = "Software caused connection abort"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2530 |
sym = @symbol(ECONNABORTED); |
362 | 2531 |
break; |
2532 |
#endif |
|
2533 |
#ifdef ECONNRESET |
|
2534 |
case ECONNRESET: |
|
2535 |
msg = "Connection reset by peer"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2536 |
sym = @symbol(ECONNRESET); |
362 | 2537 |
break; |
2538 |
#endif |
|
2539 |
#ifdef EISCONN |
|
2540 |
case EISCONN: |
|
2541 |
msg = "Socket is already connected"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2542 |
sym = @symbol(EISCONN); |
362 | 2543 |
break; |
2544 |
#endif |
|
2545 |
#ifdef ENOTCONN |
|
2546 |
case ENOTCONN: |
|
2547 |
msg = "Socket is not connected"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2548 |
sym = @symbol(ENOTCONN); |
362 | 2549 |
break; |
2550 |
#endif |
|
2551 |
#ifdef ESHUTDOWN |
|
2552 |
case ESHUTDOWN: |
|
2553 |
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
|
2554 |
sym = @symbol(ESHUTDOWN); |
362 | 2555 |
break; |
2556 |
#endif |
|
2557 |
#ifdef EHOSTDOWN |
|
2558 |
case EHOSTDOWN: |
|
2559 |
msg = "Host is down"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2560 |
sym = @symbol(EHOSTDOWN); |
362 | 2561 |
break; |
2562 |
#endif |
|
2563 |
#ifdef EHOSTUNREACH |
|
2564 |
case EHOSTUNREACH: |
|
2565 |
msg = "No route to host"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2566 |
sym = @symbol(EHOSTUNREACH); |
362 | 2567 |
break; |
2568 |
#endif |
|
2569 |
||
185 | 2570 |
default: |
368 | 2571 |
{ |
809
5eef87c2907b
e convenient macro for register saving (sparc only)
Claus Gittinger <cg@exept.de>
parents:
805
diff
changeset
|
2572 |
__BEGIN_PROTECT_REGISTERS__ |
1135 | 2573 |
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
|
2574 |
__END_PROTECT_REGISTERS__ |
368 | 2575 |
} |
185 | 2576 |
msg = buffer; |
2577 |
break; |
|
2578 |
} |
|
77 | 2579 |
} |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2580 |
text = __MKSTRING(msg); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2581 |
%}. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2582 |
^ Array with:sym with:text |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2583 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2584 |
" |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2585 |
OperatingSystem errorSymbolAndTextForNumber:4 |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2586 |
" |
616 | 2587 |
! |
2588 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2589 |
errorSymbolForNumber:errNr |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2590 |
"return a symbol for a unix errorNumber |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2591 |
(as returned by a system call)." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2592 |
|
1153
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
2593 |
^ (self errorSymbolAndTextForNumber:errNr) at:1 |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2594 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2595 |
" |
1666 | 2596 |
OperatingSystem errorSymbolForNumber:4 |
2597 |
OperatingSystem errorSymbolForNumber:2 |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2598 |
" |
1153
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
2599 |
|
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
2600 |
"Modified: 12.4.1996 / 09:16:29 / stefan" |
1666 | 2601 |
"Modified: 13.9.1996 / 16:23:35 / cg" |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2602 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2603 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2604 |
errorTextForNumber:errNr |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2605 |
"return a message string from a unix errorNumber |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2606 |
(as returned by a system call). |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2607 |
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
|
2608 |
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
|
2609 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2610 |
^ (self errorSymbolAndTextForNumber:errNr) at:2 |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2611 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2612 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2613 |
OperatingSystem errorTextForNumber:4 |
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 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2616 |
|
616 | 2617 |
lastErrorNumber |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2618 |
"return the last errors number. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2619 |
See also: #lastErrorSymbol and #lastErrorString. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2620 |
Notice: having a single error number is a bad idea in a multithreaded |
1487 | 2621 |
environment - this interface will change." |
616 | 2622 |
|
2623 |
^ LastErrorNumber |
|
2624 |
||
2625 |
" |
|
2626 |
OperatingSystem lastErrorNumber |
|
2627 |
" |
|
2628 |
! |
|
2629 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2630 |
lastErrorString |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2631 |
"return a message string describing the last error. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2632 |
See also: #lastErrorNumber and #lastErrorSymbol. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2633 |
Notice: having a single error number is a bad idea in a multithreaded |
1487 | 2634 |
environment - this interface will change." |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2635 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2636 |
^ self errorTextForNumber:LastErrorNumber |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2637 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2638 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2639 |
OperatingSystem lastErrorString |
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 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2642 |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2643 |
lastErrorSymbol |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2644 |
"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
|
2645 |
See also: #lastErrorNumber and #lastErrorString. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2646 |
Notice: having a single error number is a bad idea in a multithreaded |
1487 | 2647 |
environment - this interface will change." |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2648 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2649 |
^ self errorSymbolForNumber:LastErrorNumber |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2650 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2651 |
" |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2652 |
OperatingSystem lastErrorSymbol |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2653 |
" |
1 | 2654 |
! ! |
2655 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
2656 |
!OperatingSystem class methodsFor:'executing OS commands'! |
616 | 2657 |
|
2658 |
canExecuteCommand:aCommandString |
|
2659 |
"return true, if the OS can execute aCommand." |
|
2660 |
||
2661 |
|cmd| |
|
2662 |
||
2663 |
cmd := aCommandString asCollectionOfWords first. |
|
2664 |
^ (self pathOfCommand:cmd) notNil |
|
2665 |
||
2666 |
" |
|
2667 |
OperatingSystem canExecuteCommand:'fooBar' |
|
2668 |
OperatingSystem canExecuteCommand:'ls' |
|
2669 |
OperatingSystem canExecuteCommand:'cvs' |
|
2670 |
" |
|
2671 |
||
2672 |
"Created: 4.11.1995 / 19:13:54 / cg" |
|
68 | 2673 |
! |
2674 |
||
616 | 2675 |
exec:aPath withArguments:argArray |
2676 |
"execute the unix command specified by the argument, aPath, with |
|
2677 |
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
|
2678 |
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
|
2679 |
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
|
2680 |
to another program." |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2681 |
|
792 | 2682 |
^ 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
|
2683 |
! |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2684 |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2685 |
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
|
2686 |
"Internal combined fork & exec; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2687 |
If fork is false: |
1487 | 2688 |
execute the unix command specified by the argument, aPath, with |
2689 |
arguments in argArray (no arguments, if nil). |
|
2690 |
If successful, this method does not return and smalltalk is gone. |
|
2691 |
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
|
2692 |
if its true: |
1487 | 2693 |
for a child to do the above. |
2694 |
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
|
2695 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2696 |
fdArray contains the filedescriptors, to be used for the child (if fork is true). |
1487 | 2697 |
fdArray[1] = 15 -> use fd 15 as stdin. |
2698 |
If an element of the array is set to nil, the corresponding filedescriptor |
|
2699 |
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
|
2700 |
|
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2701 |
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
|
2702 |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2703 |
If newPgrp is true, the subprocess will be established in a new process group. |
1487 | 2704 |
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
|
2705 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2706 |
Notice: this used to be two separate ST-methods; however, in order to use |
1487 | 2707 |
vfork on some machines, it had to be merged into one, to avoid write |
2708 |
accesses to ST/X memory from the vforked-child. The code below only does |
|
2709 |
read accesses." |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2710 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2711 |
%{ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2712 |
#ifndef MSDOS_LIKE |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2713 |
char **argv; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2714 |
int nargs, i, id; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2715 |
OBJ arg; |
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 |
if (__isString(aPath) && |
1487 | 2718 |
((argArray == nil) || __isArray(argArray)) && |
2719 |
((fdArray == nil) || __isArray(fdArray)) && |
|
2720 |
((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
|
2721 |
) { |
1487 | 2722 |
nargs = argArray == nil ? 0 : _arraySize(argArray); |
2723 |
argv = (char **) malloc(sizeof(char *) * (nargs + 1)); |
|
2724 |
if (argv) { |
|
2725 |
for (i=0; i < nargs; i++) { |
|
2726 |
arg = __ArrayInstPtr(argArray)->a_element[i]; |
|
2727 |
if (__isString(arg)) { |
|
2728 |
argv[i] = (char *) __stringVal(arg); |
|
2729 |
} else { |
|
2730 |
argv[i] = ""; |
|
2731 |
} |
|
2732 |
} |
|
2733 |
argv[i] = NULL; |
|
2734 |
||
2735 |
if (doFork == true) { |
|
2736 |
int nfd, nclose; |
|
2737 |
||
2738 |
nfd = fdArray == nil ? 0 : _arraySize(fdArray); |
|
2739 |
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
|
2740 |
#ifdef HAS_VFORK |
1487 | 2741 |
id = vfork(); |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2742 |
#else |
1487 | 2743 |
id = fork(); |
2744 |
#endif |
|
2745 |
if (id == 0) { |
|
2746 |
/* |
|
2747 |
** In child. |
|
2748 |
** first: dup filedescriptors |
|
2749 |
*/ |
|
2750 |
for (i = 0; i < nfd; i++) { |
|
2751 |
if (__isSmallInteger(__ArrayInstPtr(fdArray)->a_element[i]) && |
|
2752 |
__intVal(__ArrayInstPtr(fdArray)->a_element[i]) != i |
|
2753 |
) { |
|
2754 |
dup2(__intVal(__ArrayInstPtr(fdArray)->a_element[i]), i); |
|
2755 |
} |
|
2756 |
} |
|
2757 |
/* |
|
2758 |
** second: close unused filedescriptors |
|
2759 |
*/ |
|
2760 |
for (i = 0; i < nfd; i++) { |
|
2761 |
if (__ArrayInstPtr(fdArray)->a_element[i] == nil) { |
|
2762 |
close(i); |
|
2763 |
} |
|
2764 |
} |
|
2765 |
/* |
|
2766 |
** third: close filedescriptors |
|
2767 |
*/ |
|
2768 |
for (i = 0; i < nclose; i++) { |
|
2769 |
if (__isSmallInteger(__ArrayInstPtr(closeFdArray)->a_element[i])) { |
|
2770 |
close(__intVal(__ArrayInstPtr(closeFdArray)->a_element[i])); |
|
2771 |
} |
|
2772 |
} |
|
2773 |
if (newPgrp == true) { |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2774 |
#if defined(_POSIX_JOB_CONTROL) |
1487 | 2775 |
(void) setpgid(0, 0); |
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2776 |
#else |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2777 |
#if defined(BSD) |
1487 | 2778 |
(void) setpgrp(0); |
2779 |
#endif |
|
2780 |
#endif |
|
2781 |
} |
|
2782 |
||
2783 |
execv(__stringVal(aPath), argv); |
|
2784 |
/* should not be reached */ |
|
2785 |
_exit(127); /* POSIX 2 compatible exit value */ |
|
2786 |
} |
|
2787 |
/* |
|
2788 |
** In parent: succes or failure |
|
2789 |
*/ |
|
2790 |
free(argv); |
|
2791 |
RETURN (__MKSMALLINT(id)); |
|
2792 |
} else { |
|
2793 |
execv(__stringVal(aPath), argv); |
|
2794 |
/* |
|
2795 |
* should not be reached |
|
2796 |
* (well, it is, if you pass a wrong command-path) |
|
2797 |
*/ |
|
2798 |
free(argv); |
|
2799 |
RETURN ( false ); |
|
2800 |
} |
|
2801 |
} |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2802 |
} |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2803 |
#endif |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2804 |
%}. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2805 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2806 |
path-argument not string |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2807 |
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
|
2808 |
or malloc failed |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2809 |
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
|
2810 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2811 |
^ self primitiveFailed |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2812 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2813 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2814 |
|id| |
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 |
id := OperatingSystem fork. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2817 |
id == 0 ifTrue:[ |
1487 | 2818 |
"I am the child" |
2819 |
OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp'). |
|
2820 |
"not reached" |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2821 |
] |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2822 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2823 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2824 |
|id| |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2825 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2826 |
id := OperatingSystem fork. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2827 |
id == 0 ifTrue:[ |
1487 | 2828 |
"I am the child" |
2829 |
OperatingSystem exec:'/bin/sh' withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2'). |
|
2830 |
"not reached" |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2831 |
]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2832 |
id printNL. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2833 |
(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
|
2834 |
'killing ...' printNL. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2835 |
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
|
2836 |
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
|
2837 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2838 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2839 |
|
1076
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2840 |
exec:aPath withArguments:argArray fileDescriptors:fdArray fork:doFork |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2841 |
"Internal combined fork & exec; |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2842 |
If fork is false: |
1487 | 2843 |
execute the unix command specified by the argument, aPath, with |
2844 |
arguments in argArray (no arguments, if nil). |
|
2845 |
If successful, this method does not return and smalltalk is gone. |
|
2846 |
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
|
2847 |
if its true: |
1487 | 2848 |
for a child to do the above. |
2849 |
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
|
2850 |
|
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2851 |
fdArray contains the filedescriptors, to be used for the child (if fork is true). |
1487 | 2852 |
fdArray[1] = 15 -> use fd 15 as stdin. |
2853 |
If an element of the array is set to nil, the corresponding filedescriptor |
|
2854 |
will be closed for the child. |
|
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 |
Notice: this used to be two separate ST-methods; however, in order to use |
1487 | 2857 |
vfork on some machines, it had to be merged into one, to avoid write |
2858 |
accesses to ST/X memory from the vforked-child. The code below only does |
|
2859 |
read accesses." |
|
1076
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2860 |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2861 |
^ 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
|
2862 |
|
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2863 |
"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
|
2864 |
! |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2865 |
|
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2866 |
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
|
2867 |
"Internal combined fork & exec; |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2868 |
If fork is false: |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2869 |
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
|
2870 |
arguments in argArray (no arguments, if nil). |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2871 |
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
|
2872 |
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
|
2873 |
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
|
2874 |
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
|
2875 |
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
|
2876 |
|
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2877 |
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
|
2878 |
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
|
2879 |
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
|
2880 |
read accesses." |
616 | 2881 |
|
2882 |
%{ |
|
792 | 2883 |
#ifndef MSDOS_LIKE |
616 | 2884 |
char **argv; |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2885 |
int nargs, i, id; |
616 | 2886 |
OBJ arg; |
2887 |
||
2888 |
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
|
2889 |
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
|
2890 |
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
|
2891 |
if (argv) { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2892 |
for (i=0; i < nargs; i++) { |
1135 | 2893 |
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
|
2894 |
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
|
2895 |
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
|
2896 |
} else { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2897 |
argv[i] = ""; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2898 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2899 |
} |
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] = NULL; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2901 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2902 |
if (doFork == true) { |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2903 |
#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
|
2904 |
id = vfork(); |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2905 |
#else |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2906 |
id = fork(); |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2907 |
#endif |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2908 |
if (id == 0) { |
1135 | 2909 |
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
|
2910 |
/* 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
|
2911 |
_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
|
2912 |
} |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2913 |
free(argv); |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2914 |
RETURN (__MKSMALLINT(id)); |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2915 |
} else { |
1135 | 2916 |
execv(__stringVal(aPath), argv); |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2917 |
/* |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2918 |
* should not be reached |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2919 |
* (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
|
2920 |
*/ |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2921 |
free(argv); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2922 |
RETURN ( false ); |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2923 |
} |
616 | 2924 |
} |
2925 |
} |
|
792 | 2926 |
#endif |
616 | 2927 |
%}. |
2928 |
" |
|
792 | 2929 |
path-argument not string |
2930 |
or argArray not an array/nil |
|
2931 |
or malloc failed |
|
2932 |
or not supported by OS |
|
616 | 2933 |
" |
2934 |
^ self primitiveFailed |
|
2935 |
||
2936 |
" |
|
2937 |
|id| |
|
2938 |
||
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2939 |
id := OperatingSystem fork. |
616 | 2940 |
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
|
2941 |
"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
|
2942 |
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
|
2943 |
"not reached" |
616 | 2944 |
] |
2945 |
" |
|
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2946 |
" |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2947 |
|id| |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2948 |
|
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2949 |
id := OperatingSystem fork. |
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2950 |
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
|
2951 |
"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
|
2952 |
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
|
2953 |
"not reached" |
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2954 |
]. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2955 |
id printNL. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2956 |
(Delay forSeconds:3.5) wait. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2957 |
'killing ...' printNL. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2958 |
OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2959 |
OperatingSystem sendSignal:(OperatingSystem sigKILL) to:id |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2960 |
" |
616 | 2961 |
! |
2962 |
||
2963 |
executeCommand:aCommandString |
|
2964 |
"execute the unix command specified by the argument, aCommandString. |
|
676 | 2965 |
The commandString is passed to a shell for execution - see the description of |
2966 |
'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
|
2967 |
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
|
2968 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2969 |
^ self executeCommand:aCommandString onError:[:status| false] |
2080
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2970 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2971 |
"/Old code: |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2972 |
"/ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2973 |
"/%{ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2974 |
"/ int status; |
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 |
"/ if (__isString(aCommandString)) { |
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 |
"/ * 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
|
2979 |
"/ * system() libc-function, which is interruptable ... |
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 |
"/# ifdef WANT_SYSTEM |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2982 |
"/ status = mySystem((char *) __stringVal(aCommandString)); |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2983 |
"/# else |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2984 |
"/ status = system((char *) __stringVal(aCommandString)); |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2985 |
"/# endif |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2986 |
"/ OperatingSystem_LastExecStatus = __MKSMALLINT(status); |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2987 |
"/ if (status == 0) { |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2988 |
"/ RETURN ( true ); |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2989 |
"/ } |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2990 |
"/ OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2991 |
"/ RETURN ( false ); |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2992 |
"/ } |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2993 |
"/%}. |
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 |
"/ "/ invalid argument (non-string) |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2996 |
"/ "/ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2997 |
"/ ^ self primitiveFailed |
616 | 2998 |
|
2999 |
" |
|
805 | 3000 |
OperatingSystem executeCommand:'sleep 30'. |
616 | 3001 |
OperatingSystem executeCommand:'pwd'. |
3002 |
OperatingSystem executeCommand:'ls -l'. |
|
3003 |
OperatingSystem executeCommand:'invalidCommand'. |
|
3004 |
OperatingSystem executeCommand:'rm /tmp/foofoofoofoo'. |
|
3005 |
" |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3006 |
|
2080
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
3007 |
"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
|
3008 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3009 |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3010 |
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
|
3011 |
"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
|
3012 |
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
|
3013 |
'sh -c' in your UNIX manual. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3014 |
Return true if successful. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3015 |
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
|
3016 |
as argument." |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3017 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3018 |
|pid exitStatus sema| |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3019 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3020 |
sema := Semaphore new. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3021 |
|
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 := self |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3024 |
startProcess:aCommandString |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3025 |
inputFrom:anExternalInStream |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3026 |
outputTo:anExternalOutStream |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3027 |
errorTo:anExternalErrStream. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3028 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3029 |
pid > 0 ifTrue:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3030 |
Processor monitorPid:pid action:[:status | |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3031 |
status stillAlive ifFalse:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3032 |
exitStatus := status. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3033 |
sema signal |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3034 |
]. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3035 |
]. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3036 |
sema wait. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3037 |
] ifFalse:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3038 |
exitStatus := OSProcessStatus processCreationFailure. |
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 |
] valueUninterruptably. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3041 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3042 |
exitStatus success ifFalse:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3043 |
^ aBlock value:exitStatus |
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 |
^ true. |
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 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3048 |
executeCommand:aCommandString onError:aBlock |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3049 |
"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
|
3050 |
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
|
3051 |
'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
|
3052 |
Return true if successful. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3053 |
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
|
3054 |
as argument." |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3055 |
|
1034 | 3056 |
|pid exitStatus sema| |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3057 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3058 |
sema := Semaphore new. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3059 |
|
1034 | 3060 |
[ |
1487 | 3061 |
pid := self startProcess:aCommandString. |
3062 |
pid > 0 ifTrue:[ |
|
3063 |
Processor monitorPid:pid action:[:status | |
|
3064 |
status stillAlive ifFalse:[ |
|
3065 |
exitStatus := status. |
|
3066 |
sema signal |
|
3067 |
]. |
|
3068 |
]. |
|
3069 |
sema wait. |
|
3070 |
] ifFalse:[ |
|
3071 |
exitStatus := OSProcessStatus processCreationFailure. |
|
3072 |
]. |
|
1034 | 3073 |
] valueUninterruptably. |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3074 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3075 |
exitStatus success ifFalse:[ |
1487 | 3076 |
^ aBlock value:exitStatus |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3077 |
]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3078 |
^ true. |
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 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3081 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3082 |
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
|
3083 |
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
|
3084 |
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
|
3085 |
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
|
3086 |
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
|
3087 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3088 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3089 |
"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
|
3090 |
"Modified: 28.12.1995 / 15:25:48 / stefan" |
1034 | 3091 |
"Modified: 28.2.1996 / 21:41:23 / cg" |
616 | 3092 |
! |
3093 |
||
3094 |
fork |
|
3095 |
"fork a new (HEAVY-weight) unix process. |
|
3096 |
Dont confuse this with Block>>fork, which creates |
|
3097 |
lightweight smalltalk processes. This method will return |
|
676 | 3098 |
0 to the child process, and a non-zero number (which is the childs |
3099 |
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
|
3100 |
|
676 | 3101 |
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
|
3102 |
#startProcess: and #executCommand: for higher level interfaces." |
68 | 3103 |
|
3104 |
%{ /* NOCONTEXT */ |
|
792 | 3105 |
#ifndef MSDOS_LIKE |
616 | 3106 |
|
3107 |
int pid; |
|
3108 |
||
3109 |
pid = fork(); |
|
1135 | 3110 |
RETURN ( __MKSMALLINT(pid) ); |
792 | 3111 |
#endif |
3112 |
%}. |
|
3113 |
"/ |
|
3114 |
"/ not supported by OS |
|
3115 |
"/ |
|
3116 |
^ self primitiveFailed |
|
3117 |
||
616 | 3118 |
" |
3119 |
|id| |
|
3120 |
||
3121 |
id := OperatingSystem fork. |
|
3122 |
id == 0 ifTrue:[ |
|
3123 |
OperatingSystem exit |
|
3124 |
] |
|
3125 |
" |
|
68 | 3126 |
! |
3127 |
||
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3128 |
getStatusOfProcess:aProcessId |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3129 |
"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
|
3130 |
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
|
3131 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3132 |
%{ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3133 |
#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
|
3134 |
int status; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3135 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3136 |
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
|
3137 |
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
|
3138 |
{ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3139 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3140 |
# 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
|
3141 |
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
|
3142 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3143 |
do { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3144 |
__BEGIN_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3145 |
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
|
3146 |
__END_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3147 |
if (child < 0 && errno != EINTR) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
3148 |
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
|
3149 |
status = -1; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3150 |
break; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3151 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3152 |
} 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
|
3153 |
# else |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3154 |
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
|
3155 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3156 |
/* 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
|
3157 |
do { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3158 |
__BEGIN_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3159 |
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
|
3160 |
__END_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3161 |
} 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
|
3162 |
if (child != pid) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
3163 |
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
|
3164 |
status = -1; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3165 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3166 |
# 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
|
3167 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3168 |
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
|
3169 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3170 |
#endif |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3171 |
%}. |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3172 |
self primitiveFailed |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3173 |
|
1034 | 3174 |
! |
3175 |
||
3176 |
pathOfCommand:aCommand |
|
3177 |
"find where aCommand's executable file is" |
|
3178 |
||
3179 |
|path f| |
|
3180 |
||
3181 |
path := self getEnvironment:'PATH'. |
|
3182 |
path notNil ifTrue:[ |
|
3183 |
(path asCollectionOfSubstringsSeparatedBy:$:) do:[:path | |
|
3184 |
(f := (path asFilename construct:aCommand)) isExecutable ifTrue:[ |
|
3185 |
^ f pathName |
|
3186 |
] |
|
3187 |
]. |
|
3188 |
]. |
|
3189 |
^ nil |
|
3190 |
||
3191 |
" |
|
3192 |
OperatingSystem pathOfCommand:'fooBar' |
|
3193 |
OperatingSystem pathOfCommand:'ls' |
|
3194 |
OperatingSystem pathOfCommand:'cvs' |
|
3195 |
" |
|
3196 |
! |
|
3197 |
||
3198 |
startProcess:aCommandString |
|
3199 |
"start executing the unix command as specified by the argument, aCommandString |
|
3200 |
as a separate process; do not wait for the command to finish. |
|
3201 |
The commandString is passed to a shell for execution - see the description of |
|
3202 |
'sh -c' in your UNIX manual. |
|
3203 |
Return the processId if successful, nil otherwise. |
|
3204 |
Use #waitForProcess: for synchronization and exec status return, |
|
3205 |
or #killProcess: to stop it." |
|
3206 |
||
3207 |
^ self |
|
3208 |
exec:'/bin/sh' |
|
3209 |
withArguments:(Array with:'sh' with:'-c' with:aCommandString) |
|
3210 |
fork:true. |
|
3211 |
||
3212 |
" |
|
3213 |
|pid| |
|
3214 |
||
3215 |
pid := OperatingSystem startProcess:'sleep 2; echo 1; sleep 2; echo 2'. |
|
3216 |
(Delay forSeconds:3) wait. |
|
3217 |
OperatingSystem killProcess:pid. |
|
3218 |
" |
|
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3219 |
! |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3220 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3221 |
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
|
3222 |
"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
|
3223 |
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
|
3224 |
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
|
3225 |
'sh -c' in your UNIX manual. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3226 |
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
|
3227 |
each may be nil. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3228 |
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
|
3229 |
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
|
3230 |
or #killProcess: to stop it." |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3231 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3232 |
|in out err| |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3233 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3234 |
anExternalInStream notNil ifTrue:[ |
1487 | 3235 |
in := anExternalInStream fileDescriptor. |
1046 | 3236 |
] ifFalse:[ |
1487 | 3237 |
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
|
3238 |
]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3239 |
anExternalOutStream notNil ifTrue:[ |
1487 | 3240 |
out := anExternalOutStream fileDescriptor. |
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3241 |
]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3242 |
anExternalErrStream notNil ifTrue:[ |
1487 | 3243 |
err := anExternalErrStream fileDescriptor. |
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3244 |
]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3245 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3246 |
^ self |
1487 | 3247 |
exec:'/bin/sh' |
3248 |
withArguments:(Array with:'sh' with:'-c' with:aCommandString) |
|
3249 |
fileDescriptors:(Array with:in with:out with:err) |
|
3250 |
fork:true. |
|
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3251 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3252 |
"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
|
3253 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3254 |
OperatingSystem executeCommand:'ls -l > out'. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3255 |
" |
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 |
"non-blocking (lower prio threads continue): |
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 |
|in out err pid sema| |
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 |
in := 'out' asFilename readStream. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3262 |
out := 'out2' asFilename writeStream. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3263 |
err := 'err' asFilename writeStream. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3264 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3265 |
sema := Semaphore new. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3266 |
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
|
3267 |
pid notNil ifTrue:[ |
1487 | 3268 |
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
|
3269 |
]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3270 |
in close. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3271 |
out close. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3272 |
err close. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3273 |
sema wait. |
1422 | 3274 |
Transcript showCR:'finished' |
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3275 |
" |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3276 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3277 |
"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
|
3278 |
"Modified: 29.2.1996 / 12:49:14 / cg" |
616 | 3279 |
! ! |
3280 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
3281 |
!OperatingSystem class methodsFor:'file access'! |
616 | 3282 |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3283 |
closeFd:anInteger |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3284 |
"low level close of a filedescriptor" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3285 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3286 |
%{ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3287 |
#if !defined(transputer) && !defined(MSDOS_LIKE) |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3288 |
if (__isSmallInteger(anInteger)) { |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3289 |
close(__intVal(anInteger)); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3290 |
RETURN(self); |
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 |
#endif |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3293 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3294 |
^ self primitiveFailed. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3295 |
! |
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 |
createDirectory:newPathName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3298 |
"create a new directory with name 'newPathName'. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3299 |
Return true if successful, false if failed. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3300 |
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
|
3301 |
|
1497 | 3302 |
"/ if it already exists this is ok |
3303 |
||
3304 |
(self isDirectory:newPathName) ifTrue:[^ true]. |
|
3305 |
||
3306 |
"/ since createDirectory is not used too often, |
|
3307 |
"/ you'll forgive me using mkdir ... |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3308 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3309 |
^ self executeCommand:('mkdir 2>/dev/null ', newPathName) |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3310 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3311 |
" |
1497 | 3312 |
OperatingSystem createDirectory:'foo' |
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 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3315 |
"Modified: 20.12.1995 / 11:24:13 / stefan" |
1497 | 3316 |
"Modified: 29.6.1996 / 14:06:54 / cg" |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3317 |
! |
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 |
linkFile:oldPath to:newPath |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3320 |
"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
|
3321 |
Return true if successful, false if not." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3322 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3323 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3324 |
#ifndef MSDOS_LIKE |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3325 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3326 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3327 |
if (__isString(oldPath) && __isString(newPath)) { |
1487 | 3328 |
__BEGIN_INTERRUPTABLE__ |
3329 |
do { |
|
3330 |
ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath)); |
|
3331 |
} while (ret < 0 && errno == EINTR); |
|
3332 |
__END_INTERRUPTABLE__ |
|
3333 |
if (ret < 0) { |
|
3334 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3335 |
RETURN ( false ); |
|
3336 |
} |
|
3337 |
RETURN (true); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3338 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3339 |
#endif |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3340 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3341 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3342 |
|
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 |
OperatingSystem linkFile:'foo' to:'bar' |
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 |
! |
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 |
makePipe |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3349 |
"make a pipe, return array with two filedescriptors on success, |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3350 |
nil on failure. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3351 |
This is a lowLevel entry, not for public use. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3352 |
See ExternalStream>>makePipe for a more user-friendly, public interface." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3353 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3354 |
|fd1 fd2| |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3355 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3356 |
%{ |
1597 | 3357 |
#ifdef UNIX_LIKE |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3358 |
int fds[2]; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3359 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3360 |
if (pipe(fds) < 0) { |
1487 | 3361 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
3362 |
RETURN ( nil ); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3363 |
} |
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 |
fd1 = __MKSMALLINT(fds[0]); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3366 |
fd2 = __MKSMALLINT(fds[1]); |
1597 | 3367 |
#endif |
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 |
^ Array with:fd1 with:fd2. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3371 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3372 |
|
1132 | 3373 |
recursiveCopyDirectory:sourcePathName to:destination |
3374 |
"copy the directory named 'sourcePathName' and all contained files/directories to 'destination'. |
|
3375 |
Return true if successful." |
|
3376 |
||
3377 |
^ self executeCommand:('cp -rf ' , sourcePathName, ' ', destination) |
|
3378 |
||
3379 |
"Modified: 7.3.1996 / 15:26:30 / cg" |
|
3380 |
! |
|
3381 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3382 |
recursiveCreateDirectory:dirName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3383 |
"create a directory - with all parent dirs if needed. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3384 |
Return true if successful, false otherwise. If false |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3385 |
is returned, a partial created tree may be left, |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3386 |
which is not cleaned-up here." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3387 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3388 |
self createDirectory:dirName. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3389 |
(self isDirectory:dirName) ifFalse:[ |
1487 | 3390 |
(self recursiveCreateDirectory:(self directoryNameOf:dirName)) ifFalse:[^ false]. |
3391 |
^ self createDirectory:dirName |
|
1084
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 |
^ true |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3394 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3395 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3396 |
OperatingSystem recursiveCreateDirectory:'foo/bar/baz' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3397 |
OperatingSystem recursiveRemoveDirectory:'foo' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3398 |
" |
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 |
"Modified: 7.3.1996 / 15:26:22 / cg" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3401 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3402 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3403 |
recursiveRemoveDirectory:fullPathName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3404 |
"remove the directory named 'fullPathName' and all contained files/directories. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3405 |
Return true if successful." |
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 |
^ self executeCommand:('rm -rf ' , fullPathName) |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3408 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3409 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3410 |
OperatingSystem recursiveCreateDirectory:'foo/bar/baz' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3411 |
OperatingSystem recursiveRemoveDirectory:'foo' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3412 |
" |
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 |
"Modified: 7.3.1996 / 15:26:30 / cg" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3415 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3416 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3417 |
removeDirectory:fullPathName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3418 |
"remove the directory named 'fullPathName'. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3419 |
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
|
3420 |
This is a lowLevel entry - use Filename protocol for compatibility." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3421 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3422 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3423 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3424 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3425 |
if (__isString(fullPathName)) { |
1487 | 3426 |
__BEGIN_INTERRUPTABLE__ |
3427 |
do { |
|
3428 |
ret = rmdir((char *) __stringVal(fullPathName)); |
|
3429 |
} while (ret < 0 && errno == EINTR); |
|
3430 |
__END_INTERRUPTABLE__ |
|
3431 |
if (ret < 0) { |
|
3432 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3433 |
RETURN ( false ); |
|
3434 |
} |
|
3435 |
RETURN (true); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3436 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3437 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3438 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3439 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3440 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3441 |
OperatingSystem createDirectory:'foo' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3442 |
OperatingSystem removeDirectory:'foo' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3443 |
" |
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 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3447 |
removeFile:fullPathName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3448 |
"remove the file named 'fullPathName'; return true if successful. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3449 |
This is a lowLevel entry - use Filename protocol for compatibility." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3450 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3451 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3452 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3453 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3454 |
if (__isString(fullPathName)) { |
1487 | 3455 |
__BEGIN_INTERRUPTABLE__ |
3456 |
do { |
|
3457 |
ret = unlink((char *) __stringVal(fullPathName)); |
|
3458 |
} while (ret < 0 && errno == EINTR); |
|
3459 |
__END_INTERRUPTABLE__ |
|
3460 |
if (ret < 0) { |
|
3461 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3462 |
RETURN ( false ); |
|
3463 |
} |
|
3464 |
RETURN (true); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3465 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3466 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3467 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3468 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3469 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3470 |
renameFile:oldPath to:newPath |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3471 |
"rename the file 'oldPath' to 'newPath'. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3472 |
Return true if successful, false if not" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3473 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3474 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3475 |
int ret, eno; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3476 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3477 |
if (__isString(oldPath) && __isString(newPath)) { |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3478 |
#if defined(HAS_RENAME) |
1487 | 3479 |
__BEGIN_INTERRUPTABLE__ |
3480 |
do { |
|
3481 |
ret = rename((char *) __stringVal(oldPath), (char *) __stringVal(newPath)); |
|
3482 |
} while (ret < 0 && errno == EINTR); |
|
3483 |
__END_INTERRUPTABLE__ |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3484 |
#else |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3485 |
# ifndef MSDOS_LIKE |
1487 | 3486 |
ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath)); |
3487 |
if (ret >= 0) { |
|
3488 |
ret = unlink((char *) __stringVal(oldPath)); |
|
3489 |
if (ret < 0) { |
|
3490 |
eno = errno; |
|
3491 |
unlink((char *) __stringVal(newPath)); |
|
3492 |
errno = eno; |
|
3493 |
} |
|
3494 |
} |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3495 |
# endif |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3496 |
#endif |
1487 | 3497 |
if (ret < 0) { |
3498 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3499 |
RETURN ( false ); |
|
3500 |
} |
|
3501 |
RETURN (true); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3502 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3503 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3504 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3505 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3506 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3507 |
OperatingSystem renameFile:'foo' to:'bar' |
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 |
! |
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 |
truncateFile:aPathName to:newSize |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3512 |
"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
|
3513 |
This may not be supported on all architectures. |
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 |
This is a low-level entry - use Filename protocol." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3516 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3517 |
%{ |
1623
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3518 |
#ifdef HAS_TRUNCATE |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3519 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3520 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3521 |
if (__isString(aPathName) |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3522 |
&& __isSmallInteger(newSize)) { |
1487 | 3523 |
__BEGIN_INTERRUPTABLE__ |
3524 |
do { |
|
3525 |
ret = truncate((char *) __stringVal(aPathName), __intVal(newSize)); |
|
3526 |
} while (ret < 0 && errno == EINTR); |
|
3527 |
__END_INTERRUPTABLE__ |
|
3528 |
if (ret < 0) { |
|
3529 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3530 |
RETURN ( false ); |
|
3531 |
} |
|
3532 |
RETURN (true); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3533 |
} |
1623
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3534 |
#else |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3535 |
# ifdef HAS_FTRUNCATE |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3536 |
int ret; |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3537 |
int fd; |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3538 |
|
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3539 |
if (__isString(aPathName) |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3540 |
&& __isSmallInteger(newSize)) { |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3541 |
do { |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3542 |
fd = open((char *) __stringVal(aPathName), 2); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3543 |
} while (fd < 0 && errno == EINTR); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3544 |
if (fd < 0) { |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3545 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3546 |
RETURN ( false ); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3547 |
} |
1632 | 3548 |
|
1623
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3549 |
ret = ftruncate(fd, __intVal(newSize)); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3550 |
close(fd); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3551 |
if (ret < 0) { |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3552 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3553 |
RETURN ( false ); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3554 |
} |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3555 |
RETURN (true); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3556 |
} |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3557 |
# endif /* using FTRUNCATE */ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3558 |
#endif |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3559 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3560 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3561 |
! ! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3562 |
|
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
3563 |
!OperatingSystem class methodsFor:'file access rights'! |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3564 |
|
616 | 3565 |
accessMaskFor:aSymbol |
3566 |
"return the access bits mask for numbers as returned by |
|
3567 |
OperatingSystem>>accessModeOf: |
|
3568 |
and expected by OperatingSystem>>changeAccessModeOf:to:. |
|
3569 |
Since these numbers are OS dependent, always use the mask |
|
3570 |
(never hardcode 8rxxx into your code)." |
|
68 | 3571 |
|
3572 |
%{ /* NOCONTEXT */ |
|
616 | 3573 |
# ifndef S_IRUSR |
3574 |
/* posix systems should define these ... */ |
|
3575 |
# define S_IRUSR 0400 |
|
3576 |
# define S_IWUSR 0200 |
|
3577 |
# define S_IXUSR 0100 |
|
3578 |
# define S_IRGRP 0040 |
|
3579 |
# define S_IWGRP 0020 |
|
3580 |
# define S_IXGRP 0010 |
|
3581 |
# define S_IROTH 0004 |
|
3582 |
# define S_IWOTH 0002 |
|
3583 |
# define S_IXOTH 0001 |
|
3584 |
||
3585 |
# endif |
|
3586 |
||
3587 |
if (aSymbol == @symbol(readUser)) { |
|
1135 | 3588 |
RETURN ( __MKSMALLINT(S_IRUSR) ); |
616 | 3589 |
} |
3590 |
if (aSymbol == @symbol(writeUser)) { |
|
1135 | 3591 |
RETURN ( __MKSMALLINT(S_IWUSR) ); |
616 | 3592 |
} |
3593 |
if (aSymbol == @symbol(executeUser)) { |
|
1135 | 3594 |
RETURN ( __MKSMALLINT(S_IXUSR) ); |
616 | 3595 |
} |
3596 |
if (aSymbol == @symbol(readGroup)) { |
|
1135 | 3597 |
RETURN ( __MKSMALLINT(S_IRGRP) ); |
616 | 3598 |
} |
3599 |
if (aSymbol == @symbol(writeGroup)) { |
|
1135 | 3600 |
RETURN ( __MKSMALLINT(S_IWGRP) ); |
616 | 3601 |
} |
3602 |
if (aSymbol == @symbol(executeGroup)) { |
|
1135 | 3603 |
RETURN ( __MKSMALLINT(S_IXGRP) ); |
616 | 3604 |
} |
3605 |
if (aSymbol == @symbol(readOthers)) { |
|
1135 | 3606 |
RETURN ( __MKSMALLINT(S_IROTH) ); |
616 | 3607 |
} |
3608 |
if (aSymbol == @symbol(writeOthers)) { |
|
1135 | 3609 |
RETURN ( __MKSMALLINT(S_IWOTH) ); |
616 | 3610 |
} |
3611 |
if (aSymbol == @symbol(executeOthers)) { |
|
1135 | 3612 |
RETURN ( __MKSMALLINT(S_IXOTH) ); |
616 | 3613 |
} |
3614 |
%}. |
|
792 | 3615 |
^ self primitiveFailed |
616 | 3616 |
|
3617 |
" |
|
3618 |
OperatingSystem accessMaskFor:#readUser |
|
3619 |
" |
|
68 | 3620 |
! |
3621 |
||
616 | 3622 |
accessModeOf:aPathName |
3623 |
"return a number representing access rights rwxrwxrwx for owner, |
|
3624 |
group and others. Return nil if such a file does not exist. |
|
3625 |
Notice that the returned number is OS dependent - use the |
|
3626 |
modeMasks as returned by OperatingSystem>>accessMaskFor:" |
|
3627 |
||
3628 |
" |
|
3629 |
this could have been implemented as: |
|
1487 | 3630 |
(self infoOf:aPathName) at:#mode |
616 | 3631 |
but for huge directory searches the code below is faster |
3632 |
" |
|
345 | 3633 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3634 |
%{ |
616 | 3635 |
struct stat buf; |
3636 |
int ret; |
|
3637 |
||
3638 |
if (__isString(aPathName)) { |
|
1487 | 3639 |
__BEGIN_INTERRUPTABLE__ |
3640 |
do { |
|
3641 |
ret = stat((char *) __stringVal(aPathName), &buf); |
|
3642 |
} while ((ret < 0) && (errno == EINTR)); |
|
3643 |
__END_INTERRUPTABLE__ |
|
3644 |
||
3645 |
if (ret < 0) { |
|
3646 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3647 |
RETURN ( nil ); |
|
3648 |
} |
|
3649 |
RETURN ( __MKSMALLINT(buf.st_mode & 0777) ); |
|
616 | 3650 |
} |
3651 |
%}. |
|
792 | 3652 |
^ self primitiveFailed |
616 | 3653 |
|
3654 |
" |
|
3655 |
(OperatingSystem accessModeOf:'/') printStringRadix:8 |
|
3656 |
" |
|
345 | 3657 |
! |
3658 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3659 |
changeAccessModeOf:aPathName to:modeBits |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3660 |
"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
|
3661 |
You should construct this mask using accessMaskFor, to be OS |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3662 |
independent. Return true if changed, |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3663 |
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
|
3664 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3665 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3666 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3667 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3668 |
if (__isString(aPathName) && __isSmallInteger(modeBits)) { |
1487 | 3669 |
__BEGIN_INTERRUPTABLE__ |
3670 |
do { |
|
3671 |
ret = chmod((char *)__stringVal(aPathName), __intVal(modeBits)); |
|
3672 |
} while (ret < 0 && errno == EINTR); |
|
3673 |
__END_INTERRUPTABLE__ |
|
3674 |
if (ret < 0) { |
|
3675 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3676 |
RETURN ( false ); |
|
3677 |
} |
|
3678 |
RETURN ( true ); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3679 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3680 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3681 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3682 |
! ! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3683 |
|
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
3684 |
!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
|
3685 |
|
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3686 |
lockFD:aFileDescriptor shared:isSharedReadLock blocking:blockIfLocked |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3687 |
"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
|
3688 |
(such as returned by ExternalStream>>fileDescriptor). |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3689 |
On some systems, only advisory locks are available - |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3690 |
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
|
3691 |
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
|
3692 |
(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
|
3693 |
The isSharedReadLock argument (if true) specifies if multiple readers |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3694 |
are to be allowed - if false, they are not. |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3695 |
On some systems, all locks are non-exclusive locks. |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3696 |
|
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3697 |
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
|
3698 |
|
1616
fa734ea238f8
type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents:
1615
diff
changeset
|
3699 |
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
|
3700 |
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
|
3701 |
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
|
3702 |
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
|
3703 |
argument." |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3704 |
|
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3705 |
%{ |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3706 |
if (__isSmallInteger(aFileDescriptor)) { |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3707 |
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
|
3708 |
int lockArg; |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3709 |
|
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3710 |
/* |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3711 |
* claus: sigh - each one has a different interface ... |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3712 |
*/ |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3713 |
#if defined(F_SETLK) |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3714 |
{ |
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 |
* new fcntl(SETLK) interface; |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3717 |
* available on SYSV4 and Linux |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3718 |
*/ |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3719 |
struct flock flock; |
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 |
if (isSharedReadLock == true) { |
1632 | 3722 |
flock.l_type = F_RDLCK; |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3723 |
} else { |
1632 | 3724 |
flock.l_type = F_WRLCK; |
1617
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 |
flock.l_whence = 0; |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3727 |
flock.l_start = 0; |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3728 |
flock.l_len = 0; |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3729 |
lockArg = F_SETLK; |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3730 |
# if defined(F_SETLKW) |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3731 |
if (blockIfLocked == true) { |
1632 | 3732 |
lockArg = F_SETLKW; |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3733 |
} |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3734 |
# endif |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3735 |
if (fcntl(fd, lockArg, &flock) != -1) { |
1632 | 3736 |
RETURN (true); |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3737 |
} |
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 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3740 |
#else /* no F_SETLK available */ |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3741 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3742 |
# if defined(LOCK_EX) && defined(LOCK_UN) |
1632 | 3743 |
/* |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3744 |
* BSD 4.3 advisory locks |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3745 |
*/ |
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3746 |
lockArg = LOCK_EX; |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3747 |
# if defined(LOCK_SH) |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3748 |
if (isSharedReadLock == true) { |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3749 |
lockArg = LOCK_SH |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3750 |
} |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3751 |
# endif |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3752 |
# 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
|
3753 |
if (blockIfLocked == false) { |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3754 |
lockArg |= LOCK_NB; |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3755 |
} |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3756 |
# endif |
1632 | 3757 |
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
|
3758 |
RETURN (true); |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3759 |
} |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3760 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3761 |
# else /* no flock available */ |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3762 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3763 |
# if defined(F_LOCK) && defined(F_UNLOCK) |
1632 | 3764 |
/* |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3765 |
* SYSV3 advisory locks |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3766 |
*/ |
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3767 |
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
|
3768 |
RETURN (true); |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3769 |
} |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3770 |
# endif |
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3771 |
# endif |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3772 |
#endif |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3773 |
} |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3774 |
%}. |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3775 |
^ false |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3776 |
! |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3777 |
|
1616
fa734ea238f8
type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents:
1615
diff
changeset
|
3778 |
supportsFileLocks |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3779 |
"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
|
3780 |
|
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3781 |
%{ /* NOCONTEXT */ |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3782 |
#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
|
3783 |
RETURN (true); |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3784 |
#else |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3785 |
# 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
|
3786 |
RETURN (true); |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3787 |
# else |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3788 |
# if defined(F_LOCK) && defined(F_UNLOCK) |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3789 |
RETURN (true); |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3790 |
# endif |
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3791 |
# endif |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3792 |
#endif |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3793 |
%}. |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3794 |
^ false |
1616
fa734ea238f8
type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents:
1615
diff
changeset
|
3795 |
|
fa734ea238f8
type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents:
1615
diff
changeset
|
3796 |
" |
fa734ea238f8
type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents:
1615
diff
changeset
|
3797 |
OperatingSystem supportsFileLocks |
fa734ea238f8
type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents:
1615
diff
changeset
|
3798 |
" |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3799 |
! |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3800 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3801 |
supportsNonBlockingFileLocks |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3802 |
"return true, if the OS supports nonBlocking file locking |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3803 |
(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
|
3804 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3805 |
%{ /* NOCONTEXT */ |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3806 |
#if defined(F_SETLK) && defined(F_SETLKW) |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3807 |
RETURN (true); |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3808 |
#else |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3809 |
# 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
|
3810 |
RETURN (true); |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3811 |
# endif |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3812 |
#endif |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3813 |
%}. |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3814 |
^ false |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3815 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3816 |
" |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3817 |
OperatingSystem supportsNonBlockingFileLocks |
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 |
! |
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 |
supportsSharedLocks |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3822 |
"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
|
3823 |
file locking." |
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 |
%{ /* NOCONTEXT */ |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3826 |
#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
|
3827 |
RETURN (true); |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3828 |
#else |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3829 |
# 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
|
3830 |
RETURN (true); |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3831 |
# endif |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3832 |
#endif |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3833 |
%}. |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3834 |
^ false |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3835 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3836 |
" |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3837 |
OperatingSystem supportsNonBlockingFileLocks |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3838 |
" |
1621 | 3839 |
! |
3840 |
||
3841 |
unlockFD:aFileDescriptor |
|
3842 |
"clear a file lock on the file represented by aFileDescriptor, |
|
3843 |
which was previously aquired by #lockFD:. |
|
3844 |
Return false, if the unlock failed |
|
3845 |
(which may happens when a wrong fd is passed, |
|
3846 |
no lock was set previously, or the systsem does not support locks). |
|
3847 |
Notice, that not all OS's support file locks; |
|
3848 |
on some, this may simply be a no-op." |
|
3849 |
||
3850 |
%{ |
|
3851 |
if (__isSmallInteger(aFileDescriptor)) { |
|
1632 | 3852 |
int fd = __intVal(aFileDescriptor); |
3853 |
||
3854 |
/* |
|
3855 |
* claus: sigh - each one has a different interface ... |
|
3856 |
*/ |
|
1621 | 3857 |
#if defined(F_SETLK) |
3858 |
{ |
|
1632 | 3859 |
/* |
3860 |
* new fcntl(SETLK) interface; |
|
3861 |
* available on SYSV4 and Linux |
|
3862 |
*/ |
|
3863 |
struct flock flock; |
|
3864 |
||
3865 |
flock.l_type = F_UNLCK; |
|
3866 |
flock.l_whence = 0; |
|
3867 |
flock.l_start = 0; |
|
3868 |
flock.l_len = 0; |
|
3869 |
if (fcntl(fd, F_SETLK, &flock) != -1) { |
|
3870 |
RETURN (true); |
|
3871 |
} |
|
1621 | 3872 |
} |
3873 |
||
3874 |
#else /* no F_SETLK available */ |
|
3875 |
||
3876 |
# if defined(LOCK_EX) && defined(LOCK_UN) |
|
1632 | 3877 |
/* |
1621 | 3878 |
* BSD 4.3 advisory locks |
3879 |
*/ |
|
1632 | 3880 |
if (flock(fd, LOCK_UN) != -1) { |
3881 |
RETURN (true); |
|
3882 |
} |
|
1621 | 3883 |
|
3884 |
# else /* no flock available */ |
|
3885 |
||
3886 |
# if defined(F_LOCK) && defined(F_UNLOCK) |
|
3887 |
/* |
|
3888 |
* SYSV3 advisory locks |
|
3889 |
*/ |
|
3890 |
if (lockf(fd, F_UNLOCK, 0) != -1) { |
|
3891 |
RETURN (true); |
|
3892 |
} |
|
3893 |
# endif |
|
3894 |
# endif |
|
3895 |
#endif |
|
3896 |
} |
|
3897 |
%}. |
|
3898 |
^ false |
|
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3899 |
! ! |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3900 |
|
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
3901 |
!OperatingSystem class methodsFor:'file queries'! |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3902 |
|
616 | 3903 |
baseNameOf:aPathString |
3904 |
"return the baseName of the argument, aPathString |
|
3905 |
- thats the file/directory name without leading parent-dirs |
|
3906 |
(i.e. OperatingSystem baseNameOf:'/usr/lib/st/file' -> 'file' |
|
3907 |
and OperatingSystem baseNameOf:'/usr/lib' -> lib). |
|
3908 |
This method does not check if the path is valid |
|
3909 |
(i.e. if these directories really exist & is readable)." |
|
3910 |
||
3911 |
|prev index sep| |
|
3912 |
||
3913 |
sep := self fileSeparator. |
|
3914 |
((aPathString size == 1) and:[(aPathString at:1) == sep]) ifTrue:[ |
|
3915 |
^ aPathString |
|
3916 |
]. |
|
3917 |
prev := 1. |
|
3918 |
[true] whileTrue:[ |
|
3919 |
index := aPathString indexOf:sep startingAt:prev. |
|
3920 |
index == 0 ifTrue:[ |
|
3921 |
^ aPathString copyFrom:prev |
|
3922 |
]. |
|
3923 |
prev := index + 1 |
|
3924 |
] |
|
3925 |
||
3926 |
" |
|
3927 |
OperatingSystem baseNameOf:'/fee/foo/bar' |
|
3928 |
OperatingSystem baseNameOf:'foo/bar' |
|
3929 |
OperatingSystem baseNameOf:'../../foo/bar' |
|
3930 |
OperatingSystem baseNameOf:'hello' |
|
3931 |
" |
|
3932 |
! |
|
3933 |
||
3934 |
caseSensitiveFilenames |
|
3935 |
"return true, if the OS has caseSensitive file naming. |
|
3936 |
On MSDOS, this will return false. Since this is for Unix, we |
|
3937 |
return true." |
|
3938 |
||
3939 |
^ true |
|
3940 |
! |
|
3941 |
||
3942 |
compressPath:pathName |
|
3943 |
"return the pathName compressed - that is, remove all ..-entries |
|
3944 |
and . entries. This does not always (in case of symbolic links) |
|
3945 |
return the true pathName and is therefore used as a fallback |
|
3946 |
if realPath and popen failed." |
|
3947 |
||
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
3948 |
|names n "{ Class: SmallInteger }" | |
616 | 3949 |
|
3950 |
names := pathName |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3951 |
asCollectionOfSubstringsSeparatedBy:self fileSeparator. |
616 | 3952 |
names := names asOrderedCollection. |
3953 |
" |
|
3954 |
cut off initial double-slashes |
|
3955 |
" |
|
3956 |
[names startsWith:#('' '')] whileTrue:[ |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3957 |
names removeFirst. |
616 | 3958 |
]. |
3959 |
" |
|
3960 |
cut off double-slashes at end |
|
3961 |
" |
|
3962 |
[names endsWith:#('')] whileTrue:[ |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3963 |
names removeLast. |
616 | 3964 |
]. |
3965 |
" |
|
3966 |
cut off current-dir at beginning |
|
3967 |
" |
|
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
3968 |
n := names size. |
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
3969 |
[(n >= 2) and:[names startsWith:#('.')]] whileTrue:[ |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3970 |
names removeFirst. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3971 |
n := n - 1. |
616 | 3972 |
]. |
3973 |
||
3974 |
" |
|
3975 |
cut off parent-dirs at end |
|
3976 |
" |
|
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
3977 |
[(n > 2) |
616 | 3978 |
and:[(names endsWith:#('..')) |
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
3979 |
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
|
3980 |
names removeLast; removeLast. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3981 |
n := n - 2. |
616 | 3982 |
]. |
3983 |
||
3984 |
^ names asStringWith:self fileSeparator |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3985 |
from:1 |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3986 |
to:n |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3987 |
compressTabs:false final:nil |
616 | 3988 |
|
3989 |
" |
|
3990 |
OperatingSystem compressPath:'./..' |
|
3991 |
OperatingSystem compressPath:'/foo/bar/baz/..' |
|
3992 |
OperatingSystem compressPath:'foo/bar/baz/..' |
|
3993 |
OperatingSystem compressPath:'foo/bar/baz/../' |
|
3994 |
OperatingSystem compressPath:'foo/bar/baz/..///' |
|
3995 |
OperatingSystem compressPath:'///foo/bar/baz/..///' |
|
3996 |
" |
|
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
3997 |
|
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
3998 |
"Modified: 1.11.1996 / 20:13:48 / cg" |
68 | 3999 |
! |
4000 |
||
616 | 4001 |
directoryNameOf:aPathString |
4002 |
"return the directoryName of the argument, aPath |
|
4003 |
- thats the name of the directory where aPath is |
|
4004 |
(i.e. OperatingSystem directoryNameOf:'/usr/lib/st/file' -> '/usr/lib/st' |
|
4005 |
and OperatingSystem directoryNameOf:'/usr/lib' -> /usr'). |
|
4006 |
This method does not check if the path is valid |
|
4007 |
(i.e. if these directories really exist & are readable)." |
|
4008 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4009 |
|last index sep sepString p| |
616 | 4010 |
|
4011 |
sep := self fileSeparator. |
|
4012 |
sepString := sep asString. |
|
4013 |
(aPathString = sepString) ifTrue:[ |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4014 |
" |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4015 |
the trivial '/' case |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4016 |
" |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4017 |
^ aPathString |
616 | 4018 |
]. |
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4019 |
|
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4020 |
p := aPathString. |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4021 |
[p endsWith:sepString] whileTrue:[ |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4022 |
(p = sepString) ifTrue:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4023 |
^ p |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4024 |
]. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4025 |
p := p copyWithoutLast:1 |
616 | 4026 |
]. |
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4027 |
|
616 | 4028 |
last := 1. |
4029 |
[true] whileTrue:[ |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4030 |
index := p indexOf:sep startingAt:(last + 1). |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4031 |
index == 0 ifTrue:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4032 |
(last == 1) ifTrue:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4033 |
(p startsWith:sepString) ifTrue:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4034 |
^ sepString |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4035 |
]. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4036 |
^ '.' |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4037 |
]. |
616 | 4038 |
" |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4039 |
(p startsWith:sepString) ifFalse:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4040 |
(p startsWith:('..' , sepString)) ifFalse:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4041 |
^ './' , (p copyTo:(last - 1)) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4042 |
] |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4043 |
]. |
616 | 4044 |
" |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4045 |
^ p copyTo:(last - 1) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4046 |
]. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4047 |
last := index. |
616 | 4048 |
] |
4049 |
||
4050 |
" |
|
4051 |
OperatingSystem directoryNameOf:'/fee/foo/bar' |
|
4052 |
OperatingSystem directoryNameOf:'foo/bar' |
|
4053 |
OperatingSystem directoryNameOf:'../../foo/bar' |
|
4054 |
OperatingSystem directoryNameOf:'bar' |
|
4055 |
OperatingSystem directoryNameOf:'/bar' |
|
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4056 |
OperatingSystem directoryNameOf:'/tmp' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4057 |
OperatingSystem directoryNameOf:'/tmp///' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4058 |
OperatingSystem directoryNameOf:'/bar///' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4059 |
OperatingSystem directoryNameOf:'/bar/' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4060 |
OperatingSystem directoryNameOf:'./bar' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4061 |
OperatingSystem directoryNameOf:'/./bar' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4062 |
" |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4063 |
|
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4064 |
"Modified: 22.10.1996 / 18:53:47 / cg" |
616 | 4065 |
! |
4066 |
||
4067 |
fileSeparator |
|
4068 |
"return the character used to separate names in a path. |
|
4069 |
This character differs for MSDOS and other systems, |
|
4070 |
(but those are currently not supported - so this is some |
|
4071 |
preparation for the future)" |
|
4072 |
||
4073 |
^ $/ |
|
4074 |
! |
|
4075 |
||
4076 |
idOf:aPathName |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4077 |
"return the fileNumber (i.e. inode number) of a file. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4078 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4079 |
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
|
4080 |
some dummy id will be returned. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4081 |
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
|
4082 |
physically identical, even if found in different directories |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4083 |
(i.e. if they are hardLinked)." |
616 | 4084 |
|
4085 |
" |
|
4086 |
this could have been implemented as: |
|
1487 | 4087 |
(self infoOf:aPathName) at:#id |
616 | 4088 |
but for huge directory searches the code below is faster |
4089 |
" |
|
68 | 4090 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4091 |
%{ |
616 | 4092 |
struct stat buf; |
4093 |
int ret; |
|
4094 |
||
4095 |
if (__isString(aPathName)) { |
|
1487 | 4096 |
__BEGIN_INTERRUPTABLE__ |
4097 |
do { |
|
4098 |
ret = stat((char *) __stringVal(aPathName), &buf); |
|
4099 |
} while (ret < 0 && errno == EINTR); |
|
4100 |
__END_INTERRUPTABLE__ |
|
4101 |
if (ret >= 0) { |
|
4102 |
RETURN (__MKSMALLINT(buf.st_ino)); |
|
4103 |
} |
|
4104 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
4105 |
RETURN (nil); |
|
616 | 4106 |
} |
68 | 4107 |
%} |
616 | 4108 |
. |
792 | 4109 |
^ self primitiveFailed |
616 | 4110 |
|
4111 |
"OperatingSystem idOf:'/'" |
|
68 | 4112 |
! |
4113 |
||
616 | 4114 |
infoOf:aPathName |
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4115 |
"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
|
4116 |
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
|
4117 |
the returned object) is: |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4118 |
type - a symbol giving the files fileType |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4119 |
mode - numeric access mode |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4120 |
uid - owners user id |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4121 |
gid - owners group id |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4122 |
size - files size |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4123 |
id - files number (i.e. inode number) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4124 |
accessed - last access time (as osTime-stamp) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4125 |
modified - last modification time (as osTime-stamp) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4126 |
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
|
4127 |
|
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4128 |
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
|
4129 |
all of the information. |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4130 |
Return nil if such a file does not exist. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4131 |
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
|
4132 |
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
|
4133 |
" |
616 | 4134 |
|
4135 |
|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
|
4136 |
atime mtime ctime| |
616 | 4137 |
|
4138 |
%{ |
|
4139 |
struct stat buf; |
|
4140 |
int ret; |
|
4141 |
||
4142 |
if (__isString(aPathName)) { |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4143 |
__BEGIN_INTERRUPTABLE__ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4144 |
do { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4145 |
ret = stat((char *) __stringVal(aPathName), &buf); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4146 |
} while ((ret < 0) && (errno == EINTR)); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4147 |
__END_INTERRUPTABLE__ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4148 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4149 |
if (ret < 0) { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4150 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4151 |
RETURN ( nil ); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4152 |
} |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4153 |
switch (buf.st_mode & S_IFMT) { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4154 |
case S_IFDIR: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4155 |
type = @symbol(directory); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4156 |
break; |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4157 |
case S_IFREG: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4158 |
type = @symbol(regular); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4159 |
break; |
616 | 4160 |
#ifdef S_IFCHR |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4161 |
case S_IFCHR: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4162 |
type = @symbol(characterSpecial); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4163 |
break; |
616 | 4164 |
#endif |
4165 |
#ifdef S_IFBLK |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4166 |
case S_IFBLK: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4167 |
type = @symbol(blockSpecial); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4168 |
break; |
616 | 4169 |
#endif |
4170 |
#ifdef S_IFLNK |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4171 |
case S_IFLNK: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4172 |
type = @symbol(symbolicLink); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4173 |
break; |
616 | 4174 |
#endif |
4175 |
#ifdef S_IFSOCK |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4176 |
case S_IFSOCK: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4177 |
type = @symbol(socket); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4178 |
break; |
616 | 4179 |
#endif |
4180 |
#ifdef S_IFIFO |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4181 |
case S_IFIFO: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4182 |
type = @symbol(fifo); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4183 |
break; |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4184 |
#endif |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4185 |
default: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4186 |
type = @symbol(unknown); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4187 |
break; |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4188 |
} |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4189 |
mode = __MKSMALLINT(buf.st_mode & 0777); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4190 |
uid = __MKSMALLINT(buf.st_uid); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4191 |
gid = __MKSMALLINT(buf.st_gid); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4192 |
size = __MKSMALLINT(buf.st_size); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4193 |
id = __MKSMALLINT(buf.st_ino); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4194 |
atime = __MKUINT(buf.st_atime); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4195 |
mtime = __MKUINT(buf.st_mtime); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4196 |
ctime = __MKUINT(buf.st_ctime); |
616 | 4197 |
} |
4198 |
%}. |
|
4199 |
mode notNil ifTrue:[ |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4200 |
^ FileStatusInfo |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4201 |
type:type |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4202 |
mode:mode |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4203 |
uid:uid |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4204 |
gid:gid |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4205 |
size:size |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4206 |
id:id |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4207 |
accessed:(AbsoluteTime fromOSTime:(atime * 1000)) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4208 |
modified:(AbsoluteTime fromOSTime:(mtime * 1000)) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4209 |
statusChanged:(AbsoluteTime fromOSTime:(ctime * 1000)) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4210 |
path:nil |
616 | 4211 |
]. |
792 | 4212 |
^ self primitiveFailed |
616 | 4213 |
|
4214 |
" |
|
4215 |
OperatingSystem infoOf:'/' |
|
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4216 |
(OperatingSystem infoOf:'/') uid |
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4217 |
(OperatingSystem infoOf:'/') accessed |
616 | 4218 |
" |
68 | 4219 |
! |
4220 |
||
616 | 4221 |
isDirectory:aPathName |
4222 |
"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
|
4223 |
(i.e. exists and is a directory). |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4224 |
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
|
4225 |
if you need to check for this, use #linkInfo:." |
68 | 4226 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4227 |
%{ |
616 | 4228 |
struct stat buf; |
4229 |
int ret; |
|
4230 |
||
4231 |
if (__isString(aPathName)) { |
|
1487 | 4232 |
__BEGIN_INTERRUPTABLE__ |
4233 |
do { |
|
4234 |
ret = stat((char *) __stringVal(aPathName), &buf); |
|
4235 |
} while ((ret < 0) && (errno == EINTR)); |
|
4236 |
__END_INTERRUPTABLE__ |
|
4237 |
if (ret < 0) { |
|
4238 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
4239 |
RETURN ( false ); |
|
4240 |
} |
|
4241 |
RETURN ( ((buf.st_mode & S_IFMT) == S_IFDIR) ? true : false); |
|
616 | 4242 |
} |
4243 |
%}. |
|
792 | 4244 |
^ self primitiveFailed |
616 | 4245 |
|
4246 |
"an alternative implementation would be: |
|
1487 | 4247 |
^ (self infoOf:aPathName) at:#type == #directory |
616 | 4248 |
" |
68 | 4249 |
! |
4250 |
||
616 | 4251 |
isExecutable:aPathName |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4252 |
"return true, if the given file is executable. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4253 |
For symbolic links, the pointed-to-file is checked." |
68 | 4254 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4255 |
%{ |
616 | 4256 |
int ret; |
4257 |
||
4258 |
if (__isString(aPathName)) { |
|
1487 | 4259 |
__BEGIN_INTERRUPTABLE__ |
4260 |
do { |
|
4261 |
ret = access(__stringVal(aPathName), X_OK); |
|
4262 |
} while ((ret < 0) && (errno == EINTR)); |
|
4263 |
__END_INTERRUPTABLE__ |
|
4264 |
if (ret < 0) { |
|
4265 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
4266 |
} |
|
4267 |
RETURN ( ((ret == 0) ? true : false) ); |
|
616 | 4268 |
} |
4269 |
%}. |
|
792 | 4270 |
^ self primitiveFailed |
68 | 4271 |
! |
4272 |
||
616 | 4273 |
isReadable:aPathName |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4274 |
"return true, if the file/dir 'aPathName' is readable. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4275 |
For symbolic links, the pointed-to-file is checked." |
68 | 4276 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4277 |
%{ |
616 | 4278 |
int ret; |
4279 |
||
4280 |
if (__isString(aPathName)) { |
|
1487 | 4281 |
__BEGIN_INTERRUPTABLE__ |
4282 |
do { |
|
4283 |
ret = access(__stringVal(aPathName), R_OK); |
|
4284 |
} while ((ret < 0) && (errno == EINTR)); |
|
4285 |
__END_INTERRUPTABLE__ |
|
4286 |
if (ret < 0) { |
|
4287 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
4288 |
} |
|
4289 |
RETURN ( ((ret == 0) ? true : false) ); |
|
616 | 4290 |
} |
4291 |
%}. |
|
792 | 4292 |
^ self primitiveFailed |
68 | 4293 |
! |
4294 |
||
616 | 4295 |
isSymbolicLink:aPathName |
4296 |
"return true, if the given file is a symbolic link" |
|
4297 |
||
4298 |
^ (self linkInfoOf:aPathName) notNil |
|
4299 |
||
4300 |
" |
|
4301 |
OperatingSystem isSymbolicLink:'Make.proto' |
|
4302 |
OperatingSystem isSymbolicLink:'Makefile' |
|
4303 |
" |
|
4304 |
! |
|
4305 |
||
4306 |
isValidPath:aPathName |
|
4307 |
"return true, if 'aPathName' is a valid path name |
|
4308 |
(i.e. the file or directory exists)" |
|
68 | 4309 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4310 |
%{ |
616 | 4311 |
struct stat buf; |
4312 |
int ret; |
|
4313 |
||
4314 |
if (__isString(aPathName) || __isSymbol(aPathName) ) { |
|
4315 |
__BEGIN_INTERRUPTABLE__ |
|
4316 |
do { |
|
1135 | 4317 |
ret = stat((char *) __stringVal(aPathName), &buf); |
616 | 4318 |
} while ((ret < 0) && (errno == EINTR)); |
4319 |
__END_INTERRUPTABLE__ |
|
4320 |
if (ret < 0) { |
|
1135 | 4321 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 4322 |
RETURN (false); |
4323 |
} |
|
4324 |
RETURN ( ret ? false : true ); |
|
4325 |
} |
|
792 | 4326 |
%}. |
4327 |
^ self primitiveFailed |
|
68 | 4328 |
! |
4329 |
||
616 | 4330 |
isWritable:aPathName |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4331 |
"return true, if the given file is writable. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4332 |
For symbolic links, the pointed-to-file is checked." |
68 | 4333 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4334 |
%{ |
616 | 4335 |
int ret; |
4336 |
||
4337 |
if (__isString(aPathName)) { |
|
1487 | 4338 |
__BEGIN_INTERRUPTABLE__ |
4339 |
do { |
|
4340 |
ret = access(__stringVal(aPathName), W_OK); |
|
4341 |
} while ((ret < 0) && (errno == EINTR)); |
|
4342 |
__END_INTERRUPTABLE__ |
|
4343 |
if (ret < 0) { |
|
4344 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
4345 |
} |
|
4346 |
RETURN ( ((ret == 0) ? true : false) ); |
|
616 | 4347 |
} |
4348 |
%}. |
|
792 | 4349 |
^ self primitiveFailed |
68 | 4350 |
! |
4351 |
||
616 | 4352 |
linkInfoOf:aPathName |
4353 |
"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
|
4354 |
IFF aPathName is a symbolic link. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4355 |
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
|
4356 |
|
616 | 4357 |
The contents of the dictionary gives info about the link itself, |
4358 |
on contrast to #infoOf:, which returns the info of the pointed to file |
|
4359 |
in case of a symbolic link." |
|
4360 |
||
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4361 |
|info type mode uid gid size id atime mtime ctime path| |
616 | 4362 |
|
4363 |
%{ /* STACK: 1200 */ |
|
792 | 4364 |
#ifdef S_IFLNK |
616 | 4365 |
struct stat buf; |
4366 |
int ret; |
|
4367 |
char pathBuffer[1024]; |
|
4368 |
||
4369 |
if (__isString(aPathName)) { |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4370 |
__BEGIN_INTERRUPTABLE__ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4371 |
do { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4372 |
ret = lstat((char *) __stringVal(aPathName), &buf); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4373 |
} while ((ret < 0) && (errno == EINTR)); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4374 |
__END_INTERRUPTABLE__ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4375 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4376 |
if (ret < 0) { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4377 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4378 |
RETURN ( nil ); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4379 |
} |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4380 |
switch (buf.st_mode & S_IFMT) { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4381 |
default: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4382 |
RETURN ( nil ); /* not a symbolic link */ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4383 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4384 |
case S_IFLNK: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4385 |
type = @symbol(symbolicLink); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4386 |
break; |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4387 |
} |
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 |
mode = __MKSMALLINT(buf.st_mode & 0777); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4390 |
uid = __MKSMALLINT(buf.st_uid); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4391 |
gid = __MKSMALLINT(buf.st_gid); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4392 |
size = __MKSMALLINT(buf.st_size); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4393 |
id = __MKSMALLINT(buf.st_ino); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4394 |
atime = __MKUINT(buf.st_atime); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4395 |
mtime = __MKUINT(buf.st_mtime); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4396 |
ctime = __MKUINT(buf.st_ctime); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4397 |
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
|
4398 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4399 |
RETURN ( nil ); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4400 |
} |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4401 |
pathBuffer[ret] = '\0'; /* readlink does not 0-terminate */ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4402 |
path = __MKSTRING(pathBuffer); |
616 | 4403 |
} |
792 | 4404 |
#else |
4405 |
RETURN ( nil ); |
|
4406 |
#endif |
|
616 | 4407 |
%}. |
4408 |
mode notNil ifTrue:[ |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4409 |
info := IdentityDictionary new. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4410 |
^ FileStatusInfo |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4411 |
type:type |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4412 |
mode:mode |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4413 |
uid:uid |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4414 |
gid:gid |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4415 |
size:size |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4416 |
id:id |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4417 |
accessed:(AbsoluteTime fromOSTime:(atime * 1000)) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4418 |
modified:(AbsoluteTime fromOSTime:(mtime * 1000)) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4419 |
statusChanged:(AbsoluteTime fromOSTime:(ctime * 1000)) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4420 |
path:path |
616 | 4421 |
]. |
792 | 4422 |
^ self primitiveFailed |
616 | 4423 |
|
4424 |
" |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4425 |
OperatingSystem infoOf:'Make.proto' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4426 |
OperatingSystem linkInfoOf:'Make.proto' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4427 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4428 |
OperatingSystem infoOf:'resources/motif.style' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4429 |
OperatingSystem linkInfoOf:'resources/motif.style' |
616 | 4430 |
" |
4431 |
! |
|
4432 |
||
4433 |
parentDirectoryName |
|
4434 |
"return the name used to refer to parent directories. |
|
4435 |
In MSDOS, Unix and other systems this is '..', but maybe different |
|
4436 |
for other systems. |
|
4437 |
(but those are currently not supported - so this is some |
|
4438 |
preparation for the future)" |
|
4439 |
||
4440 |
^ '..' |
|
68 | 4441 |
! |
4442 |
||
616 | 4443 |
pathNameOf:pathName |
4444 |
"return the pathName of the argument, aPathString, |
|
4445 |
- thats the full pathname of the directory, starting at '/'. |
|
4446 |
This method needs the path to be valid |
|
4447 |
(i.e. all directories must exist, be readable and executable). |
|
4448 |
Notice: if symbolic links are involved, the result may look different |
|
4449 |
from what you expect." |
|
4450 |
||
4451 |
|p path command| |
|
4452 |
||
4453 |
"some systems have a convenient function for this ..." |
|
4454 |
path := self primPathNameOf:pathName. |
|
4455 |
||
4456 |
path isNil ifTrue:[ |
|
2080
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4457 |
(self isValidPath:pathName) ifFalse:[ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4458 |
p := pathName. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4459 |
[(p size > 1) |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4460 |
and:[p endsWith:(self fileSeparator)] |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4461 |
] whileTrue:[ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4462 |
p := p copyWithoutLast:1. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4463 |
]. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4464 |
^ p |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4465 |
]. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4466 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4467 |
(SlowFork==true or:[ForkFailed==true]) ifFalse:[ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4468 |
PipeStream openErrorSignal handle:[:ex | |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4469 |
ForkFailed := true. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4470 |
'OS: cannot fork/popen' errorPrintNL. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4471 |
ex return. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4472 |
] do:[ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4473 |
"have to fall back ..." |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4474 |
command := 'cd ' , pathName , '; pwd'. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4475 |
p := PipeStream readingFrom:command. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4476 |
]. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4477 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4478 |
(p isNil or:[p atEnd]) ifTrue:[ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4479 |
('OS: PipeStream for <' , command , '> failed') errorPrintNL. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4480 |
] ifFalse:[ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4481 |
path := p nextLine. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4482 |
p close. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4483 |
]. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4484 |
]. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4485 |
path isNil ifTrue:[ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4486 |
path := pathName |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4487 |
]. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4488 |
(SlowFork==true or:[ForkFailed==true]) ifTrue:[ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4489 |
path := self compressPath:path |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4490 |
] |
616 | 4491 |
]. |
4492 |
^ path. |
|
4493 |
||
4494 |
" |
|
4495 |
OperatingSystem pathNameOf:'.' |
|
4496 |
OperatingSystem pathNameOf:'../smalltalk/../smalltalk' |
|
4497 |
OperatingSystem pathNameOf:'../../..' |
|
4498 |
OperatingSystem pathNameOf:'..' |
|
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4499 |
OperatingSystem pathNameOf:'/tmp////' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4500 |
OperatingSystem pathNameOf:'/foo/bar' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4501 |
OperatingSystem pathNameOf:'/foo/bar/' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4502 |
OperatingSystem pathNameOf:'/foo/bar//' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4503 |
" |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4504 |
|
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4505 |
"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
|
4506 |
"Modified: 29.11.1996 / 18:02:12 / stefan" |
359 | 4507 |
! |
4508 |
||
616 | 4509 |
primPathNameOf:pathName |
4510 |
"return the pathName of the argument, aPathString, |
|
4511 |
- thats the full pathname of the directory, starting at '/'. |
|
4512 |
This method here returns nil, if the OS does not provide a |
|
4513 |
realPath library function. |
|
4514 |
Notice: if symbolic links are involved, the result may look different |
|
4515 |
from what you expect." |
|
4516 |
||
4517 |
|path| |
|
4518 |
||
4519 |
"some systems have a convenient function for this ..." |
|
4520 |
%{ /* STACK: 16000 */ |
|
4521 |
#ifdef HAS_REALPATH |
|
4522 |
char nameBuffer[MAXPATHLEN + 1]; |
|
4523 |
||
4524 |
if (__isString(pathName)) { |
|
1135 | 4525 |
if (realpath(__stringVal(pathName), nameBuffer)) { |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
4526 |
RETURN ( __MKSTRING(nameBuffer) ); |
616 | 4527 |
} |
4528 |
} |
|
1632 | 4529 |
#else |
4530 |
# ifdef WIN32 |
|
4531 |
char nameBuffer[MAXPATHLEN + 1]; |
|
4532 |
char *pFinal; |
|
4533 |
||
4534 |
if (__isString(pathName)) { |
|
4535 |
if (GetFullPathName(__stringVal(pathName), sizeof(nameBuffer), |
|
4536 |
nameBuffer, &pFinal)) { |
|
4537 |
RETURN ( __MKSTRING(nameBuffer) ); |
|
4538 |
} |
|
4539 |
} |
|
4540 |
# endif |
|
616 | 4541 |
#endif |
4542 |
%}. |
|
4543 |
^ nil |
|
359 | 4544 |
! |
4545 |
||
616 | 4546 |
timeOfLastAccess:aPathName |
4547 |
"return the time, when the file was last accessed. |
|
4548 |
For nonexistent files, nil is returned." |
|
4549 |
||
4550 |
"could be implemented as: |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4551 |
(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
|
4552 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4553 |
|osSeconds| |
616 | 4554 |
%{ |
4555 |
struct stat buf; |
|
4556 |
time_t mtime; |
|
4557 |
int ret; |
|
4558 |
||
4559 |
if (__isString(aPathName)) { |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4560 |
__BEGIN_INTERRUPTABLE__ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4561 |
do { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4562 |
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
|
4563 |
} while (ret < 0 && errno == EINTR); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4564 |
__END_INTERRUPTABLE__ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4565 |
if (ret < 0) { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4566 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4567 |
RETURN (nil); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4568 |
} |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4569 |
osSeconds = __MKUINT(buf.st_atime); |
616 | 4570 |
} |
792 | 4571 |
%}. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4572 |
osSeconds notNil ifTrue:[^ AbsoluteTime fromOSTime:(osSeconds * 1000)]. |
792 | 4573 |
^ self primitiveFailed |
616 | 4574 |
|
4575 |
" |
|
4576 |
OperatingSystem timeOfLastAccess:'/' |
|
4577 |
" |
|
359 | 4578 |
! |
4579 |
||
616 | 4580 |
timeOfLastChange:aPathName |
4581 |
"return the time, when the file was last changed. |
|
4582 |
For nonexistent files, nil is returned." |
|
4583 |
||
4584 |
"could be implemented as: |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4585 |
(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
|
4586 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4587 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4588 |
|osSeconds| |
616 | 4589 |
%{ |
4590 |
struct stat buf; |
|
4591 |
int ret; |
|
4592 |
time_t mtime; |
|
4593 |
||
4594 |
if (__isString(aPathName)) { |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4595 |
__BEGIN_INTERRUPTABLE__ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4596 |
do { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4597 |
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
|
4598 |
} while (ret < 0 && errno == EINTR); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4599 |
__END_INTERRUPTABLE__ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4600 |
if (ret < 0) { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4601 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4602 |
RETURN ( nil ); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4603 |
} |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4604 |
osSeconds = __MKUINT(buf.st_mtime); |
616 | 4605 |
} |
792 | 4606 |
%}. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4607 |
osSeconds notNil ifTrue:[^ AbsoluteTime fromOSTime:(osSeconds * 1000)]. |
792 | 4608 |
^ self primitiveFailed |
616 | 4609 |
|
4610 |
" |
|
4611 |
OperatingSystem timeOfLastChange:'/' |
|
4612 |
" |
|
4613 |
! |
|
4614 |
||
4615 |
typeOf:aPathName |
|
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4616 |
"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
|
4617 |
nil is returned. |
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4618 |
Notice: for symbolic links, the type of the pointed-to file is returned." |
616 | 4619 |
|
4620 |
" |
|
4621 |
this could have been implemented as: |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4622 |
(self infoOf:aPathName) at:#type |
616 | 4623 |
but for huge directory searches the code below is faster |
4624 |
" |
|
359 | 4625 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4626 |
%{ |
616 | 4627 |
struct stat buf; |
4628 |
int ret; |
|
4629 |
||
4630 |
if (__isString(aPathName)) { |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4631 |
__BEGIN_INTERRUPTABLE__ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4632 |
do { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4633 |
ret = stat((char *) __stringVal(aPathName), &buf); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4634 |
} while (ret < 0 && errno == EINTR); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4635 |
__END_INTERRUPTABLE__ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4636 |
if (ret < 0) { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4637 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4638 |
RETURN ( nil ); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4639 |
} |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4640 |
switch (buf.st_mode & S_IFMT) { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4641 |
case S_IFDIR: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4642 |
RETURN ( @symbol(directory) ); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4643 |
case S_IFREG: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4644 |
RETURN ( @symbol(regular) ); |
616 | 4645 |
#ifdef S_IFCHR |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4646 |
case S_IFCHR: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4647 |
RETURN ( @symbol(characterSpecial) ); |
616 | 4648 |
#endif |
4649 |
#ifdef S_IFBLK |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4650 |
case S_IFBLK: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4651 |
RETURN ( @symbol(blockSpecial) ); |
616 | 4652 |
#endif |
4653 |
#ifdef S_IFLNK |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4654 |
case S_IFLNK: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4655 |
RETURN ( @symbol(symbolicLink) ); |
616 | 4656 |
#endif |
4657 |
#ifdef S_IFSOCK |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4658 |
case S_IFSOCK: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4659 |
RETURN ( @symbol(socket) ); |
616 | 4660 |
#endif |
4661 |
#ifdef S_IFIFO |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4662 |
case S_IFIFO: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4663 |
RETURN ( @symbol(fifo) ); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4664 |
#endif |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4665 |
default: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4666 |
RETURN ( @symbol(unknown) ); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4667 |
} |
616 | 4668 |
} |
4669 |
%}. |
|
792 | 4670 |
^ self primitiveFailed |
616 | 4671 |
|
4672 |
" |
|
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4673 |
OperatingSystem typeOf:'/' |
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4674 |
OperatingSystem typeOf:'.' |
616 | 4675 |
OperatingSystem typeOf:'Make.proto' |
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4676 |
OperatingSystem typeOf:'resources/motif.style' |
616 | 4677 |
" |
68 | 4678 |
! ! |
4679 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4680 |
!OperatingSystem class methodsFor:'interrupts & signals'! |
63 | 4681 |
|
10 | 4682 |
blockInterrupts |
95 | 4683 |
"disable interrupt processing - if disabled, incoming |
4684 |
interrupts will be registered and handled as soon as |
|
4685 |
interrupts are reenabled by OperatingSystemclass>>unblockInterrupts. |
|
4686 |
Returns the previous blocking status i.e. true if interrupts |
|
4687 |
where already blocked. You need this information for proper |
|
4688 |
unblocking, in case of nested block/unblock calls." |
|
4689 |
||
4690 |
%{ /* NOCONTEXT */ |
|
710 | 4691 |
RETURN ( __BLOCKINTERRUPTS() ); |
10 | 4692 |
%} |
4693 |
! |
|
4694 |
||
616 | 4695 |
defaultSignal:signalNumber |
4696 |
"revert to the default action on arrival of a (Unix-)signal. |
|
4697 |
Dont confuse Unix signals with smalltalk signals. |
|
4698 |
WARNING: for some signals, it is no good idea to revert to default; |
|
4699 |
for example, the default for SIGINT (i.e. ^C) is to exit; while the |
|
4700 |
default for SIGQUIT (^ \) is to dump core. |
|
4701 |
Also, NOTICE that signal numbers are not portable between unix |
|
4702 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
4703 |
a signal." |
|
4704 |
||
4705 |
%{ /* NOCONTEXT */ |
|
4706 |
||
4707 |
if (__isSmallInteger(signalNumber)) { |
|
831 | 4708 |
#ifdef SIG_DFL |
1135 | 4709 |
signal(__intVal(signalNumber), SIG_DFL); |
616 | 4710 |
RETURN (self); |
831 | 4711 |
#endif |
616 | 4712 |
} |
4713 |
%}. |
|
4714 |
" |
|
4715 |
this error is triggered on non-integer argument |
|
4716 |
" |
|
792 | 4717 |
^ self primitiveFailed |
616 | 4718 |
|
4719 |
"you better save a snapshot image before trying this ..." |
|
4720 |
" |
|
4721 |
'if you hit ^C now, Smalltalk will exit immediately' printNewline. |
|
4722 |
OperatingSystem defaultSignal:(OperatingSystem sigINT). |
|
4723 |
1 to:1000000 do:[:i| ]. |
|
4724 |
OperatingSystem enableSignal:(OperatingSystem sigINT). |
|
4725 |
'normal ^C handling again.' printNewline |
|
4726 |
" |
|
4727 |
! |
|
4728 |
||
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4729 |
disableChildSignalInterrupts |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4730 |
"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
|
4731 |
(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
|
4732 |
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
|
4733 |
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
|
4734 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4735 |
^ 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
|
4736 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4737 |
"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
|
4738 |
! |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4739 |
|
616 | 4740 |
disableIOInterruptsOn:fd |
4741 |
"turn off IO interrupts for a filedescriptor" |
|
4742 |
||
4743 |
%{ /* NOCONTEXT */ |
|
4744 |
||
4745 |
int ret, flags, f; |
|
4746 |
||
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4747 |
#if (defined(F_GETFL) && defined(F_SETFL) && defined(FASYNC)) || defined(SYSV4) |
616 | 4748 |
if (__isSmallInteger(fd)) { |
1135 | 4749 |
f = __intVal(fd); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4750 |
# if defined(SYSV4) |
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
756
diff
changeset
|
4751 |
ret = ioctl(f, I_SETSIG, 0); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4752 |
# else /*! SYSV4*/ |
616 | 4753 |
flags = fcntl(f, F_GETFL, 0); |
4754 |
/* |
|
4755 |
* if already clear, there is no need for this syscall ... |
|
4756 |
*/ |
|
4757 |
if (flags & FASYNC) { |
|
4758 |
ret = fcntl(f, F_SETFL, flags & ~FASYNC); |
|
4759 |
if (ret >= 0) ret = flags; |
|
4760 |
} else { |
|
4761 |
ret = flags; |
|
4762 |
} |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4763 |
# endif /* !SYSV4 */ |
1135 | 4764 |
RETURN ( __MKSMALLINT(ret) ); |
616 | 4765 |
} |
4766 |
#endif |
|
4767 |
%}. |
|
4768 |
" |
|
4769 |
this error is triggered on non-integer argument |
|
4770 |
or if the OS does not support IO interrupts. |
|
4771 |
" |
|
792 | 4772 |
^ self primitiveFailed |
10 | 4773 |
! |
4774 |
||
63 | 4775 |
disableSignal:signalNumber |
95 | 4776 |
"disable (Unix-) signal processing for signalNumber. |
4777 |
Dont confuse Unix signals with smalltalk signals. |
|
63 | 4778 |
WARNING: for some signals, it is no good idea to disable |
95 | 4779 |
them; for example, disabling the SIGINT signal turns off ^C |
63 | 4780 |
handling. |
68 | 4781 |
Also, NOTICE that signal numbers are not portable between unix |
4782 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
4783 |
a signal. |
|
63 | 4784 |
Use only for fully debugged stand alone applications." |
4785 |
||
4786 |
%{ /* NOCONTEXT */ |
|
4787 |
||
252 | 4788 |
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
|
4789 |
int sigNo = __intVal(signalNumber); |
831 | 4790 |
|
4791 |
if (sigNo == 0) { |
|
4792 |
RETURN (self); |
|
4793 |
} |
|
4794 |
#ifdef SIG_IGN |
|
4795 |
signal(sigNo, SIG_IGN); |
|
185 | 4796 |
RETURN (self); |
831 | 4797 |
#endif |
63 | 4798 |
} |
68 | 4799 |
%}. |
4800 |
" |
|
4801 |
this error is triggered on non-integer argument |
|
4802 |
" |
|
792 | 4803 |
^ self primitiveFailed |
68 | 4804 |
|
4805 |
" |
|
4806 |
'now, ^C is totally ignored ...' printNewline. |
|
4807 |
OperatingSystem disableSignal:(OperatingSystem sigINT). |
|
4808 |
1 to:1000000 do:[:i| ]. |
|
4809 |
OperatingSystem enableSignal:(OperatingSystem sigINT). |
|
4810 |
'^C handled again.' printNewline |
|
4811 |
" |
|
4812 |
! |
|
4813 |
||
616 | 4814 |
disableTimer |
831 | 4815 |
"disable timer interrupts. |
4816 |
WARNING: |
|
4817 |
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
|
4818 |
disabled, because no scheduling or timeouts are possible." |
616 | 4819 |
|
4820 |
%{ /* NOCONTEXT */ |
|
4821 |
||
1632 | 4822 |
#if defined(WIN32) |
4823 |
KillTimer(NULL, w32TimerId); |
|
4824 |
w32TimerId = 0; |
|
4825 |
RETURN (true); |
|
4826 |
#else |
|
4827 |
# if defined(ITIMER_REAL) |
|
616 | 4828 |
struct itimerval dt; |
4829 |
||
4830 |
dt.it_interval.tv_sec = 0; |
|
4831 |
dt.it_interval.tv_usec = 0; |
|
4832 |
dt.it_value.tv_sec = 0; |
|
4833 |
dt.it_value.tv_usec = 0; |
|
4834 |
setitimer(ITIMER_REAL, &dt, 0); |
|
4835 |
RETURN (true); |
|
1632 | 4836 |
# endif /* ITIMER_REAL */ |
4837 |
#endif |
|
616 | 4838 |
%} |
4839 |
. |
|
4840 |
^ false |
|
4841 |
! |
|
4842 |
||
4843 |
disableUserInterrupts |
|
4844 |
"disable userInterrupt processing; |
|
4845 |
when disabled, no ^C processing takes place. |
|
831 | 4846 |
WARNING: |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4847 |
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
|
4848 |
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
|
4849 |
We recommend setting up a handler for the signal instead of disabling it." |
831 | 4850 |
|
4851 |
self disableSignal:(self sigBREAK). |
|
4852 |
self disableSignal:(self sigINT). |
|
616 | 4853 |
! |
4854 |
||
4855 |
enableAbortInterrupts |
|
4856 |
"enable abort signalhandling, and make it a regular signalInterrupt. |
|
4857 |
(the default will dump core and exit - which is not a good idea for |
|
4858 |
end-user applications ...). |
|
4859 |
This is especially useful, if linked-in C-libraries call abort() ..." |
|
4860 |
||
831 | 4861 |
self enableSignal:(self sigABRT) |
616 | 4862 |
! |
4863 |
||
4864 |
enableChildSignalInterrupts |
|
4865 |
"enable childSignal interrupts |
|
4866 |
(SIGCHLD, if the architecture supports it). |
|
831 | 4867 |
After enabling, these signals will send the message |
616 | 4868 |
'childSignalInterrupt' to the ChildSignalInterruptHandler object." |
4869 |
||
831 | 4870 |
self enableSignal:(self sigCHLD) |
616 | 4871 |
! |
4872 |
||
4873 |
enableFpExceptionInterrupts |
|
4874 |
"enable floating point exception interrupts (if the |
|
4875 |
architecture supports it). |
|
831 | 4876 |
After enabling, fpu-exceptions will send the message |
616 | 4877 |
'fpuExceptionInterrupt' to the FPUExceptionInterruptHandler object." |
4878 |
||
831 | 4879 |
self enableSignal:(self sigFP) |
616 | 4880 |
! |
4881 |
||
4882 |
enableHardSignalInterrupts |
|
4883 |
"enable hard signal exception interrupts (trap, buserror & segm. violation). |
|
831 | 4884 |
After enabling, these exceptions will send the message |
616 | 4885 |
'signalInterrupt' to the SignalInterruptHandler object." |
68 | 4886 |
|
855
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
4887 |
"/ 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
|
4888 |
"/ 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
|
4889 |
|
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
4890 |
"/ ... 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
|
4891 |
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
|
4892 |
|
1808
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
4893 |
self enableSignal:(self sigILL). |
640
be94dfc60eaa
Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents:
630
diff
changeset
|
4894 |
self enableSignal:(self sigBUS). |
be94dfc60eaa
Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents:
630
diff
changeset
|
4895 |
self enableSignal:(self sigSEGV) |
616 | 4896 |
! |
4897 |
||
4898 |
enableIOInterruptsOn:fd |
|
4899 |
"turn on IO interrupts for a filedescriptor" |
|
4900 |
||
4901 |
%{ /* NOCONTEXT */ |
|
4902 |
||
4903 |
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
|
4904 |
#ifndef __signalIoInterrupt |
616 | 4905 |
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
|
4906 |
#endif |
616 | 4907 |
static int firstCall = 1; |
4908 |
||
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4909 |
#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
|
4910 |
/* |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4911 |
* SIGIO/SIGPOLL - data available for I/O |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4912 |
* (used to wake up waiting processes) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4913 |
*/ |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4914 |
#ifdef SIGIO |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4915 |
# define THESIGNAL SIGIO |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4916 |
#else |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4917 |
# ifdef SIGPOLL |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4918 |
# define THESIGNAL SIGPOLL |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4919 |
# else |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4920 |
# ifdef SIGURG |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4921 |
# define THESIGNAL SIGURG |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4922 |
# endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4923 |
# endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4924 |
#endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4925 |
|
616 | 4926 |
if (__isSmallInteger(fd)) { |
4927 |
if (firstCall) { |
|
762
cea705669628
ok, stefan was right: HAS_SIGACTION works
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
4928 |
#ifdef HAS_SIGACTION |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4929 |
struct sigaction act; |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4930 |
|
1487 | 4931 |
/* |
4932 |
* Do not add SA_RESTART here. A signal can cause a |
|
4933 |
* thread switch, another thread can do a garbage collect |
|
4934 |
* and restarted system calls may write into old |
|
4935 |
* (collected) addresses. |
|
4936 |
*/ |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4937 |
|
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4938 |
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
|
4939 |
sigemptyset(&act.sa_mask); |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4940 |
act.sa_handler = __signalIoInterrupt; |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4941 |
sigaction(THESIGNAL, &act, 0); |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4942 |
#else |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4943 |
# ifdef HAS_SIGVEC |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4944 |
struct sigvec vec; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4945 |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4946 |
vec.sv_flags = SV_INTERRUPT; |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4947 |
sigemptyset(&vec.sv_mask); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4948 |
vec.sv_handler = __signalIoInterrupt; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4949 |
sigvec(THESIGNAL, &vec, NULL); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4950 |
# else |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4951 |
signal(THESIGNAL, __signalIoInterrupt); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4952 |
# endif |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4953 |
#endif |
616 | 4954 |
firstCall = 0; |
4955 |
} |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4956 |
#undef THESIGNAL |
616 | 4957 |
|
1135 | 4958 |
f = __intVal(fd); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4959 |
# if defined(SYSV4) |
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
756
diff
changeset
|
4960 |
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
|
4961 |
# else /*! SYSV4*/ |
616 | 4962 |
flags = fcntl(f, F_GETFL, 0); |
4963 |
/* |
|
4964 |
* if already set, there is no need for this syscall ... |
|
4965 |
*/ |
|
4966 |
if (flags & FASYNC) { |
|
4967 |
ret = flags; |
|
4968 |
} else { |
|
4969 |
ret = fcntl(f, F_SETFL, flags | FASYNC); |
|
4970 |
if (ret >= 0) ret = flags; |
|
4971 |
} |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4972 |
# endif /*!SYSV4*/ |
1135 | 4973 |
RETURN ( __MKSMALLINT(ret) ); |
68 | 4974 |
} |
616 | 4975 |
#endif |
68 | 4976 |
%}. |
4977 |
" |
|
4978 |
this error is triggered on non-integer argument |
|
616 | 4979 |
or if the system does not support SIGIO |
68 | 4980 |
" |
792 | 4981 |
^ self primitiveFailed |
616 | 4982 |
! |
4983 |
||
4984 |
enableQuitInterrupts |
|
4985 |
"enable quitInterrupt (usually ^\) handling, and make it a userInterrupt. |
|
4986 |
(the default will dump core and exit - which is not a good idea for |
|
4987 |
end-user applications ...)" |
|
4988 |
||
831 | 4989 |
self enableSignal:(self sigQUIT) |
68 | 4990 |
! |
4991 |
||
4992 |
enableSignal:signalNumber |
|
95 | 4993 |
"enable (Unix-)signal processing for signalNumber. |
4994 |
Dont confuse Unix signals with smalltalk signals. |
|
68 | 4995 |
The signal will be delivered to one of the standard handlers |
4996 |
(SIGINT, SIGQUIT, etc) or to a general handler, which |
|
4997 |
sends #signalInterrupt:. |
|
4998 |
||
4999 |
NOTICE that signal numbers are not portable between unix |
|
5000 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
5001 |
a signal." |
|
5002 |
||
5003 |
%{ /* NOCONTEXT */ |
|
5004 |
||
5005 |
#ifdef NSIG |
|
5006 |
# define SIG_LIMIT NSIG |
|
5007 |
#else |
|
5008 |
# ifdef SIGUSR2 |
|
5009 |
# define SIG_LIMIT SIGUSR2 |
|
5010 |
# else |
|
5011 |
# ifdef SIGUSR |
|
5012 |
# define SIG_LIMIT SIGUSR |
|
5013 |
# endif |
|
5014 |
# endif |
|
5015 |
#endif |
|
5016 |
||
5017 |
#if defined(SIGPOLL) && !defined(SIGIO) |
|
5018 |
# define SIGIO SIGPOLL |
|
5019 |
#endif |
|
5020 |
||
5021 |
#ifdef SIGCHLD |
|
5022 |
# define CHILD_SIGNAL SIGCHLD |
|
5023 |
#else |
|
5024 |
# ifdef SIGCLD |
|
5025 |
# define CHILD_SIGNAL SIGCLD |
|
5026 |
# endif |
|
5027 |
#endif |
|
5028 |
||
5029 |
int sigNr; |
|
443 | 5030 |
#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
|
5031 |
# ifndef __signalUserInterrupt |
831 | 5032 |
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
|
5033 |
# endif |
443 | 5034 |
#endif |
5035 |
#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
|
5036 |
# ifndef __signalFpExceptionInterrupt |
831 | 5037 |
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
|
5038 |
# endif |
443 | 5039 |
#endif |
5040 |
#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
|
5041 |
# ifndef __signalIoInterrupt |
831 | 5042 |
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
|
5043 |
# endif |
443 | 5044 |
#endif |
68 | 5045 |
#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
|
5046 |
# ifndef __signalChildInterrupt |
831 | 5047 |
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
|
5048 |
# endif |
68 | 5049 |
#endif |
443 | 5050 |
#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
|
5051 |
# ifndef __signalPIPEInterrupt |
831 | 5052 |
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
|
5053 |
# endif |
443 | 5054 |
#endif |
5055 |
#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
|
5056 |
# ifndef __signalBUSInterrupt |
831 | 5057 |
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
|
5058 |
# endif |
443 | 5059 |
#endif |
5060 |
#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
|
5061 |
# ifndef __signalSEGVInterrupt |
831 | 5062 |
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
|
5063 |
# endif |
443 | 5064 |
#endif |
1808
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
5065 |
#ifdef SIGILL |
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
5066 |
# ifndef __signalTrapInterrupt |
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
5067 |
extern void __signalTrapInterrupt(SIGHANDLER_ARG); |
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
5068 |
# endif |
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
5069 |
#endif |
443 | 5070 |
#ifdef SIGALRM |
831 | 5071 |
# 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
|
5072 |
# ifndef __signalTimerInterrupt |
831 | 5073 |
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
|
5074 |
# endif |
831 | 5075 |
# endif |
5076 |
#endif |
|
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 __signalInterrupt |
831 | 5078 |
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
|
5079 |
#endif |
831 | 5080 |
void (*handler)(SIGHANDLER_ARG); |
68 | 5081 |
|
252 | 5082 |
if (__isSmallInteger(signalNumber) |
1135 | 5083 |
&& ((sigNr = __intVal(signalNumber)) >= 0) |
831 | 5084 |
#ifdef SIG_LIMIT |
5085 |
&& (sigNr <= SIG_LIMIT) |
|
5086 |
#endif |
|
5087 |
) { |
|
185 | 5088 |
/* |
5089 |
* standard signals are forced into standard handlers |
|
5090 |
* - all others go into general signalInterrupt |
|
5091 |
*/ |
|
68 | 5092 |
#if defined(SIGPOLL) && defined(SIGIO) |
185 | 5093 |
if (sigNr == SIGPOLL) |
5094 |
sigNr = SIGIO; |
|
68 | 5095 |
#endif |
185 | 5096 |
switch (sigNr) { |
831 | 5097 |
case 0: |
5098 |
/* enabling a non-supported signal */ |
|
5099 |
RETURN (self); |
|
5100 |
||
5101 |
#ifdef SIGBREAK |
|
5102 |
case SIGBREAK: |
|
5103 |
#endif |
|
443 | 5104 |
#ifdef SIGINT |
185 | 5105 |
case SIGINT: |
443 | 5106 |
#endif |
5107 |
#ifdef SIGQUIT |
|
185 | 5108 |
case SIGQUIT: |
443 | 5109 |
#endif |
831 | 5110 |
#if defined(SIGINT) || defined(SIGQUIT) || defined(SIGBREAK) |
329 | 5111 |
handler = __signalUserInterrupt; |
185 | 5112 |
break; |
443 | 5113 |
#endif |
5114 |
||
5115 |
#ifdef SIGFPE |
|
185 | 5116 |
case SIGFPE: |
329 | 5117 |
handler = __signalFpExceptionInterrupt; |
185 | 5118 |
break; |
443 | 5119 |
#endif |
5120 |
||
5121 |
#ifdef SIGPIPE |
|
185 | 5122 |
case SIGPIPE: |
329 | 5123 |
handler = __signalPIPEInterrupt; |
185 | 5124 |
break; |
443 | 5125 |
#endif |
68 | 5126 |
#ifdef SIGBUS |
185 | 5127 |
case SIGBUS: |
329 | 5128 |
handler = __signalBUSInterrupt; |
185 | 5129 |
break; |
68 | 5130 |
#endif |
443 | 5131 |
#ifdef SIGSEGV |
185 | 5132 |
case SIGSEGV: |
329 | 5133 |
handler = __signalSEGVInterrupt; |
185 | 5134 |
break; |
443 | 5135 |
#endif |
1982
8d4f97279e55
oops - SIGILL was never cought
Claus Gittinger <cg@exept.de>
parents:
1966
diff
changeset
|
5136 |
#ifdef SIGILL |
8d4f97279e55
oops - SIGILL was never cought
Claus Gittinger <cg@exept.de>
parents:
1966
diff
changeset
|
5137 |
case SIGILL: |
1808
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
5138 |
handler = __signalTrapInterrupt; |
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
5139 |
break; |
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
5140 |
#endif |
68 | 5141 |
#ifdef SIGIO |
185 | 5142 |
case SIGIO: |
329 | 5143 |
handler = __signalIoInterrupt; |
185 | 5144 |
break; |
68 | 5145 |
#endif |
5146 |
||
5147 |
#ifdef CHILD_SIGNAL |
|
185 | 5148 |
case CHILD_SIGNAL: |
329 | 5149 |
handler = __signalChildInterrupt; |
185 | 5150 |
break; |
68 | 5151 |
#endif |
443 | 5152 |
#ifdef SIGALRM |
831 | 5153 |
# ifndef WIN32 |
185 | 5154 |
case SIGALRM: |
329 | 5155 |
handler = __signalTimerInterrupt; |
185 | 5156 |
break; |
831 | 5157 |
# endif |
443 | 5158 |
#endif |
185 | 5159 |
|
5160 |
default: |
|
329 | 5161 |
handler = __signalInterrupt; |
185 | 5162 |
break; |
5163 |
} |
|
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5164 |
|
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5165 |
{ |
762
cea705669628
ok, stefan was right: HAS_SIGACTION works
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
5166 |
#ifdef HAS_SIGACTION |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5167 |
struct sigaction act; |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5168 |
|
1487 | 5169 |
/* |
5170 |
* Do not add SA_RESTART here. A signal can cause a |
|
5171 |
* thread switch, another thread can do a garbage collect |
|
5172 |
* and restarted system calls may write into old |
|
5173 |
* (collected) addresses. |
|
5174 |
*/ |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
5175 |
|
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
5176 |
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
|
5177 |
sigemptyset(&act.sa_mask); |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5178 |
act.sa_handler = handler; |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5179 |
sigaction(sigNr, &act, 0); |
213 | 5180 |
#else |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5181 |
# ifdef HAS_SIGVEC |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5182 |
struct sigvec vec; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5183 |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
5184 |
vec.sv_flags = SV_INTERRUPT; |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5185 |
sigemptyset(&vec.sv_mask); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5186 |
vec.sv_handler = handler; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5187 |
sigvec(sigNr, &vec, NULL); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5188 |
# else |
831 | 5189 |
(void) signal(sigNr, handler); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5190 |
# endif |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5191 |
#endif |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5192 |
} |
213 | 5193 |
|
185 | 5194 |
/* |
5195 |
* maybe, we should return the old enable-status |
|
5196 |
* as boolean here ... |
|
5197 |
*/ |
|
5198 |
RETURN (self); |
|
68 | 5199 |
} |
5200 |
%}. |
|
5201 |
||
5202 |
" |
|
5203 |
this error is triggered on non-integer argument, or |
|
5204 |
if the signal number is not in the valid range (1..NSIG) |
|
5205 |
" |
|
792 | 5206 |
^ self primitiveFailed |
63 | 5207 |
! |
5208 |
||
831 | 5209 |
enableTimer:milliSeconds |
616 | 5210 |
"trigger a timerInterrupt, to be signalled after some (real) time." |
5211 |
||
5212 |
%{ /* NOCONTEXT */ |
|
831 | 5213 |
int millis; |
5214 |
||
5215 |
millis = __intVal(milliSeconds); |
|
616 | 5216 |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
5217 |
#if defined(ITIMER_REAL) |
831 | 5218 |
{ |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5219 |
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
|
5220 |
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
|
5221 |
#ifndef __signalTimerInterrupt |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5222 |
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
|
5223 |
#endif |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5224 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5225 |
if (firstCall) { |
831 | 5226 |
# ifdef HAS_SIGACTION |
5227 |
struct sigaction act; |
|
5228 |
||
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
5229 |
act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */ |
831 | 5230 |
sigemptyset(&act.sa_mask); |
5231 |
act.sa_handler = __signalTimerInterrupt; |
|
5232 |
sigaction(SIGALRM, &act, 0); |
|
5233 |
# else |
|
5234 |
# 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
|
5235 |
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
|
5236 |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
5237 |
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
|
5238 |
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
|
5239 |
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
|
5240 |
sigvec(SIGALRM, &vec, NULL); |
831 | 5241 |
# else |
5242 |
signal(SIGALRM, __signalTimerInterrupt); |
|
5243 |
# endif |
|
5244 |
# endif |
|
5245 |
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
|
5246 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5247 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5248 |
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
|
5249 |
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
|
5250 |
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
|
5251 |
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
|
5252 |
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
|
5253 |
RETURN (true); |
831 | 5254 |
} |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
5255 |
#else |
831 | 5256 |
# ifdef WIN32 |
5257 |
{ |
|
5258 |
/* |
|
5259 |
* two mechanisms - which one to use ? |
|
5260 |
*/ |
|
5261 |
# ifdef USE_TimerProc |
|
5262 |
||
5263 |
extern VOID CALLBACK __win32TimerProc(HWND, UINT, UINT, DWORD); |
|
1632 | 5264 |
w32TimerId = SetTimer(NULL, 0, millis, __win32TimerProc); |
831 | 5265 |
|
5266 |
# else /* USE_TimeProc */ |
|
5267 |
||
5268 |
extern void CALLBACK __win32TimeProc(UINT, UINT, DWORD, DWORD, DWORD, DWORD); |
|
1632 | 5269 |
timeSetEvent(millis, 5, (LPTIMECALLBACK)__win32TimeProc, 0, TIME_ONESHOT); |
831 | 5270 |
# endif |
1632 | 5271 |
RETURN (true); |
640
be94dfc60eaa
Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents:
630
diff
changeset
|
5272 |
} |
831 | 5273 |
# endif /* WIN32 */ |
5274 |
#endif /* ITIMER_REAL */ |
|
5275 |
%}. |
|
616 | 5276 |
^ false |
5277 |
! |
|
5278 |
||
1 | 5279 |
enableUserInterrupts |
5280 |
"enable userInterrupt (^C) handling; |
|
95 | 5281 |
when enabled, ^C in the terminal window will send the message |
5282 |
'userInterrupt' to the UserInterruptHandler object." |
|
1 | 5283 |
|
831 | 5284 |
self enableSignal:(self sigINT). |
5285 |
self enableSignal:(self sigBREAK). |
|
63 | 5286 |
! |
5287 |
||
616 | 5288 |
interruptPending |
5289 |
"return true, if an interrupt is pending. The returned value is |
|
5290 |
invalid if interrupts are not currently blocked, since otherwise |
|
5291 |
the interrupt is usually already handled before arriving here, |
|
5292 |
or may be served while returning from here." |
|
5293 |
||
5294 |
%{ /* NOCONTEXT */ |
|
5295 |
extern OBJ __INTERRUPTPENDING(); |
|
5296 |
||
5297 |
RETURN ( __INTERRUPTPENDING() ); |
|
5298 |
%} |
|
1 | 5299 |
! |
5300 |
||
704 | 5301 |
killProcess:processId |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5302 |
"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
|
5303 |
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
|
5304 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5305 |
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
|
5306 |
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
|
5307 |
OperatingSystem>>getStatusOfProcess:aProcessId." |
704 | 5308 |
|
5309 |
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
|
5310 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5311 |
"Modified: 28.12.1995 / 15:06:18 / stefan" |
704 | 5312 |
! |
5313 |
||
616 | 5314 |
nameForSignal:aSignalNumber |
5315 |
"for a given Unix signalnumber, return a descriptive string" |
|
5316 |
||
5317 |
aSignalNumber == self sigHUP ifTrue:[^ 'hangup']. |
|
5318 |
aSignalNumber == self sigINT ifTrue:[^ 'interrupt']. |
|
5319 |
aSignalNumber == self sigKILL ifTrue:[^ 'kill']. |
|
5320 |
aSignalNumber == self sigQUIT ifTrue:[^ 'quit']. |
|
5321 |
aSignalNumber == self sigILL ifTrue:[^ 'illegal instruction']. |
|
5322 |
aSignalNumber == self sigTRAP ifTrue:[^ 'trap']. |
|
5323 |
aSignalNumber == self sigABRT ifTrue:[^ 'abort']. |
|
5324 |
aSignalNumber == self sigIOT ifTrue:[^ 'iot trap']. |
|
5325 |
aSignalNumber == self sigEMT ifTrue:[^ 'emt trap']. |
|
5326 |
aSignalNumber == self sigFP ifTrue:[^ 'fp exception']. |
|
5327 |
aSignalNumber == self sigBUS ifTrue:[^ 'bus error']. |
|
5328 |
aSignalNumber == self sigSEGV ifTrue:[^ 'segmentation violation']. |
|
5329 |
aSignalNumber == self sigSYS ifTrue:[^ 'bad system call']. |
|
5330 |
aSignalNumber == self sigPIPE ifTrue:[^ 'broken pipe']. |
|
5331 |
aSignalNumber == self sigALRM ifTrue:[^ 'alarm timer']. |
|
5332 |
aSignalNumber == self sigTERM ifTrue:[^ 'termination']. |
|
5333 |
aSignalNumber == self sigSTOP ifTrue:[^ 'stop']. |
|
5334 |
aSignalNumber == self sigTSTP ifTrue:[^ 'tty stop']. |
|
5335 |
aSignalNumber == self sigCONT ifTrue:[^ 'continue']. |
|
5336 |
aSignalNumber == self sigCHLD ifTrue:[^ 'child death']. |
|
5337 |
aSignalNumber == self sigTTIN ifTrue:[^ 'background tty input']. |
|
5338 |
aSignalNumber == self sigTTOU ifTrue:[^ 'background tty output']. |
|
5339 |
aSignalNumber == self sigIO ifTrue:[^ 'io available']. |
|
5340 |
aSignalNumber == self sigXCPU ifTrue:[^ 'cpu time expired']. |
|
5341 |
aSignalNumber == self sigXFSZ ifTrue:[^ 'file size limit']. |
|
5342 |
aSignalNumber == self sigVTALRM ifTrue:[^ 'virtual alarm timer']. |
|
5343 |
aSignalNumber == self sigPROF ifTrue:[^ 'profiling timer']. |
|
5344 |
aSignalNumber == self sigWINCH ifTrue:[^ 'winsize changed']. |
|
5345 |
aSignalNumber == self sigLOST ifTrue:[^ 'resource lost']. |
|
5346 |
aSignalNumber == self sigUSR1 ifTrue:[^ 'user signal 1']. |
|
5347 |
aSignalNumber == self sigUSR2 ifTrue:[^ 'user signal 2']. |
|
5348 |
aSignalNumber == self sigMSG ifTrue:[^ 'HFT message']. |
|
5349 |
aSignalNumber == self sigPWR ifTrue:[^ 'power-fail']. |
|
5350 |
aSignalNumber == self sigPRE ifTrue:[^ 'programming exception']. |
|
5351 |
aSignalNumber == self sigGRANT ifTrue:[^ 'HFT access wanted']. |
|
5352 |
aSignalNumber == self sigRETRACT ifTrue:[^ 'HFT access relinquish']. |
|
5353 |
aSignalNumber == self sigSOUND ifTrue:[^ 'HFT sound complete']. |
|
5354 |
aSignalNumber == self sigDANGER ifTrue:[^ 'low on paging space']. |
|
5355 |
||
5356 |
"notice: many systems map SIGPOLL and/or SIGUSR onto SIGIO |
|
5357 |
therefore, keep SIGIO always above the two below" |
|
5358 |
aSignalNumber == self sigPOLL ifTrue:[^ 'io available']. |
|
5359 |
aSignalNumber == self sigURG ifTrue:[^ 'urgent']. |
|
5360 |
||
5361 |
^ 'unknown signal' |
|
5362 |
||
68 | 5363 |
" |
616 | 5364 |
OperatingSystem nameForSignal:9 |
5365 |
OperatingSystem nameForSignal:(OperatingSystem sigPOLL) |
|
68 | 5366 |
" |
616 | 5367 |
! |
5368 |
||
5369 |
operatingSystemSignal:signalNumber |
|
5370 |
"return the signal to be raised when an |
|
5371 |
operatingSystem-signal occurs, or nil" |
|
5372 |
||
5373 |
OSSignals notNil ifTrue:[ |
|
5374 |
^ OSSignals at:signalNumber ifAbsent:[nil] |
|
5375 |
]. |
|
5376 |
^ nil |
|
10 | 5377 |
! |
5378 |
||
616 | 5379 |
operatingSystemSignal:signalNumber install:aSignal |
5380 |
"install a signal to be raised when an operatingSystem-signal occurs" |
|
5381 |
||
5382 |
OSSignals isNil ifTrue:[ |
|
5383 |
OSSignals := Array new:32 |
|
5384 |
]. |
|
5385 |
OSSignals at:signalNumber put:aSignal |
|
5386 |
! |
|
5387 |
||
5388 |
sendSignal:signalNumber to:processId |
|
5389 |
"send a unix signal to some process (maybe myself). |
|
5390 |
Returns false if any error occurred, true otherwise. |
|
5391 |
||
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5392 |
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
|
5393 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5394 |
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
|
5395 |
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
|
5396 |
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
|
5397 |
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
|
5398 |
|
616 | 5399 |
%{ |
792 | 5400 |
#ifndef MSDOS_LIKE |
616 | 5401 |
if (__bothSmallInteger(signalNumber, processId)) { |
5402 |
if (kill(__intVal(processId), __intVal(signalNumber)) < 0) { |
|
1135 | 5403 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 5404 |
RETURN ( false ); |
216 | 5405 |
} |
616 | 5406 |
RETURN ( true ); |
10 | 5407 |
} |
792 | 5408 |
#endif |
68 | 5409 |
%}. |
792 | 5410 |
"/ |
5411 |
"/ either invalid argument (non-integers) |
|
5412 |
"/ or not supported by OS |
|
5413 |
"/ |
|
5414 |
^ self primitiveFailed |
|
1 | 5415 |
! |
5416 |
||
5417 |
startSpyTimer |
|
63 | 5418 |
"trigger a spyInterrupt, to be signalled after some short (virtual) time. |
359 | 5419 |
This is used by the old MessageTally for profiling. |
63 | 5420 |
Should be changed to use real profiling timer if available. |
68 | 5421 |
On systems, where no virtual timer is available, use the real timer |
359 | 5422 |
(which is of course less correct). |
5423 |
OBSOLETE: the new messageTally runs as a high prio process, not using |
|
5424 |
spy interrupts." |
|
1 | 5425 |
|
5426 |
%{ /* NOCONTEXT */ |
|
5427 |
||
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5428 |
#ifndef __spyInterrupt |
329 | 5429 |
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
|
5430 |
#endif |
10 | 5431 |
#if defined(ITIMER_VIRTUAL) |
1 | 5432 |
struct itimerval dt; |
5433 |
||
13 | 5434 |
# ifdef SIGVTALRM |
329 | 5435 |
signal(SIGVTALRM, __spyInterrupt); |
13 | 5436 |
# else |
329 | 5437 |
signal(SIGALRM, __spyInterrupt); |
13 | 5438 |
# endif |
5439 |
||
348 | 5440 |
dt.it_interval.tv_sec = 0; |
5441 |
dt.it_interval.tv_usec = 0; |
|
5442 |
dt.it_value.tv_sec = 0; |
|
5443 |
dt.it_value.tv_usec = 1000; /* 1000 Hz */ |
|
5444 |
setitimer(ITIMER_VIRTUAL, &dt, 0); |
|
5445 |
||
13 | 5446 |
RETURN (true); |
1 | 5447 |
#endif |
5448 |
%} |
|
13 | 5449 |
. |
5450 |
^ false |
|
1 | 5451 |
! |
5452 |
||
5453 |
stopSpyTimer |
|
359 | 5454 |
"stop spy timing - disable spy timer. |
5455 |
OBSOLETE: the new messageTally runs as a high prio process, not using |
|
5456 |
spy interrupts." |
|
1 | 5457 |
|
5458 |
%{ /* NOCONTEXT */ |
|
5459 |
||
10 | 5460 |
#if defined(ITIMER_VIRTUAL) |
1 | 5461 |
struct itimerval dt; |
5462 |
||
5463 |
dt.it_interval.tv_sec = 0; |
|
5464 |
dt.it_interval.tv_usec = 0; |
|
5465 |
dt.it_value.tv_sec = 0; |
|
5466 |
dt.it_value.tv_usec = 0; |
|
5467 |
setitimer(ITIMER_VIRTUAL, &dt, 0); |
|
13 | 5468 |
RETURN (true); |
10 | 5469 |
#endif |
5470 |
%} |
|
13 | 5471 |
. |
5472 |
^ false |
|
10 | 5473 |
! |
5474 |
||
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5475 |
terminateProcess:processId |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5476 |
"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
|
5477 |
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
|
5478 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5479 |
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
|
5480 |
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
|
5481 |
OperatingSystem>>getStatusOfProcess:aProcessId." |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5482 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5483 |
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
|
5484 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5485 |
"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
|
5486 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5487 |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5488 |
terminateProcessGroup:processGroupId |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5489 |
"terminate a unix process group. |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5490 |
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
|
5491 |
|
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5492 |
WARNING: in order to avoid zombie processes (on unix), |
1487 | 5493 |
you may have to fetch the processes exitstatus with |
5494 |
OperatingSystem>>getStatusOfProcess:aProcessId." |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5495 |
|
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5496 |
self sendSignal:(self sigTERM) to:(processGroupId negated). |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5497 |
|
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5498 |
"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
|
5499 |
"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
|
5500 |
! |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5501 |
|
616 | 5502 |
unblockInterrupts |
5503 |
"enable interrupt processing - if any interrupts are pending, |
|
5504 |
these will be handled immediately. |
|
5505 |
When unblocking interrupts, take care of nested block/unblock |
|
5506 |
calls - you must only unblock after a blockcall if they where |
|
5507 |
really not blocked before. See OperatingSystemclass>>blockInterrupts." |
|
5508 |
%{ |
|
5509 |
__UNBLOCKINTERRUPTS(); |
|
1040
60e4c4bbbca2
return nil from unblockInterrupts (thats what the inlined code returns)
Claus Gittinger <cg@exept.de>
parents:
1034
diff
changeset
|
5510 |
RETURN (nil); |
616 | 5511 |
%} |
5512 |
! ! |
|
5513 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
5514 |
!OperatingSystem class methodsFor:'misc'! |
616 | 5515 |
|
5516 |
exit |
|
710 | 5517 |
"shutdown smalltalk immediately - this method does not return. |
5518 |
Return 'good'-status (0) to the parent unix process." |
|
616 | 5519 |
|
5520 |
%{ /* NOCONTEXT */ |
|
5521 |
__mainExit(0); |
|
5522 |
%} |
|
5523 |
"OperatingSystem exit - dont evaluate this" |
|
5524 |
! |
|
5525 |
||
5526 |
exit:exitCode |
|
5527 |
"shutdown smalltalk immediately - |
|
5528 |
returning an exit-code to the parent unix process." |
|
5529 |
||
5530 |
%{ /* NOCONTEXT */ |
|
5531 |
int code = 1; |
|
5532 |
||
5533 |
if (__isSmallInteger(exitCode)) { |
|
1135 | 5534 |
code = __intVal(exitCode); |
616 | 5535 |
} |
5536 |
__mainExit(code); |
|
5537 |
%} |
|
5538 |
"OperatingSystem exit:1 - dont evaluate this" |
|
5539 |
! |
|
5540 |
||
5541 |
exitWithCoreDump |
|
5542 |
"shutdown smalltalk immediately - dumping core. |
|
5543 |
This always returns 'bad'-status to the parent unix process. |
|
5544 |
Notice, that no cleanup is performed at all - you may have to |
|
5545 |
manually remove any tempfiles. |
|
5546 |
Use this only for debugging ST/X itself" |
|
5547 |
||
5548 |
%{ /* NOCONTEXT */ |
|
5549 |
abort(); |
|
5550 |
%} |
|
831 | 5551 |
" |
5552 |
OperatingSystem exitWithCoreDump - dont evaluate this |
|
5553 |
" |
|
616 | 5554 |
! |
5555 |
||
5556 |
slowFork:aBoolean |
|
1247 | 5557 |
"set/clear the `avoid-fork-if-possible-because-its-slow' flag. |
5558 |
Only used internally on SYSV3 systems" |
|
5559 |
||
616 | 5560 |
SlowFork := aBoolean |
1247 | 5561 |
|
5562 |
"Modified: 22.4.1996 / 13:13:09 / cg" |
|
616 | 5563 |
! ! |
5564 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
5565 |
!OperatingSystem class methodsFor:'os queries'! |
616 | 5566 |
|
5567 |
getCPUDefine |
|
831 | 5568 |
"return a string which was used to identify this CPU type when STX was |
616 | 5569 |
compiled, and which should be passed down when compiling methods. |
831 | 5570 |
For example, on linux, this may be '-Di386'; on a vax, this would be '-Dvax'. |
5571 |
This is normally not of interest to 'normal' users; however, it is passed |
|
5572 |
down to the c-compiler when methods are incrementally compiled to machine code." |
|
616 | 5573 |
|
5574 |
%{ /* NOCONTEXT */ |
|
831 | 5575 |
# ifndef CPU_DEFINE |
5576 |
# define CPU_DEFINE "-DunknownCPU" |
|
5577 |
# endif |
|
5578 |
||
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5579 |
RETURN ( __MKSTRING(CPU_DEFINE)); |
616 | 5580 |
%} |
5581 |
" |
|
5582 |
OperatingSystem getCPUDefine |
|
5583 |
" |
|
5584 |
! |
|
5585 |
||
5586 |
getCPUType |
|
5587 |
"return a string giving the type of machine we're running on. |
|
831 | 5588 |
Here, the machine for which ST/X was compiled is returned |
5589 |
(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
|
5590 |
This may normally not be of any interest to you ..." |
616 | 5591 |
|
5592 |
|cpu| |
|
5593 |
||
5594 |
%{ /* NOCONTEXT */ |
|
5595 |
||
5596 |
# ifdef vax |
|
5597 |
# define CPU_STRING "vax" |
|
5598 |
# endif |
|
5599 |
# ifdef mips |
|
5600 |
# define CPU_STRING "mips" |
|
5601 |
# endif |
|
5602 |
# ifdef i386 |
|
5603 |
# define CPU_STRING "i386" |
|
5604 |
# endif |
|
5605 |
# ifdef ns32k |
|
5606 |
# define CPU_STRING "ns32k" |
|
5607 |
# endif |
|
5608 |
# ifdef mc68k |
|
5609 |
# define CPU_STRING "mc68k" |
|
5610 |
# endif |
|
5611 |
# ifdef mc88k |
|
5612 |
# define CPU_STRING "mc88k" |
|
5613 |
# endif |
|
5614 |
# ifdef sparc |
|
5615 |
# define CPU_STRING "sparc" |
|
5616 |
# endif |
|
5617 |
# ifdef hppa |
|
5618 |
# define CPU_STRING "hppa" |
|
5619 |
# endif |
|
5620 |
# ifdef rs6000 |
|
5621 |
# define CPU_STRING "rs6000" |
|
5622 |
# endif |
|
831 | 5623 |
# ifdef powerPC |
5624 |
# define CPU_STRING "powerPC" |
|
5625 |
# endif |
|
616 | 5626 |
# ifdef alpha |
5627 |
# define CPU_STRING "alpha" |
|
5628 |
# endif |
|
5629 |
# ifdef transputer |
|
5630 |
# define CPU_STRING "transputer" |
|
5631 |
# endif |
|
5632 |
# ifdef ibm370 |
|
5633 |
# define CPU_STRING "ibm370" |
|
5634 |
# endif |
|
5635 |
||
5636 |
# ifndef CPU_STRING |
|
5637 |
# define CPU_STRING "unknown" |
|
5638 |
# endif |
|
5639 |
||
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5640 |
cpu = __MKSTRING(CPU_STRING); |
616 | 5641 |
# undef CPU_STRING |
831 | 5642 |
%}. |
616 | 5643 |
^ cpu |
5644 |
||
5645 |
" |
|
5646 |
OperatingSystem getCPUType |
|
5647 |
" |
|
5648 |
||
5649 |
"examples: are we running on a ss-10/solaris ?" |
|
5650 |
" |
|
5651 |
(OperatingSystem getCPUType = 'sparc') |
|
5652 |
and:[OperatingSystem getOSType = 'solaris'] |
|
5653 |
" |
|
5654 |
||
5655 |
"or on a pc/solaris ?" |
|
5656 |
" |
|
5657 |
(OperatingSystem getCPUType = 'i386') |
|
5658 |
and:[OperatingSystem getOSType = 'solaris'] |
|
5659 |
" |
|
5660 |
! |
|
5661 |
||
5662 |
getCommandOutputFrom:aCommand |
|
5663 |
"execute a simple command (such as hostname) and |
|
5664 |
return the commands output as a string" |
|
5665 |
||
5666 |
|p result| |
|
5667 |
||
5668 |
ForkFailed ifFalse:[ |
|
5669 |
PipeStream openErrorSignal handle:[:ex | |
|
5670 |
ForkFailed := true. |
|
5671 |
'OS: cannot fork/popen' errorPrintNL. |
|
5672 |
ex return. |
|
5673 |
] do:[ |
|
5674 |
p := PipeStream readingFrom:aCommand. |
|
5675 |
p notNil ifTrue:[ |
|
5676 |
result := p nextLine. |
|
5677 |
p close |
|
5678 |
] |
|
5679 |
] |
|
5680 |
]. |
|
5681 |
^ result |
|
5682 |
! |
|
5683 |
||
5684 |
getDomainName |
|
5685 |
"return the domain this host is in. |
|
5686 |
Notice: |
|
1487 | 5687 |
not all systems support this; on some, 'unknown' is returned." |
616 | 5688 |
|
5689 |
|name| |
|
5690 |
||
5691 |
DomainName notNil ifTrue:[ |
|
1487 | 5692 |
^ DomainName |
616 | 5693 |
]. |
5694 |
||
5695 |
%{ /* STACK: 2048 */ |
|
5696 |
#if defined(HAS_GETDOMAINNAME) |
|
5697 |
char buffer[128]; |
|
5698 |
||
5699 |
if (getdomainname(buffer, sizeof(buffer)) == 0) { |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5700 |
name = __MKSTRING(buffer); |
616 | 5701 |
} |
5702 |
#else |
|
5703 |
# if defined(HAS_UNAME) && defined(HAS_UTS_DOMAINNAME) |
|
5704 |
struct utsname ubuff; |
|
5705 |
||
5706 |
if (uname(&ubuff) >= 0) { |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5707 |
name = __MKSTRING(ubuff.domainname); |
1433 | 5708 |
} |
5709 |
# else |
|
5710 |
# if defined(HAS_SYSINFO) && defined(SI_SRPC_DOMAIN) |
|
5711 |
char buffer[256]; |
|
5712 |
int ret; |
|
5713 |
||
5714 |
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
|
5715 |
name = __MKSTRING(buffer); |
1433 | 5716 |
} |
5717 |
# endif |
|
616 | 5718 |
# endif |
5719 |
#endif |
|
5720 |
%}. |
|
5721 |
name isNil ifTrue:[ |
|
1487 | 5722 |
name := self getEnvironment:'DOMAIN'. |
5723 |
name isNil ifTrue:[ |
|
5724 |
name := self getCommandOutputFrom:'domainname' |
|
5725 |
] |
|
616 | 5726 |
]. |
5727 |
name isNil ifTrue:[ |
|
1487 | 5728 |
'OS: cannot find out domainname' errorPrintNL. |
5729 |
name := 'unknown'. |
|
616 | 5730 |
]. |
5731 |
DomainName := name. |
|
5732 |
^ name |
|
5733 |
||
5734 |
" |
|
5735 |
OperatingSystem getDomainName |
|
5736 |
" |
|
1433 | 5737 |
|
5738 |
"Modified: 26.4.1996 / 10:04:54 / stefan" |
|
616 | 5739 |
! |
5740 |
||
5741 |
getEnvironment:aStringOrSymbol |
|
5742 |
"get an environment string" |
|
10 | 5743 |
|
5744 |
%{ /* NOCONTEXT */ |
|
5745 |
||
616 | 5746 |
char *env; |
5747 |
||
5748 |
if (__isString(aStringOrSymbol) || __isSymbol(aStringOrSymbol)) { |
|
1632 | 5749 |
#ifdef WIN32 |
5750 |
char buff[512]; |
|
5751 |
||
5752 |
env = NULL; |
|
5753 |
if (GetEnvironmentVariable(__stringVal(aStringOrSymbol), |
|
5754 |
buff, |
|
5755 |
sizeof(buff)-1)) { |
|
5756 |
env = buff; |
|
5757 |
} |
|
5758 |
#else |
|
1135 | 5759 |
env = (char *)getenv(__stringVal(aStringOrSymbol)); |
1632 | 5760 |
#endif |
616 | 5761 |
if (env) { |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5762 |
RETURN ( __MKSTRING(env) ); |
616 | 5763 |
} |
5764 |
} |
|
5765 |
%} |
|
5766 |
. |
|
5767 |
^ nil |
|
5768 |
||
5769 |
" |
|
5770 |
OperatingSystem getEnvironment:'LANG' |
|
5771 |
OperatingSystem getEnvironment:'LOGIN' |
|
5772 |
OperatingSystem getEnvironment:'HOME' |
|
5773 |
OperatingSystem getEnvironment:'NNTPSERVER' |
|
5774 |
OperatingSystem getEnvironment:'MAIL' |
|
5775 |
OperatingSystem getEnvironment:'PATH' |
|
5776 |
" |
|
5777 |
! |
|
5778 |
||
5779 |
getHostName |
|
5780 |
"return the hostname we are running on - if there is |
|
5781 |
a HOST environment variable, we are much faster here ... |
|
5782 |
Notice: |
|
5783 |
not all systems support this; on some, 'unknown' is returned." |
|
5784 |
||
5785 |
|name| |
|
5786 |
||
5787 |
HostName notNil ifTrue:[ |
|
5788 |
^ HostName |
|
5789 |
]. |
|
5790 |
||
5791 |
%{ /* STACK: 2048 */ |
|
5792 |
#if defined(HAS_GETHOSTNAME) |
|
5793 |
char buffer[128]; |
|
5794 |
||
5795 |
if (gethostname(buffer, sizeof(buffer)) == 0) { |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5796 |
name = __MKSTRING(buffer); |
616 | 5797 |
} |
5798 |
#else |
|
5799 |
# if defined(HAS_UNAME) |
|
5800 |
struct utsname ubuff; |
|
5801 |
||
5802 |
if (uname(&ubuff) >= 0) { |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5803 |
name = __MKSTRING(ubuff.nodename); |
616 | 5804 |
} |
831 | 5805 |
# else |
1702 | 5806 |
# if defined(HAS_SYSINFO) && defined(SI_HOSTNAME) |
5807 |
char buffer[256]; |
|
5808 |
int ret; |
|
5809 |
||
5810 |
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
|
5811 |
name = __MKSTRING(buffer); |
1702 | 5812 |
} |
5813 |
# else |
|
5814 |
# ifdef WIN32 |
|
831 | 5815 |
char buffer[128]; |
5816 |
int buffSize = sizeof(buffer); |
|
5817 |
||
5818 |
if (GetComputerName(buffer, &buffSize) == TRUE) { |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5819 |
name = __MKSTRING(buffer); |
831 | 5820 |
} |
1702 | 5821 |
# endif |
831 | 5822 |
# endif |
1 | 5823 |
# endif |
616 | 5824 |
#endif |
5825 |
%}. |
|
5826 |
name isNil ifTrue:[ |
|
5827 |
name := self getEnvironment:'HOST'. |
|
5828 |
name isNil ifTrue:[ |
|
5829 |
name := self getCommandOutputFrom:'hostname' |
|
5830 |
] |
|
5831 |
]. |
|
5832 |
name isNil ifTrue:[ |
|
5833 |
'OS: cannot find out hostname' errorPrintNL. |
|
5834 |
name := 'unknown'. |
|
5835 |
]. |
|
5836 |
HostName := name. |
|
5837 |
^ name |
|
5838 |
||
5839 |
" |
|
5840 |
OperatingSystem getHostName |
|
5841 |
" |
|
5842 |
! |
|
5843 |
||
1034 | 5844 |
getLocaleInfo |
5845 |
"return a dictionary filled with values from the locale information; |
|
5846 |
Not all fields may be present, depending on the OS's setup and capabilities. |
|
5847 |
Possible fields are: |
|
5848 |
decimalPoint <String> |
|
5849 |
||
5850 |
thousandsSep <String> |
|
5851 |
||
5852 |
internationalCurrencySymbol <String> |
|
5853 |
||
5854 |
currencySymbol <String> |
|
5855 |
||
5856 |
monetaryDecimalPoint <String> |
|
5857 |
||
5858 |
monetaryThousandsSeparator <String> |
|
5859 |
||
5860 |
positiveSign <String> |
|
5861 |
||
5862 |
negativeSign <String> |
|
5863 |
||
5864 |
internationalFractionalDigits <Integer> |
|
5865 |
||
5866 |
fractionalDigits <Integer> |
|
5867 |
||
5868 |
positiveSignPrecedesCurrencySymbol <Boolean> |
|
5869 |
||
5870 |
negativeSignPrecedesCurrencySymbol <Boolean> |
|
5871 |
||
5872 |
positiveSignSeparatedBySpaceFromCurrencySymbol <Boolean> |
|
5873 |
||
5874 |
negativeSignSeparatedBySpaceFromCurrencySymbol <Boolean> |
|
5875 |
||
5876 |
positiveSignPosition <Symbol> |
|
5877 |
one of: #parenthesesAround, |
|
5878 |
#signPrecedes, |
|
5879 |
#signSuceeds, |
|
5880 |
#signPrecedesCurrencySymbol, |
|
5881 |
#signSuceedsCurrencySymbol |
|
5882 |
||
5883 |
negativeSignPosition <like above> |
|
5884 |
||
5885 |
it is up to the application to deal with undefined values. |
|
5886 |
||
5887 |
Notice, that (for now), the system does not use this information; |
|
5888 |
it should be used by applications as required. |
|
5889 |
" |
|
5890 |
||
5891 |
|info val| |
|
5892 |
||
5893 |
LocaleInfo notNil ifTrue:[ |
|
5894 |
"/ return the internal info; useful on systems which do not |
|
5895 |
"/ support this. |
|
5896 |
^ LocaleInfo |
|
5897 |
]. |
|
5898 |
||
5899 |
info := IdentityDictionary new. |
|
5900 |
%{ |
|
5901 |
char *decimalPoint; /* something like "." (US) or "," (german) */ |
|
5902 |
char *thousandsSep; /* something like "," (US) or "." (german) */ |
|
5903 |
char *intCurrencySymbol; /* international currency symbol; something like "USD " "DM " */ |
|
5904 |
char *currencySymbol; /* local currency symbol; something like "USD " "DM " */ |
|
5905 |
char *monDecimalPoint; /* money: decimal point */ |
|
5906 |
char *monThousandsSep; /* money: thousands sep */ |
|
5907 |
char *positiveSign; |
|
5908 |
char *negativeSign; |
|
5909 |
int intFractDigits; /* money: international digits after decPoint */ |
|
5910 |
int fractDigits; /* money: local digits after decPoint */ |
|
5911 |
int csPosPrecedes; /* money: 1 if currency symbol precedes a positive value; 0 if it sceeds */ |
|
5912 |
int csNegPrecedes; /* money: 1 if currency symbol precedes a negative value; 0 if it sceeds */ |
|
5913 |
int csPosSepBySpace; /* money: 1 if currency symbol should be separated by a space from a positive value; 0 if no space */ |
|
5914 |
int csNegSepBySpace; /* money: 1 if currency symbol should be separated by a space from a negative value; 0 if no space */ |
|
5915 |
int csPosSignPosition; /* money: 0: ()'s around the value & currency symbol */ |
|
5916 |
int csNegSignPosition; /* 1: sign precedes the value & currency symbol */ |
|
5917 |
/* 2: sign succeeds the value & currency symbol */ |
|
5918 |
/* 3: sign immediately precedes the currency symbol */ |
|
5919 |
/* 4: sign immediately suceeds the currency symbol */ |
|
5920 |
||
5921 |
#if defined(HAS_LOCALECONV) |
|
5922 |
struct lconv *conf; |
|
5923 |
||
5924 |
conf = localeconv(); |
|
5925 |
if (conf) { |
|
5926 |
decimalPoint = conf->decimal_point; |
|
5927 |
thousandsSep = conf->thousands_sep; |
|
5928 |
intCurrencySymbol = conf->int_curr_symbol; |
|
5929 |
currencySymbol = conf->currency_symbol; |
|
5930 |
monDecimalPoint = conf->mon_decimal_point; |
|
5931 |
monThousandsSep = conf->mon_thousands_sep; |
|
5932 |
positiveSign = conf->positive_sign; |
|
5933 |
negativeSign = conf->negative_sign; |
|
5934 |
intFractDigits = conf->int_frac_digits; |
|
5935 |
fractDigits = conf->frac_digits; |
|
5936 |
csPosPrecedes = conf->p_cs_precedes; |
|
5937 |
csNegPrecedes = conf->n_cs_precedes; |
|
5938 |
csPosSepBySpace = conf->p_sep_by_space; |
|
5939 |
csNegSepBySpace = conf->n_sep_by_space; |
|
5940 |
csPosSignPosition = conf->p_sign_posn; |
|
5941 |
csNegSignPosition = conf->n_sign_posn; |
|
5942 |
} |
|
5943 |
#else |
|
5944 |
decimalPoint = (char *)0; |
|
5945 |
thousandsSep = (char *)0; |
|
5946 |
intCurrencySymbol = (char *)0; |
|
5947 |
currencySymbol = (char *)0; |
|
5948 |
monDecimalPoint = (char *)0; |
|
5949 |
monThousandsSep = (char *)0; |
|
5950 |
positiveSign = (char *)0; |
|
5951 |
negativeSign =(char *)0; |
|
5952 |
intFractDigits = -1; |
|
5953 |
fractDigits = -1; |
|
5954 |
csPosPrecedes = -1; |
|
5955 |
csNegPrecedes = -1; |
|
5956 |
csPosSepBySpace = -1; |
|
5957 |
csNegSepBySpace = -1; |
|
5958 |
csPosSignPosition = -1; |
|
5959 |
csNegSignPosition = -1; |
|
5960 |
#endif |
|
5961 |
if (decimalPoint) { |
|
5962 |
val = __MKSTRING(decimalPoint); |
|
5963 |
__AT_PUT_(info, @symbol(decimalPoint), val); |
|
5964 |
} |
|
5965 |
if (thousandsSep) { |
|
5966 |
val = __MKSTRING(thousandsSep); |
|
5967 |
__AT_PUT_(info, @symbol(thousandsSeparator), val); |
|
5968 |
} |
|
5969 |
if (intCurrencySymbol) { |
|
5970 |
val = __MKSTRING(intCurrencySymbol); |
|
5971 |
__AT_PUT_(info, @symbol(internationCurrencySymbol), val); |
|
5972 |
} |
|
5973 |
if (currencySymbol) { |
|
5974 |
val = __MKSTRING(currencySymbol); |
|
5975 |
__AT_PUT_(info, @symbol(currencySymbol), val); |
|
5976 |
} |
|
5977 |
if (monDecimalPoint) { |
|
5978 |
val = __MKSTRING(monDecimalPoint); |
|
5979 |
__AT_PUT_(info, @symbol(monetaryDecimalPoint), val); |
|
5980 |
} |
|
5981 |
if (monThousandsSep) { |
|
5982 |
val = __MKSTRING(monThousandsSep); |
|
5983 |
__AT_PUT_(info, @symbol(monetaryThousandsSeparator), val); |
|
5984 |
} |
|
5985 |
if (positiveSign) { |
|
5986 |
val = __MKSTRING(positiveSign); |
|
5987 |
__AT_PUT_(info, @symbol(positiveSign), val); |
|
5988 |
} |
|
5989 |
if (negativeSign) { |
|
5990 |
val = __MKSTRING(negativeSign); |
|
5991 |
__AT_PUT_(info, @symbol(negativeSign), val); |
|
5992 |
} |
|
5993 |
if (intFractDigits >= 0) { |
|
5994 |
__AT_PUT_(info, @symbol(internationalFractionalDigits), __MKSMALLINT(intFractDigits)); |
|
5995 |
} |
|
5996 |
if (fractDigits >= 0) { |
|
5997 |
__AT_PUT_(info, @symbol(fractionalDigits), __MKSMALLINT(fractDigits)); |
|
5998 |
} |
|
5999 |
if (csPosPrecedes >= 0) { |
|
6000 |
if (csPosPrecedes == 0) { |
|
6001 |
val = false; |
|
6002 |
} else { |
|
6003 |
val = true; |
|
6004 |
} |
|
6005 |
__AT_PUT_(info, @symbol(positiveSignPrecedesCurrencySymbol), val ); |
|
6006 |
} |
|
6007 |
if (csNegPrecedes >= 0) { |
|
6008 |
if (csNegPrecedes == 0) { |
|
6009 |
val = false; |
|
6010 |
} else { |
|
6011 |
val = true; |
|
6012 |
} |
|
6013 |
__AT_PUT_(info, @symbol(negativeSignPrecedesCurrencySymbol), val ); |
|
6014 |
} |
|
6015 |
if (csPosSepBySpace >= 0) { |
|
6016 |
if (csPosSepBySpace == 0) { |
|
6017 |
val = false; |
|
6018 |
} else { |
|
6019 |
val = true; |
|
6020 |
} |
|
6021 |
__AT_PUT_(info, @symbol(positiveSignSeparatedBySpaceFromCurrencySymbol), val); |
|
6022 |
} |
|
6023 |
if (csNegSepBySpace >= 0) { |
|
6024 |
if (csNegSepBySpace == 0) { |
|
6025 |
val = false; |
|
6026 |
} else { |
|
6027 |
val = true; |
|
6028 |
} |
|
6029 |
__AT_PUT_(info, @symbol(negativeSignSeparatedBySpaceFromCurrencySymbol), val); |
|
6030 |
} |
|
6031 |
switch (csPosSignPosition) { |
|
6032 |
case 0: |
|
6033 |
val = @symbol(parenthesesAround); |
|
6034 |
break; |
|
6035 |
||
6036 |
case 1: |
|
6037 |
val = @symbol(signPrecedes); |
|
6038 |
break; |
|
6039 |
||
6040 |
case 2: |
|
6041 |
val = @symbol(signSuceeds); |
|
6042 |
break; |
|
6043 |
||
6044 |
case 3: |
|
6045 |
val = @symbol(signPrecedesCurrencySymbol); |
|
6046 |
break; |
|
6047 |
||
6048 |
case 4: |
|
6049 |
val = @symbol(signSuceedsCurrencySymbol); |
|
6050 |
break; |
|
6051 |
||
6052 |
default: |
|
6053 |
val = nil; |
|
6054 |
} |
|
6055 |
if (val != nil) { |
|
6056 |
__AT_PUT_(info, @symbol(positiveSignPosition), val); |
|
6057 |
} |
|
6058 |
||
6059 |
switch (csNegSignPosition) { |
|
6060 |
case 0: |
|
6061 |
val = @symbol(parenthesesAround); |
|
6062 |
break; |
|
6063 |
||
6064 |
case 1: |
|
6065 |
val = @symbol(signPrecedes); |
|
6066 |
break; |
|
6067 |
||
6068 |
case 2: |
|
6069 |
val = @symbol(signSuceeds); |
|
6070 |
break; |
|
6071 |
||
6072 |
case 3: |
|
6073 |
val = @symbol(signPrecedesCurrencySymbol); |
|
6074 |
break; |
|
6075 |
||
6076 |
case 4: |
|
6077 |
val = @symbol(signSuceedsCurrencySymbol); |
|
6078 |
break; |
|
6079 |
||
6080 |
default: |
|
6081 |
val = nil; |
|
6082 |
} |
|
6083 |
if (val != nil) { |
|
6084 |
__AT_PUT_(info, @symbol(negativeSignPosition), val); |
|
6085 |
} |
|
6086 |
%}. |
|
6087 |
^ info |
|
6088 |
||
6089 |
" |
|
6090 |
OperatingSystem getLocaleInfo |
|
6091 |
" |
|
6092 |
||
6093 |
"Created: 23.12.1995 / 14:19:20 / cg" |
|
6094 |
! |
|
6095 |
||
616 | 6096 |
getOSDefine |
6097 |
"return a string which was used to identify this machine when stx was |
|
6098 |
compiled, and which should be passed down when compiling methods. |
|
6099 |
For example, on linux, this is '-DLINUX'." |
|
6100 |
||
6101 |
%{ /* NOCONTEXT */ |
|
831 | 6102 |
#ifdef WIN32 |
6103 |
# ifndef OS_DEFINE |
|
6104 |
# define OS_DEFINE "-DWIN32" |
|
6105 |
# endif |
|
6106 |
#endif |
|
6107 |
||
616 | 6108 |
#ifndef OS_DEFINE |
6109 |
# define OS_DEFINE "-DunknownOS" |
|
6110 |
#endif |
|
831 | 6111 |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6112 |
RETURN ( __MKSTRING(OS_DEFINE)); |
1987 | 6113 |
|
6114 |
#undef OS_DEFINE |
|
616 | 6115 |
%} |
6116 |
" |
|
6117 |
OperatingSystem getOSDefine |
|
6118 |
" |
|
6119 |
! |
|
6120 |
||
6121 |
getOSType |
|
6122 |
"return a string giving the type of OS we're running on. |
|
6123 |
This can be used to adapt programs to certain environment |
|
6124 |
differences (for example: mail-lock strategy ...)" |
|
6125 |
||
6126 |
|os| |
|
6127 |
||
6128 |
%{ /* NOCONTEXT */ |
|
6129 |
||
6130 |
# ifdef MSDOS |
|
6131 |
# define OS_STRING "msdos" |
|
6132 |
# endif |
|
6133 |
||
831 | 6134 |
# ifdef WIN32 |
1987 | 6135 |
# define OS_STRING "win32" |
831 | 6136 |
|
6137 |
# endif |
|
6138 |
||
616 | 6139 |
# ifdef MSWINDOWS |
6140 |
# define OS_STRING "mswindows" |
|
6141 |
# endif |
|
6142 |
||
6143 |
# ifdef NT |
|
6144 |
# define OS_STRING "nt" |
|
6145 |
# endif |
|
6146 |
||
6147 |
# ifdef VMS |
|
6148 |
# define OS_STRING "vms" |
|
6149 |
# endif |
|
6150 |
||
6151 |
# ifdef MVS |
|
6152 |
# define OS_STRING "mvs" |
|
6153 |
# endif |
|
6154 |
||
6155 |
# ifdef OS2 |
|
6156 |
# define OS_STRING "os2" |
|
6157 |
# endif |
|
6158 |
||
6159 |
# ifdef sinix |
|
6160 |
# define OS_STRING "sinix" |
|
6161 |
# endif |
|
6162 |
||
6163 |
# ifdef ultrix |
|
6164 |
# define OS_STRING "ultrix" |
|
6165 |
# endif |
|
6166 |
||
6167 |
# ifdef sco |
|
6168 |
# define OS_STRING "sco" |
|
6169 |
# endif |
|
6170 |
||
6171 |
# ifdef hpux |
|
6172 |
# define OS_STRING "hpux" |
|
6173 |
# endif |
|
6174 |
||
6175 |
# ifdef LINUX |
|
6176 |
# define OS_STRING "linux" |
|
6177 |
# endif |
|
6178 |
||
6179 |
# ifdef sunos |
|
6180 |
# define OS_STRING "sunos" |
|
6181 |
# endif |
|
6182 |
||
6183 |
# ifdef solaris |
|
6184 |
# define OS_STRING "solaris" |
|
6185 |
# endif |
|
6186 |
||
6187 |
# ifdef IRIS |
|
6188 |
# define OS_STRING "irix" |
|
6189 |
# endif |
|
6190 |
||
6191 |
# ifdef aix |
|
6192 |
# define OS_STRING "aix" |
|
6193 |
# endif |
|
6194 |
||
6195 |
# ifdef realIX |
|
6196 |
# define OS_STRING "realIX" |
|
6197 |
# endif |
|
6198 |
||
6199 |
/* |
|
6200 |
* no concrete info; become somewhat vague ... |
|
6201 |
*/ |
|
6202 |
# ifndef OS_STRING |
|
6203 |
# ifdef MACH |
|
6204 |
# define OS_STRING "mach" |
|
6205 |
# endif |
|
6206 |
# endif |
|
6207 |
||
6208 |
# ifndef OS_STRING |
|
6209 |
# ifdef BSD |
|
6210 |
# define OS_STRING "bsd" |
|
6211 |
# endif |
|
6212 |
||
6213 |
# ifdef SYSV |
|
6214 |
# ifdef SYSV3 |
|
6215 |
# define OS_STRING "sys5_3" |
|
6216 |
# else |
|
6217 |
# ifdef SYSV4 |
|
6218 |
# define OS_STRING "sys5_4" |
|
6219 |
# else |
|
6220 |
# define OS_STRING "sys5" |
|
6221 |
# endif |
|
6222 |
# endif |
|
6223 |
# endif |
|
6224 |
# endif |
|
6225 |
||
6226 |
/* |
|
6227 |
* become very vague ... |
|
6228 |
*/ |
|
6229 |
# ifndef OS_STRING |
|
6230 |
# ifdef POSIX |
|
6231 |
# define OS_STRING "posix" |
|
6232 |
# endif |
|
6233 |
# endif |
|
6234 |
# ifndef OS_STRING |
|
6235 |
# ifdef UNIX |
|
6236 |
# define OS_STRING "unix" |
|
6237 |
# endif |
|
6238 |
# endif |
|
6239 |
||
6240 |
# ifndef OS_STRING |
|
6241 |
# define OS_STRING "unknown" |
|
6242 |
# endif |
|
6243 |
||
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6244 |
os = __MKSTRING(OS_STRING); |
1987 | 6245 |
|
616 | 6246 |
# undef OS_STRING |
831 | 6247 |
%}. |
616 | 6248 |
^ os |
6249 |
||
6250 |
"OperatingSystem getOSType" |
|
6251 |
! |
|
6252 |
||
6253 |
getProcessId |
|
6254 |
"return the (unix-)processId" |
|
6255 |
||
6256 |
%{ /* NOCONTEXT */ |
|
6257 |
||
6258 |
int pid = 0; |
|
6259 |
#ifdef UNIX_LIKE |
|
6260 |
pid = getpid(); |
|
1632 | 6261 |
#else |
6262 |
# ifdef WIN32 |
|
6263 |
pid = GetCurrentProcessId() & 0x3FFFFFFF; |
|
6264 |
# endif |
|
616 | 6265 |
#endif |
1135 | 6266 |
RETURN ( __MKSMALLINT(pid) ); |
616 | 6267 |
%} |
6268 |
" |
|
6269 |
OperatingSystem getProcessId |
|
6270 |
" |
|
6271 |
! |
|
6272 |
||
6273 |
getSystemID |
|
6274 |
"if supported by the OS, return the systemID; |
|
6275 |
a unique per machine identification. |
|
6276 |
WARNING: |
|
6277 |
not all systems support this; on some, 'unknown' is returned." |
|
6278 |
||
6279 |
%{ /* NO_CONTEXT */ |
|
6280 |
#if defined(IRIX5) && !defined(HAS_GETHOSTID) |
|
6281 |
char idBuffer[MAXSYSIDSIZE]; |
|
6282 |
int retVal; |
|
6283 |
OBJ arr; |
|
6284 |
||
6285 |
if ((retVal = syssgi(SGI_SYSID, idBuffer)) == 0) { |
|
6286 |
arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(MAXSYSIDSIZE); |
|
6287 |
bcopy(idBuffer, __ByteArrayInstPtr(arr)->ba_element, MAXSYSIDSIZE); |
|
6288 |
RETURN (arr); |
|
6289 |
} |
|
6290 |
#endif |
|
6291 |
#if defined(HAS_GETHOSTID) |
|
6292 |
int runningId; |
|
6293 |
OBJ arr; |
|
6294 |
||
6295 |
runningId = gethostid(); |
|
6296 |
arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(4); |
|
6297 |
*(int *)(__ByteArrayInstPtr(arr)->ba_element) = runningId; |
|
6298 |
RETURN (arr); |
|
6299 |
#endif |
|
6300 |
%}. |
|
6301 |
^ 'unknown' |
|
6302 |
||
6303 |
" |
|
6304 |
OperatingSystem getSystemID |
|
6305 |
" |
|
6306 |
! |
|
6307 |
||
6308 |
getSystemInfo |
|
831 | 6309 |
"return info on the system weare running on. |
6310 |
If the system supports the uname system call, that info is returned; |
|
616 | 6311 |
otherwise, some simulated info is returned. |
831 | 6312 |
|
616 | 6313 |
WARNING: |
831 | 6314 |
Do not depend on the amount and contents of the returned information, some |
6315 |
systems may return more/less than others. Also, the contents depends on the |
|
6316 |
OS, for example, linux returns 'ix86', while WIN32 returns 'x86'. |
|
6317 |
||
6318 |
This method is mainly provided to augment error reports with some system |
|
6319 |
information. |
|
6320 |
(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
|
6321 |
may be based upon this info) |
616 | 6322 |
|
6323 |
The returned info may (or may not) contain: |
|
831 | 6324 |
#system -> some operating system identification (irix, Linux, nt, win32s ...) |
6325 |
#version -> OS version (some os version identification) |
|
6326 |
#release -> OS release (3.5, 1.2.1 ...) |
|
6327 |
#node -> some host identification (hostname) |
|
6328 |
#domain -> domain name (hosts domain) |
|
6329 |
#machine -> type of machine (i586, mips ...) |
|
616 | 6330 |
" |
6331 |
||
6332 |
|sys node rel ver mach dom mtyp brel info| |
|
6333 |
||
1060
119d45f975e1
increased getSystemInfos stack - just to make certain
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
6334 |
%{ /* STACK: 4096 */ |
616 | 6335 |
#if defined(HAS_UNAME) |
6336 |
struct utsname ubuff; |
|
6337 |
||
6338 |
if (uname(&ubuff) >= 0) { |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6339 |
sys = __MKSTRING(ubuff.sysname); |
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6340 |
node = __MKSTRING(ubuff.nodename); |
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6341 |
rel = __MKSTRING(ubuff.release); |
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6342 |
ver = __MKSTRING(ubuff.version); |
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6343 |
mach = __MKSTRING(ubuff.machine); |
616 | 6344 |
# ifdef HAS_UTS_DOMAINNAME |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6345 |
dom = __MKSTRING(ubuff.domainname); |
1675 | 6346 |
# else |
6347 |
# if defined(HAS_GETDOMAINNAME) |
|
6348 |
{ |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
6349 |
char buffer[128]; |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
6350 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
6351 |
if (getdomainname(buffer, sizeof(buffer)) == 0) { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
6352 |
dom = __MKSTRING(buffer); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
6353 |
} |
1675 | 6354 |
} |
6355 |
# endif |
|
616 | 6356 |
# endif |
6357 |
} |
|
831 | 6358 |
#else /* no uname */ |
6359 |
# ifdef WIN32 |
|
6360 |
||
6361 |
char vsnBuffer[32]; |
|
6362 |
char *s; |
|
6363 |
int winVer; |
|
6364 |
DWORD vsn; |
|
6365 |
SYSTEM_INFO sysInfo; |
|
6366 |
||
6367 |
vsn = GetVersion(); |
|
6368 |
||
6369 |
if (HIWORD(vsn) & 0x8000) { |
|
6370 |
s = "win32s"; |
|
6371 |
} else { |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6372 |
s = "nt"; |
831 | 6373 |
} |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6374 |
sys = __MKSTRING(s); |
831 | 6375 |
winVer = LOWORD(vsn); |
6376 |
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
|
6377 |
rel = __MKSTRING(vsnBuffer); |
831 | 6378 |
|
6379 |
GetSystemInfo(&sysInfo); |
|
6380 |
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
|
6381 |
sprintf(vsnBuffer, "%d", sysInfo.dwProcessorType); |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6382 |
mach = __MKSTRING(vsnBuffer); |
831 | 6383 |
} |
6384 |
||
6385 |
# endif /* WIN32 */ |
|
6386 |
#endif /* no uname */ |
|
616 | 6387 |
%}. |
6388 |
sys isNil ifTrue:[ |
|
6389 |
sys := self getSystemType. |
|
6390 |
]. |
|
6391 |
node isNil ifTrue:[ |
|
6392 |
node := self getHostName |
|
6393 |
]. |
|
6394 |
dom isNil ifTrue:[ |
|
6395 |
dom := self getDomainName |
|
6396 |
]. |
|
831 | 6397 |
mach isNil ifTrue:[ |
6398 |
mach := self getCPUType |
|
6399 |
]. |
|
616 | 6400 |
|
6401 |
info := IdentityDictionary new. |
|
6402 |
info at:#system put:sys. |
|
6403 |
info at:#node put:node. |
|
6404 |
rel notNil ifTrue:[info at:#release put:rel]. |
|
6405 |
ver notNil ifTrue:[info at:#version put:ver]. |
|
6406 |
mach notNil ifTrue:[info at:#machine put:mach]. |
|
6407 |
dom notNil ifTrue:[info at:#domain put:dom]. |
|
6408 |
^ info |
|
6409 |
||
6410 |
" |
|
6411 |
OperatingSystem getSystemInfo |
|
6412 |
" |
|
6413 |
! |
|
6414 |
||
6415 |
getSystemType |
|
6416 |
"return a string giving the type of system we're running on. |
|
6417 |
This is almost the same as getOSType, but the returned string |
|
6418 |
is slightly different for some systems (i.e. iris vs. irix). |
|
6419 |
Dont depend on this - use getOSType. I dont really see a point |
|
831 | 6420 |
here ... |
6421 |
(except for slight differences between next/mach and other machs)" |
|
616 | 6422 |
|
6423 |
|sys| |
|
6424 |
||
6425 |
%{ |
|
6426 |
# ifdef NEXT |
|
6427 |
# define SYS_STRING "next" |
|
6428 |
# endif |
|
6429 |
||
6430 |
# ifdef IRIS |
|
6431 |
# define SYS_STRING "iris" |
|
6432 |
# endif |
|
6433 |
||
831 | 6434 |
# ifdef WIN32 |
6435 |
# define SYS_STRING "win32" |
|
6436 |
# endif |
|
6437 |
||
616 | 6438 |
# ifdef SYS_STRING |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6439 |
sys = __MKSTRING(SYS_STRING); |
616 | 6440 |
# undef SYS_STRING |
6441 |
# endif |
|
831 | 6442 |
%}. |
616 | 6443 |
sys isNil ifTrue:[ |
6444 |
^ self getOSType |
|
6445 |
]. |
|
6446 |
^ sys |
|
6447 |
||
6448 |
" |
|
6449 |
OperatingSystem getSystemType |
|
6450 |
" |
|
6451 |
! |
|
6452 |
||
6453 |
isBSDlike |
|
6454 |
"return true, if the OS we're running on is a 'real' unix." |
|
6455 |
||
6456 |
%{ /* NOCONTEXT */ |
|
6457 |
||
6458 |
#if defined(BSD) || defined(MACH) || defined(SYSV4) |
|
6459 |
RETURN ( true ); |
|
13 | 6460 |
#endif |
831 | 6461 |
%}. |
13 | 6462 |
^ false |
10 | 6463 |
! |
6464 |
||
616 | 6465 |
isMSDOSlike |
6466 |
"return true, if the OS we're running on is dos like |
|
6467 |
(in contrast to unix-like)." |
|
6468 |
||
6469 |
%{ /* NOCONTEXT */ |
|
6470 |
||
6471 |
#if defined(MSDOS_LIKE) |
|
6472 |
RETURN ( true ); |
|
6473 |
#endif |
|
831 | 6474 |
%}. |
616 | 6475 |
^ false |
6476 |
! |
|
6477 |
||
831 | 6478 |
isMSWINDOWSlike |
6479 |
"return true, if the OS we're running on is MS-Windows like." |
|
6480 |
||
6481 |
%{ /* NOCONTEXT */ |
|
6482 |
||
6483 |
#if defined(WIN32) |
|
6484 |
RETURN ( true ); |
|
6485 |
#endif |
|
6486 |
||
6487 |
%}. |
|
6488 |
^ false |
|
6489 |
! |
|
6490 |
||
6491 |
isOS2like |
|
6492 |
"return true, if the OS we're running on is OS2 like" |
|
6493 |
||
6494 |
%{ /* NOCONTEXT */ |
|
6495 |
||
6496 |
#if defined(OS2) |
|
6497 |
RETURN (true); |
|
6498 |
#endif |
|
6499 |
||
6500 |
%}. |
|
6501 |
^ false |
|
6502 |
! |
|
6503 |
||
1034 | 6504 |
isUNIXlike |
6505 |
"return true, if the OS we're running on is a unix like." |
|
6506 |
||
6507 |
%{ /* NOCONTEXT */ |
|
6508 |
||
6509 |
#if !defined(UNIX_LIKE) |
|
6510 |
RETURN ( false ); |
|
6511 |
#endif |
|
6512 |
%}. |
|
6513 |
^ true |
|
6514 |
! |
|
6515 |
||
616 | 6516 |
maxFileNameLength |
6517 |
"return the max number of characters in a filename. |
|
831 | 6518 |
CAVEAT: |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6519 |
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
|
6520 |
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
|
6521 |
We return a somewhat conservative number here." |
10 | 6522 |
|
6523 |
%{ /* NOCONTEXT */ |
|
616 | 6524 |
|
6525 |
/* |
|
6526 |
* XXX: newer systems provide a query function for this ... use it |
|
6527 |
*/ |
|
6528 |
# if defined(BSD) || defined(SYSV4) || defined(LONGFILENAMES) |
|
831 | 6529 |
RETURN ( __MKSMALLINT(255) ); |
616 | 6530 |
# endif |
6531 |
||
6532 |
# ifdef realIX |
|
831 | 6533 |
RETURN ( __MKSMALLINT(127) ); |
616 | 6534 |
# endif |
6535 |
||
6536 |
# ifdef SYSV |
|
831 | 6537 |
RETURN ( __MKSMALLINT(14) ); |
616 | 6538 |
# endif |
6539 |
||
6540 |
# ifdef MSDOS |
|
831 | 6541 |
RETURN ( __MKSMALLINT(9) ); |
616 | 6542 |
# endif |
6543 |
||
831 | 6544 |
# ifdef WIN32 |
616 | 6545 |
/* |
6546 |
* mhmh - depends on the filesystem type |
|
6547 |
*/ |
|
831 | 6548 |
RETURN ( __MKSMALLINT(9) ); |
616 | 6549 |
# endif |
6550 |
%}. |
|
6551 |
"unix default" |
|
831 | 6552 |
|
616 | 6553 |
^ 14 |
6554 |
! |
|
6555 |
||
1034 | 6556 |
setLocaleInfo:anInfoDictionary |
6557 |
"set the locale information; if set, this oerrides the OS's settings. |
|
6558 |
(internal in ST/X only - the OS's settings remain unaffected) |
|
6559 |
See description of fields in #getLocaleInfo. |
|
6560 |
||
6561 |
Notice, that (for now), the system does not use this information; |
|
6562 |
it should be used by applications as required." |
|
6563 |
||
6564 |
LocaleInfo := anInfoDictionary |
|
6565 |
||
6566 |
" |
|
6567 |
|d| |
|
6568 |
||
6569 |
d := IdentityDictionary new. |
|
6570 |
d at:#decimalPoint put:'.' . |
|
6571 |
d at:#thousandsSeparator put:',' . |
|
6572 |
d at:#currencySymbol put:'USD' . |
|
6573 |
d at:#monetaryDecimalPoint put:'.' . |
|
6574 |
d at:#monetaryThousandsSeparator put:'.' . |
|
6575 |
d at:#fractionalDigits put:2 . |
|
6576 |
d at:#positiveSign put:'+' . |
|
6577 |
d at:#negativeSign put:'-' . |
|
6578 |
d at:#positiveSignPrecedesCurrencySymbol put:true . |
|
6579 |
d at:#negativeSignPrecedesCurrencySymbol put:false . |
|
6580 |
OperatingSystem setLocaleInfo:d |
|
6581 |
" |
|
6582 |
! |
|
6583 |
||
616 | 6584 |
supportsIOInterrupts |
6585 |
"return true, if the OS supports IO availability interrupts |
|
6586 |
(i.e. SIGPOLL/SIGIO). |
|
6587 |
||
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6588 |
Currently, this mechanism does work for SYSV4 only ..." |
616 | 6589 |
|
6590 |
%{ /* NOCONTEXT */ |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
6591 |
#if defined(SYSV4) && defined(USE_SIGIO) && 0 |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6592 |
|
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6593 |
# if defined(SIGPOLL) || defined(SIGIO) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6594 |
# 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
|
6595 |
/* |
765
93bdb4f0e095
no, SIGIO does not work on SGI ...
Claus Gittinger <cg@exept.de>
parents:
764
diff
changeset
|
6596 |
* 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
|
6597 |
* (not even on SGI ...) |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6598 |
*/ |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6599 |
# if !defined(NEXT) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6600 |
RETURN (true); |
616 | 6601 |
# endif |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6602 |
# endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6603 |
# endif |
616 | 6604 |
|
10 | 6605 |
#endif |
831 | 6606 |
%}. |
13 | 6607 |
^ false |
123 | 6608 |
! |
6609 |
||
616 | 6610 |
supportsNonBlockingIO |
6611 |
"return true, if the OS supports nonblocking IO." |
|
6612 |
||
6613 |
%{ /* NOCONTEXT */ |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6614 |
#if defined(F_GETFL) && defined(F_SETFL) && defined(FNDELAY) |
616 | 6615 |
RETURN (true); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6616 |
#endif |
831 | 6617 |
%}. |
616 | 6618 |
^ false |
123 | 6619 |
! |
6620 |
||
616 | 6621 |
supportsSelect |
6622 |
"return true, if the OS supports selecting on multiple |
|
6623 |
filedescriptors via select." |
|
6624 |
||
6625 |
%{ /* NOCONTEXT */ |
|
831 | 6626 |
#if defined(WIN32) |
6627 |
RETURN (false); |
|
6628 |
#endif |
|
616 | 6629 |
#if defined(sco) |
6630 |
/* |
|
831 | 6631 |
* sco has a select, but its broken: always waiting 1 second |
616 | 6632 |
*/ |
6633 |
RETURN(false); |
|
6634 |
#endif |
|
6635 |
%} |
|
6636 |
. |
|
6637 |
^ true |
|
6638 |
! ! |
|
6639 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
6640 |
!OperatingSystem class methodsFor:'shared memory access'! |
616 | 6641 |
|
6642 |
shmAttach:id address:addr flags:flags |
|
1247 | 6643 |
"low level entry to shmat()-system call. |
6644 |
Not supported on all operatingSystems" |
|
6645 |
||
616 | 6646 |
%{ /* NOCONTEXT */ |
6647 |
#ifdef WANT_SHM |
|
6648 |
void *address, *shmaddr; |
|
6649 |
int shmflg, shmid; |
|
6650 |
||
6651 |
if (__isSmallInteger(addr) |
|
6652 |
&& __bothSmallInteger(flags, id)) { |
|
1487 | 6653 |
shmaddr = (void *) __intVal(addr); |
6654 |
shmflg = __intVal(flags); |
|
6655 |
shmid = __intVal(id); |
|
6656 |
||
6657 |
address = shmat(shmid, shmaddr, shmflg); |
|
6658 |
if (address != (void *)-1) { |
|
6659 |
RETURN (__MKEXTERNALBYTES(addr)); |
|
6660 |
} |
|
6661 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
|
6662 |
RETURN (nil); |
|
616 | 6663 |
} |
6664 |
#endif |
|
6665 |
%}. |
|
792 | 6666 |
^ self primitiveFailed |
1247 | 6667 |
|
6668 |
"Modified: 22.4.1996 / 13:15:12 / cg" |
|
370 | 6669 |
! |
6670 |
||
616 | 6671 |
shmDetach:addr |
1247 | 6672 |
"low level entry to shmdt()-system call. |
6673 |
Not supported on all operatingSystems" |
|
6674 |
||
616 | 6675 |
%{ /* NOCONTEXT */ |
6676 |
#ifdef WANT_SHM |
|
6677 |
void *shmaddr; |
|
6678 |
int rslt; |
|
6679 |
||
6680 |
if (__isSmallInteger(addr)) { |
|
1487 | 6681 |
shmaddr = (void *) __intVal(addr); |
6682 |
||
6683 |
rslt = shmdt(shmaddr); |
|
6684 |
if (rslt != -1) { |
|
6685 |
RETURN (true); |
|
6686 |
} |
|
6687 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
|
6688 |
RETURN (false); |
|
370 | 6689 |
} |
616 | 6690 |
#endif |
6691 |
%}. |
|
792 | 6692 |
^ self primitiveFailed |
1247 | 6693 |
|
6694 |
"Modified: 22.4.1996 / 13:15:03 / cg" |
|
616 | 6695 |
! |
6696 |
||
6697 |
shmGet:key size:size flags:flags |
|
1247 | 6698 |
"low level entry to shmget()-system call. |
6699 |
This is not for public use and not supported with all operatingSystems. |
|
616 | 6700 |
- use the provided wrapper class SharedExternalBytes instead." |
6701 |
||
6702 |
%{ /* NOCONTEXT */ |
|
6703 |
#ifdef WANT_SHM |
|
6704 |
if (__bothSmallInteger(key, size) |
|
6705 |
&& __isSmallInteger(flags)) { |
|
1487 | 6706 |
int rslt; |
6707 |
||
6708 |
rslt = shmget(__intVal(key), __intVal(size), __intVal(flags)); |
|
6709 |
if (rslt != -1) { |
|
6710 |
RETURN (__MKSMALLINT(rslt)); |
|
6711 |
} |
|
6712 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
|
6713 |
RETURN (nil); |
|
616 | 6714 |
} |
6715 |
#endif |
|
370 | 6716 |
%}. |
792 | 6717 |
^ self primitiveFailed |
1247 | 6718 |
|
6719 |
"Modified: 22.4.1996 / 13:14:46 / cg" |
|
1 | 6720 |
! ! |
6721 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
6722 |
!OperatingSystem class methodsFor:'time and date'! |
1 | 6723 |
|
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6724 |
computeDatePartsOf:osTime for:aBlock |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6725 |
"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
|
6726 |
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
|
6727 |
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
|
6728 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6729 |
|year month day osSeconds| |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6730 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6731 |
osSeconds := osTime // 1000. |
1 | 6732 |
%{ |
6733 |
struct tm *tmPtr; |
|
6734 |
long t; |
|
6735 |
||
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6736 |
t = __longIntVal(osSeconds); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6737 |
|
1 | 6738 |
tmPtr = localtime(&t); |
1135 | 6739 |
year = __MKSMALLINT(tmPtr->tm_year + 1900); |
6740 |
month = __MKSMALLINT(tmPtr->tm_mon + 1); |
|
6741 |
day = __MKSMALLINT(tmPtr->tm_mday); |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6742 |
%}. |
1 | 6743 |
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
|
6744 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6745 |
" |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6746 |
OperatingSystem computeDatePartsOf:0 for:[:y :m :d | |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
6747 |
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
|
6748 |
] |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6749 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6750 |
! |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6751 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6752 |
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
|
6753 |
"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
|
6754 |
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
|
6755 |
any daylight saving adjustings." |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6756 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6757 |
|osSeconds| |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6758 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6759 |
%{ |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6760 |
struct tm tm; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6761 |
long t; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6762 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6763 |
if (__bothSmallInteger(y, m) |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6764 |
&& __bothSmallInteger(d, h) |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6765 |
&& __bothSmallInteger(min, s)) { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6766 |
tm.tm_hour = __intVal(h); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6767 |
tm.tm_min = __intVal(min); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6768 |
tm.tm_sec = __intVal(s); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6769 |
|
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6770 |
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
|
6771 |
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
|
6772 |
tm.tm_mday = __intVal(d); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6773 |
tm.tm_isdst = -1; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6774 |
|
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6775 |
t = mktime(&tm); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6776 |
osSeconds = __MKUINT(t); |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6777 |
} |
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 |
osSeconds notNil ifTrue:[ |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6780 |
^ osSeconds * 1000 + millis |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6781 |
]. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6782 |
^ self primitiveFailed |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6783 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6784 |
" |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6785 |
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
|
6786 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6787 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6788 |
! |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6789 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6790 |
computeTimeAndDateFrom:osTime |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6791 |
"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
|
6792 |
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
|
6793 |
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
|
6794 |
dayInYear (1..) and dayInWeek (1..). |
616 | 6795 |
Conversion is to localtime including any daylight saving adjustments." |
6796 |
||
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6797 |
|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
|
6798 |
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
|
6799 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6800 |
millis := osTime \\ 1000. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6801 |
osSeconds := osTime // 1000. |
63 | 6802 |
%{ |
6803 |
struct tm *tmPtr; |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6804 |
struct tm *gmTmPtr; |
63 | 6805 |
long t; |
6806 |
||
2073 | 6807 |
#if defined(HAS_NO_TIMEZONE) |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6808 |
# define TIMEZONE tmPtr->tm_gmtoff |
811 | 6809 |
#else |
831 | 6810 |
# ifdef MSDOS_LIKE |
1487 | 6811 |
# define TIMEZONE 0 |
831 | 6812 |
# else |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6813 |
# define TIMEZONE timezone |
831 | 6814 |
# endif |
811 | 6815 |
#endif |
6816 |
||
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6817 |
t = __longIntVal(osSeconds); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6818 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6819 |
tmPtr = localtime(&t); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6820 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6821 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6822 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6823 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6824 |
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
|
6825 |
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
|
6826 |
day = __MKSMALLINT(tmPtr->tm_mday); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6827 |
|
1511
823fcfbbb741
weekDay/yearDay start with0 in tm_ struct, but
Claus Gittinger <cg@exept.de>
parents:
1510
diff
changeset
|
6828 |
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
|
6829 |
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
|
6830 |
|
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6831 |
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
|
6832 |
dst = false; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6833 |
utcOffset = __MKSMALLINT(TIMEZONE); |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6834 |
} else { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6835 |
dst = true; |
800
067094efdaed
use HAS_ALTZONE / HAS_DAYLIGHT
Claus Gittinger <cg@exept.de>
parents:
798
diff
changeset
|
6836 |
#ifdef HAS_ALTZONE |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6837 |
utcOffset = __MKSMALLINT(altzone); |
800
067094efdaed
use HAS_ALTZONE / HAS_DAYLIGHT
Claus Gittinger <cg@exept.de>
parents:
798
diff
changeset
|
6838 |
#else |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6839 |
utcOffset = __MKSMALLINT(TIMEZONE) + 3600; |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6840 |
#endif |
63 | 6841 |
} |
241 | 6842 |
%}. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6843 |
"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
|
6844 |
ret := Array new:11. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6845 |
ret at:1 put:year. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6846 |
ret at:2 put:month. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6847 |
ret at:3 put:day. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6848 |
ret at:4 put:hours. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6849 |
ret at:5 put:minutes. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6850 |
ret at:6 put:seconds. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6851 |
ret at:7 put:utcOffset. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6852 |
ret at:8 put:dst. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6853 |
ret at:9 put:millis. |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6854 |
ret at:10 put:yDay. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6855 |
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
|
6856 |
^ ret |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6857 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6858 |
" |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6859 |
OperatingSystem computeTimeAndDateFrom:0 |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6860 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6861 |
! |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6862 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6863 |
computeTimePartsOf:osTime for:aBlock |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6864 |
"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
|
6865 |
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
|
6866 |
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
|
6867 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6868 |
|hours minutes seconds millis osSeconds| |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6869 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6870 |
osSeconds := osTime // 1000. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6871 |
millis := osTime \\ 1000. |
616 | 6872 |
%{ |
6873 |
struct tm *tmPtr; |
|
6874 |
long t; |
|
6875 |
||
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6876 |
t = __longIntVal(osSeconds); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6877 |
|
616 | 6878 |
tmPtr = localtime(&t); |
1135 | 6879 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
6880 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
|
6881 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6882 |
%}. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6883 |
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
|
6884 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6885 |
" |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6886 |
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
|
6887 |
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
|
6888 |
] |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6889 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6890 |
! |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6891 |
|
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6892 |
computeUTCTimeAndDateFrom:osTime |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6893 |
"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
|
6894 |
containing year, month, day, hour, minute and seconds, |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6895 |
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
|
6896 |
dayInYear (1..) and dayInWeek (1..). |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6897 |
Conversion is to UTC." |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6898 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6899 |
|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
|
6900 |
dst yDay wDay osSeconds ret| |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6901 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6902 |
millis := osTime \\ 1000. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6903 |
osSeconds := osTime // 1000. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6904 |
%{ |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6905 |
struct tm *tmPtr; |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6906 |
struct tm *gmTmPtr; |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6907 |
long t; |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6908 |
|
2073 | 6909 |
#if defined(HAS_NO_TIMEZONE) |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6910 |
# define TIMEZONE tmPtr->tm_gmtoff |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6911 |
#else |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6912 |
# ifdef MSDOS_LIKE |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6913 |
# define TIMEZONE 0 |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6914 |
# else |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6915 |
# define TIMEZONE timezone |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6916 |
# endif |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6917 |
#endif |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6918 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6919 |
t = __longIntVal(osSeconds); |
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 |
tmPtr = gmtime(&t); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6922 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6923 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6924 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6925 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6926 |
year = __MKSMALLINT(tmPtr->tm_year + 1900); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6927 |
month = __MKSMALLINT(tmPtr->tm_mon + 1); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6928 |
day = __MKSMALLINT(tmPtr->tm_mday); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6929 |
|
1511
823fcfbbb741
weekDay/yearDay start with0 in tm_ struct, but
Claus Gittinger <cg@exept.de>
parents:
1510
diff
changeset
|
6930 |
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
|
6931 |
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
|
6932 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6933 |
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
|
6934 |
dst = false; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6935 |
utcOffset = __MKSMALLINT(TIMEZONE); |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6936 |
} else { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6937 |
dst = true; |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6938 |
#ifdef HAS_ALTZONE |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6939 |
utcOffset = __MKSMALLINT(altzone); |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6940 |
#else |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6941 |
utcOffset = __MKSMALLINT(TIMEZONE) + 3600; |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6942 |
#endif |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6943 |
} |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6944 |
%}. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6945 |
"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
|
6946 |
ret := Array new:11. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6947 |
ret at:1 put:year. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6948 |
ret at:2 put:month. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6949 |
ret at:3 put:day. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6950 |
ret at:4 put:hours. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6951 |
ret at:5 put:minutes. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6952 |
ret at:6 put:seconds. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6953 |
ret at:7 put:utcOffset. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6954 |
ret at:8 put:dst. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6955 |
ret at:9 put:millis. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6956 |
ret at:10 put:yDay. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6957 |
ret at:11 put:wDay. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6958 |
^ ret |
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 |
OperatingSystem computeUTCTimeAndDateFrom:0 |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6962 |
" |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6963 |
! |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6964 |
|
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6965 |
computeUTCTimePartsOf:osTime for:aBlock |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6966 |
"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
|
6967 |
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
|
6968 |
Conversion is to UTC." |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6969 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6970 |
|hours minutes seconds millis osSeconds| |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6971 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6972 |
osSeconds := osTime // 1000. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6973 |
millis := osTime \\ 1000. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6974 |
%{ |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6975 |
struct tm *tmPtr; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6976 |
long t; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6977 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6978 |
t = __longIntVal(osSeconds); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6979 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6980 |
tmPtr = gmtime(&t); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6981 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6982 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6983 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6984 |
%}. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6985 |
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
|
6986 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6987 |
" |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6988 |
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
|
6989 |
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
|
6990 |
] |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6991 |
" |
275 | 6992 |
! |
6993 |
||
1 | 6994 |
getMillisecondTime |
185 | 6995 |
"This returns the millisecond timers value. |
6996 |
The range is limited to 0..1fffffff (i.e. the SmallInteger range) to avoid |
|
6997 |
LargeInteger arithmetic when doing timeouts and delays. |
|
792 | 6998 |
Since this value is wrapping around in regular intervals, this can only be used for |
185 | 6999 |
short relative time deltas. |
7000 |
Use the millisecondTimeXXX:-methods to compare and add time deltas - these know about the wrap. |
|
7001 |
||
7002 |
BAD DESIGN: |
|
7003 |
This should be changed to return some instance of RelativeTime, |
|
7004 |
and these computations moved there. |
|
95 | 7005 |
|
7006 |
Dont use this method in application code since it is an internal (private) |
|
7007 |
interface. For compatibility with ST-80, use Time millisecondClockValue. |
|
7008 |
" |
|
1 | 7009 |
|
7010 |
%{ /* NOCONTEXT */ |
|
7011 |
||
7012 |
long t; |
|
185 | 7013 |
#if !defined(HAS_GETTIMEOFDAY) && defined(SYSV) && defined(HZ) |
7014 |
/* |
|
7015 |
* sys5 time |
|
7016 |
*/ |
|
1 | 7017 |
long ticks; |
7018 |
struct tms tb; |
|
7019 |
||
7020 |
ticks = times(&tb); |
|
7021 |
t = (ticks * 1000) / HZ; |
|
792 | 7022 |
#else |
1632 | 7023 |
# ifdef WIN32 |
7024 |
t = GetTickCount(); |
|
7025 |
# else |
|
7026 |
# ifdef MSDOS_LIKE |
|
792 | 7027 |
struct _timeb timebuffer; |
7028 |
||
7029 |
_ftime(&timebuffer); |
|
7030 |
t = (timebuffer.time * 1000) + timebuffer.millitm; |
|
1632 | 7031 |
# else /* assume HAS_GETTIMEOFDAY */ |
185 | 7032 |
/* |
7033 |
* bsd time |
|
7034 |
*/ |
|
1 | 7035 |
struct timeval tb; |
7036 |
struct timezone tzb; |
|
7037 |
||
7038 |
gettimeofday(&tb, &tzb); |
|
7039 |
t = tb.tv_sec*1000 + tb.tv_usec/1000; |
|
1632 | 7040 |
# endif |
792 | 7041 |
# endif |
68 | 7042 |
#endif |
1135 | 7043 |
RETURN ( __MKSMALLINT(t & 0x1FFFFFFF) ); |
1 | 7044 |
%} |
7045 |
! |
|
7046 |
||
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7047 |
getOSTime |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7048 |
"This returns the millisecond OS time. |
2000 | 7049 |
The base of the returned value is not consistent across |
7050 |
different OS's - some return the number of millis since jan, 1st 1970; |
|
7051 |
others since 1900. The Time classes are prepared for this, and |
|
7052 |
convert as appropriate. |
|
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7053 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7054 |
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
|
7055 |
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
|
7056 |
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
|
7057 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7058 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7059 |
|seconds millis| |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7060 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7061 |
%{ |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7062 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7063 |
long t; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7064 |
#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
|
7065 |
/* |
2000 | 7066 |
* sys5 time; we have to fake the information |
7067 |
* 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
|
7068 |
*/ |
616 | 7069 |
int now; |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7070 |
long ticks; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7071 |
struct tms tb; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7072 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7073 |
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
|
7074 |
seconds = __MKUINT(now); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7075 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7076 |
ticks = times(&tb); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7077 |
t = (ticks * 1000) / HZ; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7078 |
t = t % 1000; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7079 |
millis = __MKSMALLINT(t); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7080 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7081 |
#else |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7082 |
# ifdef MSDOS_LIKE |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7083 |
struct _timeb timebuffer; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7084 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7085 |
_ftime(&timebuffer); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7086 |
seconds = __MKUINT(timebuffer.time); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7087 |
millis = __MKSMALLINT(timebuffer.millitm); |
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 |
# else /* assume HAS_GETTIMEOFDAY */ |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7090 |
/* |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7091 |
* bsd time |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7092 |
*/ |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7093 |
struct timeval tb; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7094 |
struct timezone tzb; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7095 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7096 |
gettimeofday(&tb, &tzb); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7097 |
seconds = __MKUINT(tb.tv_sec); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7098 |
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
|
7099 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7100 |
# endif |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7101 |
#endif |
831 | 7102 |
%}. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7103 |
^ (seconds * 1000) + millis |
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 |
" |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
7106 |
OperatingSystem getOSTime printCR. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7107 |
Delay waitForSeconds:0.2. |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
7108 |
OperatingSystem getOSTime printCR. |
831 | 7109 |
" |
616 | 7110 |
! |
7111 |
||
7112 |
maximumMillisecondTimeDelta |
|
7113 |
"this returns the maximum delta supported by millisecondCounter |
|
7114 |
based methods. The returned value is half the value at which the |
|
7115 |
timer wraps." |
|
7116 |
||
7117 |
%{ /* NOCONTEXT */ |
|
1135 | 7118 |
RETURN ( __MKSMALLINT(0x0FFFFFFF) ); |
616 | 7119 |
%} |
7120 |
! |
|
7121 |
||
7122 |
millisecondDelay:millis |
|
7123 |
"delay execution for millis milliseconds or until the next event |
|
7124 |
arrives. |
|
7125 |
All lower priority threads will also sleep for the duration, |
|
7126 |
interrupts (and therefore, higher prio processes) are |
|
7127 |
still handled. |
|
7128 |
Better use a Delay, to only delay the calling thread. |
|
7129 |
(however, a delay cannot be used in the event handler or scheduler)" |
|
7130 |
||
7131 |
|now then delta| |
|
7132 |
||
831 | 7133 |
%{ /* NOCONTEXT */ |
7134 |
#ifdef WIN32 |
|
7135 |
int t = __intVal(millis); |
|
7136 |
||
7137 |
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
|
7138 |
Sleep(t); |
831 | 7139 |
} |
7140 |
RETURN (self); |
|
7141 |
#endif |
|
7142 |
%}. |
|
7143 |
||
616 | 7144 |
now := OperatingSystem getMillisecondTime. |
7145 |
then := OperatingSystem millisecondTimeAdd:now and:millis. |
|
7146 |
||
7147 |
[OperatingSystem millisecondTime:then isAfter:now] whileTrue:[ |
|
7148 |
delta := OperatingSystem millisecondTimeDeltaBetween:then and:now. |
|
7149 |
self selectOnAnyReadable:nil writable:nil exception:nil withTimeOut:delta. |
|
7150 |
now := OperatingSystem getMillisecondTime. |
|
7151 |
] |
|
7152 |
||
7153 |
" |
|
7154 |
OperatingSystem millisecondDelay:2000 |
|
7155 |
" |
|
7156 |
! |
|
7157 |
||
7158 |
millisecondTime:msTime1 isAfter:msTime2 |
|
7159 |
"return true if msTime1 is after msTime2, false if not. |
|
7160 |
The two arguments are supposed to be millisecond times |
|
7161 |
(such as returned getMillisecondTime) which wrap at 16r1FFFFFFF. |
|
7162 |
||
7163 |
This should really be moved to some RelativeTime class." |
|
7164 |
||
7165 |
(msTime1 > msTime2) ifTrue:[ |
|
7166 |
((msTime1 - msTime2) >= 16r10000000) ifTrue:[ |
|
7167 |
^ false |
|
7168 |
]. |
|
7169 |
^ true |
|
7170 |
]. |
|
7171 |
((msTime2 - msTime1) > 16r10000000) ifTrue:[ |
|
7172 |
^ true |
|
7173 |
]. |
|
7174 |
^ false |
|
7175 |
! |
|
7176 |
||
7177 |
millisecondTimeAdd:msTime1 and:msTime2 |
|
7178 |
"Add two millisecond times (such as returned getMillisecondTime). |
|
7179 |
The returned value is msTime1 + msTime2 where a wrap occurs at:16r1FFFFFFF. |
|
7180 |
||
7181 |
This should really be moved to some RelativeTime class." |
|
7182 |
||
7183 |
|sum| |
|
7184 |
||
7185 |
sum := msTime1 + msTime2. |
|
7186 |
(sum > 16r1FFFFFFF) ifTrue:[^ sum - 16r20000000]. |
|
7187 |
(sum < 0) ifTrue:[^ sum + 16r20000000]. |
|
7188 |
^ sum |
|
7189 |
! |
|
7190 |
||
1 | 7191 |
millisecondTimeDeltaBetween:msTime1 and:msTime2 |
95 | 7192 |
"subtract two millisecond times (such as returned getMillisecondTime) |
185 | 7193 |
and return the difference. Since milli-times wrap (at 16r01FFFFFFF), |
95 | 7194 |
some special handling is built-in here. |
185 | 7195 |
The returned value is msTime1 - msTime2. The returned value is invalid |
7196 |
if the delta is >= 0x10000000. |
|
63 | 7197 |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
7198 |
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
|
7199 |
better yet: create a subclass of Integer named LimitedRangeInteger." |
1 | 7200 |
|
7201 |
(msTime1 > msTime2) ifTrue:[ |
|
185 | 7202 |
^ msTime1 - msTime2 |
1 | 7203 |
]. |
7204 |
^ msTime1 + 16r10000000 - msTime2 |
|
95 | 7205 |
|
7206 |
" |
|
7207 |
OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:1 |
|
7208 |
OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:(16 / 3) |
|
7209 |
OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:1000 |
|
7210 |
||
7211 |
OperatingSystem millisecondTimeDeltaBetween:0 and:16r0FFFFFFF |
|
7212 |
OperatingSystem millisecondTimeDeltaBetween:(13/3) and:16r0FFFFFFF |
|
7213 |
OperatingSystem millisecondTimeDeltaBetween:999 and:16r0FFFFFFF |
|
7214 |
||
7215 |
OperatingSystem millisecondTime:0 isAfter:16r0FFFFFFF |
|
7216 |
OperatingSystem millisecondTime:(13/3) isAfter:16r0FFFFFFF |
|
7217 |
OperatingSystem millisecondTime:999 isAfter:16r0FFFFFFF |
|
7218 |
||
7219 |
OperatingSystem millisecondTime:0 isAfter:0 |
|
7220 |
OperatingSystem millisecondTime:(13/3) isAfter:0 |
|
7221 |
OperatingSystem millisecondTime:999 isAfter:0 |
|
7222 |
||
7223 |
OperatingSystem millisecondTime:1 isAfter:0 |
|
7224 |
OperatingSystem millisecondTime:(13/3) isAfter:2 |
|
7225 |
OperatingSystem millisecondTime:999 isAfter:900 |
|
7226 |
||
7227 |
|t1 t2| |
|
7228 |
||
7229 |
t1 := Time millisecondClockValue. |
|
7230 |
(Delay forMilliseconds:1) wait. |
|
7231 |
t2 := Time millisecondClockValue. |
|
7232 |
OperatingSystem millisecondTimeDeltaBetween:t2 and:t1 |
|
7233 |
" |
|
1 | 7234 |
! |
7235 |
||
7236 |
sleep:numberOfSeconds |
|
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7237 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7238 |
|
308 | 7239 |
"cease ANY action for some time. This suspends the whole smalltalk |
7240 |
(unix-) process for some time. |
|
1 | 7241 |
Not really useful since not even low-prio processes and interrupt |
95 | 7242 |
handling will run during the sleep. |
7243 |
Use either OperatingSystem>>millisecondDelay: (which makes all |
|
7244 |
threads sleep, but handles interrupts) or use a Delay (which makes |
|
7245 |
only the calling thread sleep)." |
|
1 | 7246 |
|
7247 |
%{ /* NOCONTEXT */ |
|
7248 |
||
252 | 7249 |
if (__isSmallInteger(numberOfSeconds)) { |
1135 | 7250 |
sleep(__intVal(numberOfSeconds)); |
185 | 7251 |
RETURN ( self ); |
1 | 7252 |
} |
68 | 7253 |
%}. |
7254 |
" |
|
7255 |
argument not integer |
|
7256 |
" |
|
792 | 7257 |
^ self primitiveFailed |
95 | 7258 |
|
7259 |
" |
|
7260 |
OperatingSystem sleep:2 |
|
7261 |
" |
|
10 | 7262 |
! ! |
7263 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
7264 |
!OperatingSystem class methodsFor:'users & groups'! |
616 | 7265 |
|
7266 |
getEffectiveGroupID |
|
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7267 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7268 |
|
616 | 7269 |
"return the current users (thats you) effective numeric group id. |
7270 |
This is only different from getGroupID, if you have ST/X running |
|
7271 |
as a setuid program (of which you should think about twice)." |
|
7272 |
||
7273 |
%{ /* NOCONTEXT */ |
|
7274 |
||
7275 |
#ifdef UNIX_LIKE |
|
7276 |
int uid; |
|
7277 |
||
7278 |
uid = getegid(); |
|
7279 |
RETURN ( __MKSMALLINT(uid) ); |
|
7280 |
#endif |
|
7281 |
/* --- return same as getGroupID --- */ |
|
7282 |
%}. |
|
7283 |
^ self getGroupID |
|
7284 |
||
7285 |
" |
|
7286 |
OperatingSystem getEffectiveGroupID |
|
7287 |
" |
|
7288 |
! |
|
7289 |
||
7290 |
getEffectiveUserID |
|
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7291 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7292 |
|
616 | 7293 |
"return the current users (thats you) effective numeric user id. |
7294 |
This is only different from getUserID, if you have ST/X running |
|
7295 |
as a setuid program (of which you should think about twice)." |
|
10 | 7296 |
|
7297 |
%{ /* NOCONTEXT */ |
|
7298 |
||
616 | 7299 |
#ifdef UNIX_LIKE |
7300 |
int uid; |
|
7301 |
||
7302 |
uid = geteuid(); |
|
7303 |
RETURN ( __MKSMALLINT(uid) ); |
|
7304 |
#endif |
|
7305 |
/* --- return same as getUserID --- */ |
|
7306 |
%}. |
|
7307 |
^ self getUserID |
|
7308 |
||
7309 |
" |
|
7310 |
OperatingSystem getEffectiveUserID |
|
7311 |
" |
|
7312 |
! |
|
7313 |
||
1549
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7314 |
getFullUserNameFromID:userID |
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7315 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7316 |
|
1549
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7317 |
"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
|
7318 |
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
|
7319 |
|
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7320 |
|info gecos| |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7321 |
|
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7322 |
info := self userInfoOf:userID. |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7323 |
(info notNil |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7324 |
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
|
7325 |
gecos := info at:#gecos. |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7326 |
(gecos includes:$,) ifTrue:[ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7327 |
^ gecos copyTo:(gecos indexOf:$,) - 1 |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7328 |
]. |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7329 |
^ gecos |
1549
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7330 |
]. |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7331 |
^ self getUserNameFromID:userID |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7332 |
|
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7333 |
" |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7334 |
OperatingSystem getFullUserNameFromID:0 |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7335 |
OperatingSystem getFullUserNameFromID:(OperatingSystem getUserID) |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7336 |
|
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7337 |
OperatingSystem getUserNameFromID:(OperatingSystem getUserID) |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7338 |
" |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7339 |
|
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7340 |
"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
|
7341 |
! |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7342 |
|
616 | 7343 |
getGroupID |
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7344 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7345 |
|
616 | 7346 |
"return the current users (thats you) numeric group id" |
7347 |
||
7348 |
%{ /* NOCONTEXT */ |
|
7349 |
||
7350 |
#ifdef UNIX_LIKE |
|
7351 |
int uid; |
|
7352 |
||
7353 |
uid = getgid(); |
|
7354 |
RETURN ( __MKSMALLINT(uid) ); |
|
7355 |
#else |
|
7356 |
# ifdef SYSTEM_HAS_GROUPS |
|
7357 |
/* ... */ |
|
10 | 7358 |
# endif |
7359 |
#endif |
|
68 | 7360 |
%}. |
616 | 7361 |
^ 1 "just a dummy for systems which do not have userIDs" |
7362 |
||
68 | 7363 |
" |
616 | 7364 |
OperatingSystem getGroupID |
7365 |
" |
|
7366 |
! |
|
7367 |
||
7368 |
getGroupNameFromID:aNumber |
|
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7369 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7370 |
|
616 | 7371 |
"return the group-name-string for a given numeric group-id" |
7372 |
||
7373 |
%{ /* NOCONTEXT */ |
|
7374 |
||
7375 |
#ifdef UNIX_LIKE |
|
7376 |
struct group *g; |
|
7377 |
||
7378 |
if (__isSmallInteger(aNumber)) { |
|
1135 | 7379 |
g = getgrgid(__intVal(aNumber)); |
616 | 7380 |
if (g) { |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7381 |
RETURN ( __MKSTRING(g->gr_name) ); |
616 | 7382 |
} |
7383 |
} |
|
7384 |
#endif |
|
7385 |
%}. |
|
7386 |
^ '???' |
|
7387 |
||
7388 |
" |
|
7389 |
OperatingSystem getGroupNameFromID:0 |
|
7390 |
OperatingSystem getGroupNameFromID:10 |
|
7391 |
" |
|
7392 |
! |
|
7393 |
||
7394 |
getHomeDirectory |
|
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7395 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7396 |
|
616 | 7397 |
"return the name of the users home directory" |
7398 |
||
7399 |
^ OperatingSystem getEnvironment:'HOME' |
|
7400 |
||
7401 |
" |
|
7402 |
OperatingSystem getHomeDirectory |
|
7403 |
" |
|
7404 |
! |
|
7405 |
||
7406 |
getLoginName |
|
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7407 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7408 |
|
1549
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7409 |
"return a string with the users login name" |
616 | 7410 |
|
7411 |
%{ /* NOCONTEXT */ |
|
7412 |
static char cachedName[64]; |
|
7413 |
static firstCall = 1; |
|
7414 |
||
831 | 7415 |
char *name = (char *)0; |
616 | 7416 |
#ifdef UNIX_LIKE |
7417 |
if (firstCall) { |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7418 |
name = (char *)getlogin(); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7419 |
if (! name || (name[0] == 0)) { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7420 |
name = (char *)getenv("LOGNAME"); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7421 |
} |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7422 |
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
|
7423 |
strcpy(cachedName, name); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7424 |
firstCall = 0; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7425 |
} |
616 | 7426 |
} else { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7427 |
name = cachedName; |
616 | 7428 |
} |
831 | 7429 |
#else |
1632 | 7430 |
# ifdef WIN32 |
831 | 7431 |
if (firstCall) { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7432 |
int nameSize = sizeof(cachedName); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7433 |
|
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7434 |
if (GetUserName(cachedName, &nameSize) == TRUE) { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7435 |
name = cachedName; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7436 |
firstCall = 0; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7437 |
} |
831 | 7438 |
} else { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7439 |
name = cachedName; |
831 | 7440 |
} |
7441 |
# endif |
|
7442 |
#endif |
|
7443 |
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
|
7444 |
name = (char *)getenv("LOGNAME"); |
831 | 7445 |
} |
7446 |
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
|
7447 |
name = "you"; |
831 | 7448 |
} |
7449 |
||
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7450 |
RETURN ( __MKSTRING(name) ); |
831 | 7451 |
%}. |
616 | 7452 |
" |
7453 |
OperatingSystem getLoginName |
|
7454 |
" |
|
7455 |
! |
|
7456 |
||
7457 |
getUserID |
|
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7458 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7459 |
|
616 | 7460 |
"return the current users (thats you) numeric user id" |
7461 |
||
7462 |
%{ /* NOCONTEXT */ |
|
7463 |
||
7464 |
#ifdef UNIX_LIKE |
|
7465 |
int uid; |
|
7466 |
||
7467 |
uid = getuid(); |
|
7468 |
RETURN ( __MKSMALLINT(uid) ); |
|
7469 |
#else |
|
7470 |
# ifdef SYSTEM_HAS_USERS |
|
7471 |
/* ... */ |
|
7472 |
# endif |
|
7473 |
#endif |
|
7474 |
%}. |
|
7475 |
^ 1 "just a dummy for systems which do not have userIDs" |
|
7476 |
||
7477 |
" |
|
7478 |
OperatingSystem getUserID |
|
68 | 7479 |
" |
616 | 7480 |
! |
7481 |
||
7482 |
getUserNameFromID:aNumber |
|
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7483 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7484 |
|
1549
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7485 |
"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
|
7486 |
This is the login name, not the fullName." |
616 | 7487 |
|
7488 |
%{ /* NOCONTEXT */ |
|
7489 |
||
7490 |
#ifdef UNIX_LIKE |
|
7491 |
struct passwd *p; |
|
7492 |
||
7493 |
if (__isSmallInteger(aNumber)) { |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7494 |
p = getpwuid(__intVal(aNumber)); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7495 |
if (p) { |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7496 |
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
|
7497 |
} |
616 | 7498 |
} |
7499 |
#endif |
|
7500 |
%}. |
|
7501 |
^ '? (' , aNumber printString , ')' |
|
7502 |
||
7503 |
" |
|
7504 |
OperatingSystem getUserNameFromID:0 |
|
7505 |
OperatingSystem getUserNameFromID:100 |
|
7506 |
OperatingSystem getUserNameFromID:9991 |
|
7507 |
" |
|
1 | 7508 |
! |
7509 |
||
616 | 7510 |
userInfoOf:aNameOrID |
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7511 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7512 |
|
616 | 7513 |
"return a dictionary filled with userinfo. The argument can be either |
7514 |
a string with the users name or its numeric id. |
|
7515 |
Notice, that not all systems provide (all of) this info; |
|
7516 |
DOS systems return nothing; |
|
7517 |
non-SYSV4 systems have no age/comment. |
|
7518 |
Portable applications may want to check the systemType and NOT depend |
|
7519 |
on all keys to be present in the returned dictionary. |
|
7520 |
Another notice: on some systems (SYSV4), the gecos field includes multiple |
|
7521 |
entries (i.e. not just the name), separated by commas. You may want to |
|
7522 |
extract any substring, up to the first comma to get the real life name." |
|
7523 |
||
7524 |
|info name passw uid gid age comment |
|
7525 |
gecos dir shell| |
|
7526 |
||
7527 |
%{ |
|
7528 |
#ifdef UNIX_LIKE |
|
7529 |
struct passwd *buf; |
|
7530 |
int ret; |
|
7531 |
||
7532 |
if (__isString(aNameOrID)) { |
|
7533 |
buf = getpwnam(__stringVal(aNameOrID)); |
|
7534 |
} else if (__isSmallInteger(aNameOrID)) { |
|
7535 |
buf = getpwuid(__intVal(aNameOrID)); |
|
7536 |
} else { |
|
7537 |
buf = (struct passwd *)0; |
|
7538 |
} |
|
7539 |
if (buf) { |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7540 |
name = __MKSTRING(buf->pw_name); |
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7541 |
passw = __MKSTRING(buf->pw_passwd); |
616 | 7542 |
# ifdef SYSV4 |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7543 |
age = __MKSTRING(buf->pw_age); |
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7544 |
comment = __MKSTRING(buf->pw_comment); |
616 | 7545 |
# endif |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7546 |
dir = __MKSTRING(buf->pw_dir); |
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7547 |
gecos = __MKSTRING(buf->pw_gecos); |
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7548 |
shell = __MKSTRING(buf->pw_shell); |
616 | 7549 |
|
1135 | 7550 |
uid = __MKSMALLINT(buf->pw_uid); |
7551 |
gid = __MKSMALLINT(buf->pw_gid); |
|
616 | 7552 |
} |
7553 |
#endif |
|
7554 |
%}. |
|
7555 |
info := IdentityDictionary new. |
|
7556 |
name notNil ifTrue:[ |
|
7557 |
info at:#name put:name. |
|
7558 |
] ifFalse:[ |
|
7559 |
info at:#name put:'unknown' |
|
7560 |
]. |
|
7561 |
passw notNil ifTrue:[info at:#passwd put:passw]. |
|
7562 |
age notNil ifTrue:[info at:#age put:age]. |
|
7563 |
comment notNil ifTrue:[info at:#comment put:comment]. |
|
7564 |
gecos notNil ifTrue:[info at:#gecos put:gecos]. |
|
7565 |
shell notNil ifTrue:[info at:#shell put:shell]. |
|
7566 |
dir notNil ifTrue:[info at:#dir put:dir]. |
|
7567 |
uid notNil ifTrue:[info at:#uid put:uid]. |
|
7568 |
gid notNil ifTrue:[info at:#gid put:gid]. |
|
7569 |
^ info |
|
7570 |
||
7571 |
" |
|
7572 |
OperatingSystem userInfoOf:'root' |
|
7573 |
OperatingSystem userInfoOf:1 |
|
7574 |
OperatingSystem userInfoOf:'claus' |
|
7575 |
OperatingSystem userInfoOf:'fooBar' |
|
7576 |
OperatingSystem userInfoOf:(OperatingSystem getUserID) |
|
7577 |
" |
|
7578 |
! ! |
|
7579 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
7580 |
!OperatingSystem class methodsFor:'waiting for events'! |
616 | 7581 |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7582 |
blockingChildProcessWait |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7583 |
"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
|
7584 |
%{ /*NOCONTEXT*/ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7585 |
#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
|
7586 |
RETURN(false); |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7587 |
#else |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7588 |
RETURN(true); |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7589 |
#endif |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7590 |
%} |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7591 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7592 |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7593 |
childProcessWait:blocking |
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7594 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7595 |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7596 |
"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
|
7597 |
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
|
7598 |
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
|
7599 |
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
|
7600 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7601 |
|pid status code core| |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7602 |
%{ |
1597 | 7603 |
#ifdef UNIX_LIKE |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7604 |
int p; |
1653 | 7605 |
|
1597 | 7606 |
# if defined(HAS_WAITPID) |
1653 | 7607 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7608 |
int s; |
1653 | 7609 |
# define __WAIT waitpid(-1, &s, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED) |
7610 |
||
1597 | 7611 |
# else |
7612 |
# if defined(HAS_WAIT3) |
|
1653 | 7613 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7614 |
union wait s; |
1653 | 7615 |
# define __WAIT wait3(&s, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED, 0) |
7616 |
||
7617 |
# else /* neithe waitpid, nor wait3; use wait, which is blocking */ |
|
7618 |
||
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7619 |
int s; |
1653 | 7620 |
# define __WAIT wait(&s) |
7621 |
# define __BLOCKING_WAIT__ 1 |
|
1597 | 7622 |
|
1654 | 7623 |
if (blocking != true) { |
7624 |
/* |
|
7625 |
* We do not support nonBlocking waits, so signal an error |
|
7626 |
* Sorry about the goto, but with all these ifdefs ... |
|
7627 |
*/ |
|
7628 |
goto done; |
|
7629 |
} |
|
7630 |
# endif /*!HAS_WAIT3*/ |
|
7631 |
# endif /*!HAS_WAITPID*/ |
|
7632 |
||
2098
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7633 |
# if !defined(WIFEXITED) |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7634 |
# define WIFEXITED(stat) (((int)((stat)&0377))==0) |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7635 |
# 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
|
7636 |
# 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
|
7637 |
|
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7638 |
# define WEXITSTATUS(stat) ((int)(((stat)>>8)&0377)) |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7639 |
# define WTERMSIG(stat) (((int)((stat)&0377))&0177) |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7640 |
# define WSTOPSIG(stat) ((int)(((stat)>>8)&0377)) |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7641 |
# endif /*!WIFEXITED*/ |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7642 |
|
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7643 |
# if !defined(WCOREDUMP) |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7644 |
# define WCOREDUMP(stat) ((int)(((stat)>>8)&0200)) |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7645 |
# endif /*!WCOREDUMP*/ |
1597 | 7646 |
|
7647 |
# if __BLOCKING_WAIT__ |
|
1433 | 7648 |
__BEGIN_INTERRUPTABLE__ |
1597 | 7649 |
# endif |
1433 | 7650 |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7651 |
do { |
1487 | 7652 |
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
|
7653 |
} 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
|
7654 |
|
1597 | 7655 |
# if __BLOCKING_WAIT__ |
1433 | 7656 |
__END_INTERRUPTABLE__ |
1654 | 7657 |
# undef __BLOCKING_WAIT__ |
1597 | 7658 |
# endif |
7659 |
||
7660 |
# undef __WAIT |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7661 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7662 |
if (p == 0) |
1487 | 7663 |
RETURN(nil) |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7664 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7665 |
if (p == -1) { |
1487 | 7666 |
if (errno == ECHILD) |
7667 |
RETURN(nil); |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7668 |
} else { |
1487 | 7669 |
pid = __MKSMALLINT(p); |
7670 |
if (WIFEXITED(s)) { |
|
7671 |
status = @symbol(exit); |
|
7672 |
code = __MKSMALLINT(WEXITSTATUS(s)); |
|
7673 |
core = WCOREDUMP(s) ? true : false; |
|
7674 |
} else if (WIFSIGNALED(s)) { |
|
7675 |
status = @symbol(signal); |
|
7676 |
code = __MKSMALLINT(WTERMSIG(s)); |
|
7677 |
} else if (WIFSTOPPED(s)) { |
|
7678 |
status = @symbol(stop); |
|
7679 |
code = __MKSMALLINT(WSTOPSIG(s)); |
|
7680 |
} |
|
1597 | 7681 |
# if defined(WIFCONTINUED) |
1487 | 7682 |
else if (WIFCONTINUED(s)) { |
7683 |
status = @symbol(continue); |
|
7684 |
} |
|
1597 | 7685 |
# endif |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7686 |
} |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7687 |
done: ; |
1597 | 7688 |
#endif /* UNIX_LIKE */ |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7689 |
%}. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7690 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7691 |
pid isNil ifTrue:[ |
1487 | 7692 |
^ self primitiveFailed |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7693 |
]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7694 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7695 |
^ 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
|
7696 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7697 |
" |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7698 |
OperatingSystem childProcessWait:false |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7699 |
" |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7700 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7701 |
"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
|
7702 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7703 |
|
10 | 7704 |
readCheck:fd |
95 | 7705 |
"return true, if data is available on a filedescriptor (i.e. read |
7706 |
is possible without blocking)" |
|
10 | 7707 |
|
7708 |
(self selectOnAnyReadable:(Array with:fd) |
|
185 | 7709 |
writable:nil |
7710 |
exception:nil |
|
7711 |
withTimeOut:0) == fd |
|
7712 |
ifTrue:[^ true]. |
|
10 | 7713 |
^ false |
7714 |
! |
|
7715 |
||
616 | 7716 |
selectOn:fd1 and:fd2 withTimeOut:millis |
7717 |
"wait for any fd to become ready; timeout after t milliseconds. |
|
7718 |
A zero timeout-time will immediately return (i.e. poll). |
|
7719 |
Return fd if i/o ok, nil if timed-out or interrupted. |
|
7720 |
Obsolete: |
|
7721 |
This is a leftover method and will vanish." |
|
7722 |
||
7723 |
^ self selectOnAnyReadable:(Array with:fd1 with:fd2) |
|
7724 |
writable:(Array with:fd1 with:fd2) |
|
7725 |
exception:nil |
|
7726 |
withTimeOut:millis |
|
10 | 7727 |
! |
7728 |
||
7729 |
selectOn:fd withTimeOut:millis |
|
7730 |
"wait for aFileDesriptor to become ready; timeout after t milliseconds. |
|
1 | 7731 |
Return true, if i/o ok, false if timed-out or interrupted. |
7732 |
With 0 as timeout argument, this can be used to check for availability |
|
7733 |
of read-data. |
|
7734 |
Experimental." |
|
7735 |
||
3 | 7736 |
^ self selectOnAnyReadable:(Array with:fd) |
185 | 7737 |
writable:(Array with:fd) |
7738 |
exception:nil |
|
7739 |
withTimeOut:millis |
|
1 | 7740 |
! |
7741 |
||
616 | 7742 |
selectOnAny:fdArray withTimeOut:millis |
7743 |
"wait for any fd in fdArray (an Array of integers) to become ready; |
|
7744 |
timeout after t milliseconds. An empty set will always wait. |
|
7745 |
Return first ready fd if i/o ok, nil if timed-out or interrupted. |
|
7746 |
Experimental." |
|
7747 |
||
7748 |
^ self selectOnAnyReadable:fdArray |
|
7749 |
writable:fdArray |
|
185 | 7750 |
exception:nil |
7751 |
withTimeOut:millis |
|
1 | 7752 |
! |
7753 |
||
10 | 7754 |
selectOnAnyReadable:fdArray withTimeOut:millis |
95 | 7755 |
"wait for any fd in fdArray (an Array of integers) to become ready for |
7756 |
reading. Timeout after t milliseconds. An empty set will always wait. |
|
7757 |
A zero timeout-time will immediately return (i.e. poll). |
|
3 | 7758 |
Return first ready fd if i/o ok, nil if timed-out or interrupted. |
7759 |
Experimental." |
|
7760 |
||
7761 |
^ self selectOnAnyReadable:fdArray |
|
185 | 7762 |
writable:nil |
7763 |
exception:nil |
|
7764 |
withTimeOut:millis |
|
3 | 7765 |
! |
7766 |
||
95 | 7767 |
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray withTimeOut:millis |
7768 |
"wait for any fd in readFdArray (an Array of integers) to become ready for |
|
7769 |
reading, writeFdArray to become ready for writing, or exceptFdArray to |
|
7770 |
arrive exceptional data (i.e. out-of-band data). |
|
7771 |
Timeout after t milliseconds or, if the timeout time is 0, immediately.. |
|
7772 |
Empty fd-sets will always wait. Zero time can be used to poll file- |
|
7773 |
descriptors (i.e. to check if I/O possible without blocking). |
|
7774 |
Return first ready fd if I/O ok, nil if timed-out or interrupted." |
|
3 | 7775 |
|
1 | 7776 |
%{ |
831 | 7777 |
#ifdef MSDOS_LIKE |
7778 |
/* |
|
7779 |
* support a delay-wait only |
|
7780 |
* (i.e. fail if any filedescriptor is selected upon) |
|
7781 |
*/ |
|
7782 |
int count; |
|
7783 |
int i; |
|
7784 |
int t; |
|
7785 |
OBJ fd; |
|
7786 |
||
7787 |
if (! __isSmallInteger(millis)) { |
|
7788 |
goto fail; |
|
7789 |
} |
|
7790 |
||
7791 |
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
|
7792 |
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
|
7793 |
goto fail; |
831 | 7794 |
} |
7795 |
count = __arraySize(readFdArray); |
|
7796 |
for (i=0; i<count;i++) { |
|
1135 | 7797 |
fd = __ArrayInstPtr(readFdArray)->a_element[i]; |
831 | 7798 |
if (fd != nil) { |
7799 |
goto fail; |
|
7800 |
} |
|
7801 |
} |
|
7802 |
} |
|
7803 |
if (writeFdArray != nil) { |
|
7804 |
if (! __isArray(writeFdArray)) { |
|
7805 |
goto fail; |
|
7806 |
} |
|
7807 |
count = __arraySize(writeFdArray); |
|
7808 |
for (i=0; i<count;i++) { |
|
1135 | 7809 |
fd = __ArrayInstPtr(writeFdArray)->a_element[i]; |
831 | 7810 |
if (fd != nil) { |
7811 |
goto fail; |
|
7812 |
} |
|
7813 |
} |
|
7814 |
} |
|
7815 |
if (exceptFdArray != nil) { |
|
7816 |
if (! __isArray(exceptFdArray)) { |
|
7817 |
goto fail; |
|
7818 |
} |
|
7819 |
count = __arraySize(exceptFdArray); |
|
7820 |
for (i=0; i<count;i++) { |
|
1135 | 7821 |
fd = __ArrayInstPtr(exceptFdArray)->a_element[i]; |
831 | 7822 |
if (fd != nil) { |
7823 |
goto fail; |
|
7824 |
} |
|
7825 |
} |
|
7826 |
} |
|
1135 | 7827 |
t = __intVal(millis); |
831 | 7828 |
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
|
7829 |
/* |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
7830 |
* delay only |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
7831 |
*/ |
831 | 7832 |
Sleep(t); |
7833 |
} |
|
7834 |
RETURN (nil); |
|
7835 |
||
7836 |
#else /* not MSDOS_LIKE */ |
|
1 | 7837 |
fd_set rset, wset, eset; |
831 | 7838 |
struct timeval wt, et; |
1 | 7839 |
int t, f, maxF, i, lX, bX; |
7840 |
OBJ fd, retFd; |
|
95 | 7841 |
int ret; |
300 | 7842 |
int count; |
1 | 7843 |
|
252 | 7844 |
if (__isSmallInteger(millis)) { |
185 | 7845 |
FD_ZERO(&rset); |
7846 |
FD_ZERO(&wset); |
|
7847 |
FD_ZERO(&eset); |
|
7848 |
||
7849 |
maxF = -1; |
|
308 | 7850 |
if (readFdArray != nil) { |
300 | 7851 |
if (! __isArray(readFdArray)) { |
7852 |
goto fail; |
|
7853 |
} |
|
7854 |
count = __arraySize(readFdArray); |
|
308 | 7855 |
|
7856 |
for (i=0; i<count;i++) { |
|
1135 | 7857 |
fd = __ArrayInstPtr(readFdArray)->a_element[i]; |
308 | 7858 |
if (fd != nil) { |
1135 | 7859 |
f = __intVal(fd); |
308 | 7860 |
if ((f >= 0) && (f < FD_SETSIZE)) { |
7861 |
FD_SET(f, &rset); |
|
7862 |
if (f > maxF) maxF = f; |
|
7863 |
} |
|
185 | 7864 |
} |
7865 |
} |
|
7866 |
} |
|
300 | 7867 |
|
308 | 7868 |
if (writeFdArray != nil) { |
300 | 7869 |
if (! __isArray(writeFdArray)) { |
7870 |
goto fail; |
|
7871 |
} |
|
7872 |
count = __arraySize(writeFdArray); |
|
308 | 7873 |
for (i=0; i<count;i++) { |
1135 | 7874 |
fd = __ArrayInstPtr(writeFdArray)->a_element[i]; |
308 | 7875 |
if (fd != nil) { |
1135 | 7876 |
f = __intVal(fd); |
308 | 7877 |
if ((f >= 0) && (f < FD_SETSIZE)) { |
7878 |
FD_SET(f, &wset); |
|
7879 |
if (f > maxF) maxF = f; |
|
7880 |
} |
|
185 | 7881 |
} |
7882 |
} |
|
7883 |
} |
|
300 | 7884 |
|
308 | 7885 |
if (exceptFdArray != nil) { |
300 | 7886 |
if (! __isArray(exceptFdArray)) { |
7887 |
goto fail; |
|
7888 |
} |
|
7889 |
count = __arraySize(exceptFdArray); |
|
308 | 7890 |
for (i=0; i<count;i++) { |
1135 | 7891 |
fd = __ArrayInstPtr(exceptFdArray)->a_element[i]; |
308 | 7892 |
if (fd != nil) { |
1135 | 7893 |
f = __intVal(fd); |
308 | 7894 |
if ((f >= 0) && (f < FD_SETSIZE)) { |
7895 |
FD_SET(f, &eset); |
|
7896 |
if (f > maxF) maxF = f; |
|
7897 |
} |
|
185 | 7898 |
} |
7899 |
} |
|
7900 |
} |
|
308 | 7901 |
|
1135 | 7902 |
t = __intVal(millis); |
774
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7903 |
if (t) { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7904 |
wt.tv_sec = t / 1000; |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7905 |
wt.tv_usec = (t % 1000) * 1000; |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7906 |
} else { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7907 |
wt.tv_sec = wt.tv_usec = 0; |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7908 |
} |
185 | 7909 |
|
7910 |
/* |
|
7911 |
* make certain, that interrupt gets us out of the select |
|
7912 |
*/ |
|
362 | 7913 |
__BEGIN_INTERRUPTABLE__ |
185 | 7914 |
errno = 0; |
774
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7915 |
|
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7916 |
if (t == 0) { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7917 |
/* |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7918 |
* 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
|
7919 |
* interruptable. |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7920 |
*/ |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7921 |
do { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7922 |
ret = select(maxF+1, &rset, &wset, &eset, &wt); |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7923 |
} while ((ret < 0) && (errno == EINTR)); |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7924 |
} else { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7925 |
do { |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7926 |
ret = select(maxF+1, &rset, &wset, &eset, &wt); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7927 |
/* |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7928 |
* 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
|
7929 |
* could otherwise stay in this loop forever ... |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7930 |
* 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
|
7931 |
* 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
|
7932 |
*/ |
774
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7933 |
} while (0 /* (ret < 0) && (errno == EINTR) */ ); |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7934 |
} |
362 | 7935 |
__END_INTERRUPTABLE__ |
95 | 7936 |
|
185 | 7937 |
if (ret > 0) { |
7938 |
for (i=0; i <= maxF; i++) { |
|
7939 |
if (FD_ISSET(i, &rset) |
|
7940 |
|| FD_ISSET(i, &wset) |
|
7941 |
|| FD_ISSET(i, &eset)) { |
|
1135 | 7942 |
RETURN ( __MKSMALLINT(i) ); |
185 | 7943 |
} |
7944 |
} |
|
855
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
7945 |
} else { |
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
7946 |
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
|
7947 |
if (errno != EINTR) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
7948 |
fprintf(stderr, "OS: select errno = %d\n", errno); |
1135 | 7949 |
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
|
7950 |
} |
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
7951 |
} |
185 | 7952 |
} |
308 | 7953 |
|
185 | 7954 |
/* |
7955 |
* return nil (means time expired) |
|
7956 |
*/ |
|
7957 |
RETURN ( nil ); |
|
1 | 7958 |
} |
831 | 7959 |
#endif /* not MSDOS_LIKE */ |
7960 |
||
300 | 7961 |
fail: ; |
68 | 7962 |
%}. |
7963 |
" |
|
300 | 7964 |
timeout argument not integer, |
7965 |
or any fd-array nonNil and not an array |
|
792 | 7966 |
or not supported by OS |
68 | 7967 |
" |
792 | 7968 |
^ self primitiveFailed |
1 | 7969 |
! |
7970 |
||
616 | 7971 |
setBlocking:aBoolean on:fd |
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7972 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7973 |
|
616 | 7974 |
"set/clear the blocking attribute - if set (which is the default) |
7975 |
a read on the fileDescriptor will block until data is available. |
|
7976 |
If cleared, a read operation will immediately return with a value of |
|
7977 |
nil." |
|
10 | 7978 |
|
7979 |
%{ /* NOCONTEXT */ |
|
7980 |
||
616 | 7981 |
int ret, flags; |
7982 |
int savInt; |
|
7983 |
||
7984 |
#if defined(F_GETFL) && defined(F_SETFL) |
|
7985 |
# if defined(FNDELAY) |
|
7986 |
if (__isSmallInteger(fd)) { |
|
1135 | 7987 |
int f = __intVal(fd); |
7988 |
||
7989 |
flags = fcntl(f, F_GETFL, 0); |
|
616 | 7990 |
if (aBoolean == true) { |
1135 | 7991 |
ret = fcntl(f, F_SETFL, flags & ~FNDELAY); |
616 | 7992 |
} else { |
1135 | 7993 |
ret = fcntl(f, F_SETFL, flags | FNDELAY); |
185 | 7994 |
} |
616 | 7995 |
if (ret >= 0) ret = flags; |
1135 | 7996 |
RETURN ( __MKSMALLINT(ret) ); |
77 | 7997 |
} |
616 | 7998 |
# endif |
77 | 7999 |
#endif |
308 | 8000 |
%}. |
77 | 8001 |
" |
616 | 8002 |
fd argument not integer |
185 | 8003 |
" |
792 | 8004 |
^ self primitiveFailed |
1 | 8005 |
! |
8006 |
||
616 | 8007 |
writeCheck:fd |
8008 |
"return true, if filedescriptor can be written without blocking" |
|
8009 |
||
8010 |
(self selectOnAnyReadable:nil |
|
8011 |
writable:(Array with:fd) |
|
8012 |
exception:nil |
|
8013 |
withTimeOut:0) == fd |
|
8014 |
ifTrue:[^ true]. |
|
8015 |
^ false |
|
1 | 8016 |
! ! |
434 | 8017 |
|
1966
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8018 |
!OperatingSystem::OSProcessStatus class methodsFor:'documentation'! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8019 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8020 |
documentation |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8021 |
" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8022 |
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
|
8023 |
operating system processes (these are no smalltalk processes!!). |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8024 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8025 |
[Instance variables:] |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8026 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8027 |
pid <Integer> OS-Process identifier |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8028 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8029 |
status <Symbol> either #exit #signal #stop #continue |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8030 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8031 |
code <Integer> either exitcode or signalnumber |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8032 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8033 |
core <Boolean> true if core has been dumped |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8034 |
|
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 |
[author:] |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8037 |
Stefan Vogel |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8038 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8039 |
[see also:] |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8040 |
OperatingSystem |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8041 |
" |
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 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8044 |
!OperatingSystem::OSProcessStatus class methodsFor:'instance creation'! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8045 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8046 |
pid:pid status:status code:code core:core |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8047 |
"private interface for OperatingSystem" |
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 |
^ 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
|
8050 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8051 |
"Created: 28.12.1995 / 14:16:14 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8052 |
"Modified: 30.4.1996 / 18:25:00 / cg" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8053 |
! |
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 |
processCreationFailure |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8056 |
"private interface for 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 |
^ 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
|
8059 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8060 |
"Created: 28.12.1995 / 14:35:29 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8061 |
"Modified: 30.4.1996 / 18:25:05 / cg" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8062 |
! ! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8063 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8064 |
!OperatingSystem::OSProcessStatus methodsFor:'accessing'! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8065 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8066 |
code |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8067 |
"return the exitcode / signalNumber" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8068 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8069 |
^ code |
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 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8072 |
"Modified: 30.4.1996 / 18:26:23 / cg" |
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 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8075 |
core |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8076 |
"return true if core has been dumped, false otherwise" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8077 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8078 |
^ core == true |
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 |
"Modified: 28.12.1995 / 14:14:38 / stefan" |
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 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8083 |
pid |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8084 |
"return the pid" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8085 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8086 |
^ pid |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8087 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8088 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8089 |
"Modified: 30.4.1996 / 18:26:30 / cg" |
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 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8092 |
status |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8093 |
"return status as a Symbol; |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8094 |
one of #exit #signal #stop #continue" |
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 |
^ status |
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 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8099 |
"Modified: 30.4.1996 / 18:26:54 / cg" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8100 |
! ! |
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 |
!OperatingSystem::OSProcessStatus methodsFor:'initialization'! |
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 |
pid:newPid status:newStatus code:newCode core:newCore |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8105 |
pid := newPid. |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8106 |
status := newStatus. |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8107 |
code := newCode. |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8108 |
core := newCore. |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8109 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8110 |
"Created: 28.12.1995 / 14:18:22 / stefan" |
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 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8113 |
!OperatingSystem::OSProcessStatus methodsFor:'private-OS interface'! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8114 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8115 |
code:something |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8116 |
"set the exitCode" |
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 |
code := something. |
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 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8121 |
"Modified: 30.4.1996 / 18:25:18 / cg" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8122 |
! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8123 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8124 |
core:something |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8125 |
"set core" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8126 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8127 |
core := something. |
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 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
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 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8132 |
pid:something |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8133 |
"set pid" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8134 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8135 |
pid := something. |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8136 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8137 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
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 |
status:something |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8141 |
"set status" |
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 |
status := 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 |
!OperatingSystem::OSProcessStatus methodsFor:'queries'! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8149 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8150 |
couldNotExecute |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8151 |
"return true when a command could not be executed" |
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 |
^ status == #exit and:[code = 127]. |
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 |
"Created: 28.12.1995 / 15:43:17 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8156 |
"Modified: 30.4.1996 / 18:27:03 / cg" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8157 |
! |
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 |
stillAlive |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8160 |
"true if process is still alive" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8161 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8162 |
^ status == #stop or:[status == #continue] |
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 |
"Created: 28.12.1995 / 14:27:26 / stefan" |
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 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8167 |
success |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8168 |
"true if process terminated successfully" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8169 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8170 |
^ status == #exit and:[code = 0] |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8171 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8172 |
"Created: 28.12.1995 / 14:13:05 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8173 |
"Modified: 28.12.1995 / 14:13:41 / stefan" |
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 |
|
2080
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8176 |
!OperatingSystem::FileStatusInfo class methodsFor:'instance creation'! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8177 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8178 |
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
|
8179 |
^ self basicNew |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8180 |
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
|
8181 |
! ! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8182 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8183 |
!OperatingSystem::FileStatusInfo methodsFor:'accessing'! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8184 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8185 |
accessed |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8186 |
"return accessed" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8187 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8188 |
^ accessed! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8189 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8190 |
gid |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8191 |
"return gid" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8192 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8193 |
^ gid! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8194 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8195 |
id |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8196 |
"return id" |
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 |
^ id! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8199 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8200 |
mode |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8201 |
"return mode" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8202 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8203 |
^ mode! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8204 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8205 |
modified |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8206 |
"return modified" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8207 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8208 |
^ modified! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8209 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8210 |
path |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8211 |
"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
|
8212 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8213 |
^ path |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8214 |
|
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 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8217 |
size |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8218 |
"return size" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8219 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8220 |
^ size! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8221 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8222 |
statusChanged |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8223 |
"return statusChanged" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8224 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8225 |
^ statusChanged! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8226 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8227 |
type |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8228 |
"return type" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8229 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8230 |
^ type! |
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 |
uid |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8233 |
"return uid" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8234 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8235 |
^ uid! ! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8236 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8237 |
!OperatingSystem::FileStatusInfo methodsFor:'backward compatibility'! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8238 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8239 |
at:key |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8240 |
"backward compatibility access: in previous releases, IdentityDictionaries |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8241 |
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
|
8242 |
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
|
8243 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8244 |
^ self perform:key |
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 |
|
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 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8249 |
!OperatingSystem::FileStatusInfo methodsFor:'private accessing'! |
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 |
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
|
8252 |
type := t. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8253 |
mode := m. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8254 |
uid := u. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8255 |
gid := g. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8256 |
size := s. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8257 |
id := i. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8258 |
accessed := aT. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8259 |
modified := mT. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8260 |
statusChanged := sT. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8261 |
path := lP |
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 |
|
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
8266 |
!OperatingSystem class methodsFor:'documentation'! |
630 | 8267 |
|
8268 |
version |
|
2098
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
8269 |
^ '$Header: /cvs/stx/stx/libbasic/Attic/Unix.st,v 1.185 1997-01-08 23:50:51 cg Exp $' |
630 | 8270 |
! ! |
616 | 8271 |
OperatingSystem initialize! |