author | Claus Gittinger <cg@exept.de> |
Fri, 10 Jan 1997 12:20:24 +0100 | |
changeset 2117 | 460b14a6db96 |
parent 2107 | 9987b837fe12 |
child 2126 | d3da2956f380 |
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 |
2107 | 384 |
* and no sigemptyset |
2073 | 385 |
*/ |
386 |
# ifdef NEXT |
|
387 |
typedef int pid_t; |
|
2107 | 388 |
# define sigemptyset(set) ((*(set) = 0L), 0) |
2073 | 389 |
# endif |
390 |
||
391 |
/* |
|
392 |
* some (BSD ?) have no timezone |
|
393 |
*/ |
|
394 |
# if defined(ultrix) || defined(sunos) || defined(NEXT) |
|
395 |
# define HAS_NO_TIMEZONE |
|
396 |
# endif |
|
397 |
||
398 |
/* |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
399 |
* sigaction dummies (you won't believe these call themself ``POSIX'' systems ...) |
763
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
400 |
*/ |
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
401 |
# ifndef SA_RESTART |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
402 |
# define SA_RESTART 0 |
763
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
403 |
# endif |
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
404 |
# ifndef SA_SIGINFO |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
405 |
# define SA_SIGINFO 0 |
763
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
406 |
# endif |
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
407 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
408 |
# if defined(HAS_WAITPID) || defined(HAS_WAIT3) |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
409 |
# include <sys/wait.h> |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
410 |
# endif |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
411 |
|
1433 | 412 |
# if defined(HAS_SYSINFO) |
413 |
# include <sys/systeminfo.h> |
|
414 |
# endif |
|
415 |
||
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
416 |
#endif /* not transputer */ |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
417 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
418 |
/* |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
419 |
* on some systems errno is a macro ... check for it here |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
420 |
*/ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
421 |
#ifndef errno |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
422 |
extern errno; |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
423 |
#endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
424 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
425 |
/* |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
426 |
* some (old ?) systems do not define this ... |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
427 |
*/ |
675 | 428 |
#if !defined(R_OK) && !defined(_AIX) |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
429 |
# define R_OK 4 /* Test for Read permission */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
430 |
# define W_OK 2 /* Test for Write permission */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
431 |
# define X_OK 1 /* Test for eXecute permission */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
432 |
# define F_OK 0 /* Test for existence of File */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
433 |
#endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
434 |
|
832 | 435 |
#ifdef WIN32 |
436 |
# define SIGHANDLER_ARG int |
|
437 |
#else |
|
438 |
# define SIGHANDLER_ARG |
|
439 |
#endif |
|
440 |
||
1441 | 441 |
#ifdef sunos |
442 |
# define NO_WAITPID |
|
443 |
#endif |
|
444 |
||
437 | 445 |
%} |
446 |
! ! |
|
447 |
||
448 |
!OperatingSystem primitiveFunctions! |
|
449 |
%{ |
|
450 |
||
451 |
/* |
|
452 |
* some systems' system() is broken in that it does not correctly |
|
453 |
* handle EINTR and returns failure even though it actually succeeded. |
|
454 |
* (LINUX is one of them) |
|
455 |
* Here is a fixed version. If you encounter EINTR returns from |
|
456 |
* OperatingSystem>>executeCommand, you ought to define WANT_SYSTEM |
|
457 |
* in the xxxIntern.h file to get this fixed version. |
|
458 |
* |
|
459 |
* As an added BONUS, this system() enables interrupts while waiting |
|
460 |
* 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
|
461 |
* (i.e. it is RT safe) |
437 | 462 |
*/ |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
463 |
|
433 | 464 |
#if defined(WANT_SYSTEM) |
465 |
||
434 | 466 |
/* # define DPRINTF(x) printf x */ |
467 |
# define DPRINTF(x) /* nothing */ |
|
433 | 468 |
|
437 | 469 |
# ifndef _STDDEF_H_INCLUDED_ |
470 |
# include <stddef.h> |
|
471 |
# define _STDDEF_H_INCLUDED_ |
|
472 |
# endif |
|
473 |
||
474 |
# ifndef _STDLIB_H_INCLUDED_ |
|
475 |
# include <stdlib.h> |
|
476 |
# define _STDLIB_H_INCLUDED_ |
|
477 |
# endif |
|
478 |
||
479 |
# ifndef _UNISTD_H_INCLUDED_ |
|
480 |
# include <unistd.h> |
|
481 |
# define _UNISTD_H_INCLUDED_ |
|
482 |
# endif |
|
483 |
||
484 |
# ifndef _SYS_WAIT_H_INCLUDED |
|
485 |
# include <sys/wait.h> |
|
486 |
# define _SYS_WAIT_H_INCLUDED |
|
487 |
# endif |
|
488 |
||
489 |
# ifndef _SIGNAL_H_INCLUDED_ |
|
490 |
# include <signal.h> |
|
491 |
# define _SIGNAL_H_INCLUDED_ |
|
492 |
# endif |
|
493 |
||
494 |
# ifndef _SYS_TYPES_H_INCLUDED_ |
|
495 |
# include <sys/types.h> |
|
496 |
# define _SYS_TYPES_H_INCLUDED_ |
|
497 |
# endif |
|
433 | 498 |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
499 |
# if (!defined(HAVE_GNU_LD) && !defined (__ELF__)) || !defined(LINUX) |
433 | 500 |
# define __environ environ |
512 | 501 |
# if !defined(LINUX) |
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
502 |
# define __sigemptyset sigemptyset |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
503 |
# define __sigaction sigaction |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
504 |
# define __sigaddset sigaddset |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
505 |
# define __sigprocmask sigprocmask |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
506 |
# define __execve execve |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
507 |
# define __wait wait |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
508 |
# define __waitpid waitpid |
674 | 509 |
# if defined(HAS_VFORK) |
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
510 |
# define FORK vfork |
514
81fa80a953e2
system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents:
513
diff
changeset
|
511 |
# else |
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
512 |
# define FORK fork |
514
81fa80a953e2
system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents:
513
diff
changeset
|
513 |
# endif |
512 | 514 |
# endif /* ! LINUX */ |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
515 |
extern char **environ; |
433 | 516 |
# endif |
517 |
||
518 |
# define SHELL_PATH "/bin/sh" /* Path of the shell. */ |
|
519 |
# define SHELL_NAME "sh" /* Name to give it. */ |
|
520 |
||
521 |
# ifndef FORK |
|
522 |
# define FORK __fork |
|
523 |
# endif |
|
524 |
||
525 |
# ifndef CONST |
|
526 |
# ifdef __GNUC__ |
|
527 |
# define CONST const |
|
528 |
# else |
|
529 |
# define CONST /* nothing */ |
|
530 |
# endif |
|
531 |
# endif |
|
532 |
||
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
533 |
static int |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
534 |
mySystem(line) |
433 | 535 |
register CONST char *line; |
536 |
{ |
|
537 |
int status, save; |
|
538 |
pid_t pid; |
|
539 |
struct sigaction sa, intr, quit; |
|
540 |
sigset_t block, omask; |
|
541 |
||
542 |
if (line == NULL) |
|
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
543 |
return -1; |
433 | 544 |
|
545 |
sa.sa_handler = SIG_IGN; |
|
546 |
sa.sa_flags = 0; |
|
547 |
__sigemptyset (&sa.sa_mask); |
|
548 |
||
549 |
if (__sigaction (SIGINT, &sa, &intr) < 0) { |
|
550 |
DPRINTF(("1: errno=%d\n", errno)); |
|
551 |
return -1; |
|
552 |
} |
|
553 |
if (__sigaction (SIGQUIT, &sa, &quit) < 0) { |
|
554 |
save = errno; |
|
555 |
(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL); |
|
556 |
errno = save; |
|
557 |
DPRINTF(("2: errno=%d\n", errno)); |
|
558 |
return -1; |
|
559 |
} |
|
560 |
||
561 |
__sigemptyset (&block); |
|
562 |
__sigaddset (&block, SIGCHLD); |
|
563 |
save = errno; |
|
564 |
if (__sigprocmask(SIG_BLOCK, &block, &omask) < 0) { |
|
565 |
if (errno == ENOSYS) |
|
566 |
errno = save; |
|
567 |
else { |
|
568 |
save = errno; |
|
569 |
(void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL); |
|
570 |
(void) __sigaction(SIGQUIT, &quit, (struct sigaction *) NULL); |
|
571 |
errno = save; |
|
572 |
DPRINTF(("3: errno=%d\n", errno)); |
|
573 |
return -1; |
|
574 |
} |
|
575 |
} |
|
576 |
||
577 |
pid = FORK (); |
|
578 |
if (pid == (pid_t) 0) { |
|
579 |
/* Child side. */ |
|
580 |
CONST char *new_argv[4]; |
|
581 |
new_argv[0] = SHELL_NAME; |
|
582 |
new_argv[1] = "-c"; |
|
583 |
new_argv[2] = line; |
|
584 |
new_argv[3] = NULL; |
|
585 |
||
586 |
/* Restore the signals. */ |
|
587 |
(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL); |
|
588 |
(void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL); |
|
589 |
(void) __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL); |
|
590 |
||
591 |
/* Exec the shell. */ |
|
592 |
(void) __execve (SHELL_PATH, (char *CONST *) new_argv, __environ); |
|
593 |
_exit (127); |
|
594 |
} else { |
|
595 |
if (pid < (pid_t) 0) { |
|
596 |
/* The fork failed. */ |
|
597 |
DPRINTF(("4: errno=%d\n", errno)); |
|
598 |
status = -1; |
|
599 |
} else { |
|
600 |
/* Parent side. */ |
|
601 |
#ifdef NO_WAITPID |
|
602 |
pid_t child; |
|
603 |
||
604 |
do { |
|
805 | 605 |
__BEGIN_INTERRUPTABLE__ |
433 | 606 |
child = __wait (&status); |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
607 |
__END_INTERRUPTABLE__ |
805 | 608 |
if (child < 0 && errno != EINTR) { |
433 | 609 |
DPRINTF(("5: errno=%d\n", errno)); |
610 |
status = -1; |
|
611 |
break; |
|
612 |
} |
|
613 |
} while (child != pid); |
|
614 |
#else |
|
615 |
pid_t child; |
|
616 |
||
617 |
/* claus: the original did not care for EINTR here ... */ |
|
618 |
do { |
|
805 | 619 |
__BEGIN_INTERRUPTABLE__ |
433 | 620 |
child = __waitpid (pid, &status, 0); |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
621 |
__END_INTERRUPTABLE__ |
433 | 622 |
} while ((child != pid) && (errno == EINTR)); |
623 |
if (child != pid) { |
|
624 |
DPRINTF(("6: errno=%d\n", errno)); |
|
625 |
status = -1; |
|
626 |
} |
|
627 |
#endif /* NO_WAITPID */ |
|
628 |
} |
|
629 |
} |
|
630 |
save = errno; |
|
631 |
if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL) |
|
632 |
| __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL) |
|
633 |
| __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)) != 0) { |
|
634 |
if (errno == ENOSYS) { |
|
635 |
errno = save; |
|
636 |
} else { |
|
637 |
status = -1; |
|
638 |
DPRINTF(("7: errno=%d\n", errno)); |
|
639 |
} |
|
640 |
} |
|
641 |
||
642 |
return status; |
|
643 |
} |
|
1441 | 644 |
#else |
1487 | 645 |
# define __wait wait |
433 | 646 |
#endif /* WANT_SYSTEM */ |
647 |
||
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
648 |
|
433 | 649 |
/* |
650 |
* some systems do not have realpath(); |
|
651 |
* the alternative of reading from a 'pwp'-pipe |
|
652 |
* is way too slow. Here is a realpath for the rest of us. |
|
440 | 653 |
* define WANT_REALPATH in the xxxIntern-file to get it. |
433 | 654 |
*/ |
443 | 655 |
|
440 | 656 |
#if defined(HAS_REALPATH) |
657 |
# undef WANT_REALPATH |
|
658 |
#endif |
|
659 |
#if !defined(HAS_GETWD) && !defined(HAS_GETCWD) |
|
660 |
# undef WANT_REALPATH |
|
661 |
#endif |
|
662 |
||
663 |
#if defined(WANT_REALPATH) |
|
406 | 664 |
|
665 |
# ifndef NULL |
|
666 |
# define NULL (char *)0 |
|
667 |
# endif |
|
668 |
||
439 | 669 |
# define MAX_READLINKS 32 |
670 |
||
671 |
# ifndef MAXPATHLEN |
|
672 |
# define MAXPATHLEN 1024 |
|
673 |
# endif |
|
406 | 674 |
|
675 |
static |
|
676 |
char *realpath(path, resolved_path) |
|
677 |
char *path; |
|
678 |
char resolved_path []; |
|
679 |
{ |
|
680 |
char copy_path[MAXPATHLEN]; |
|
681 |
char link_path[MAXPATHLEN]; |
|
682 |
char *new_path = resolved_path; |
|
683 |
char *max_path; |
|
684 |
int readlinks = 0; |
|
685 |
int n; |
|
686 |
||
687 |
/* Make a copy of the source path since we may need to modify it. */ |
|
688 |
strcpy(copy_path, path); |
|
689 |
path = copy_path; |
|
690 |
max_path = copy_path + MAXPATHLEN - 2; |
|
691 |
/* If it's a relative pathname use getwd for starters. */ |
|
692 |
if (*path != '/') { |
|
693 |
#ifdef HAS_GETCWD |
|
694 |
getcwd(new_path, MAXPATHLEN - 1); |
|
695 |
#else |
|
696 |
getwd(new_path); |
|
697 |
#endif |
|
698 |
new_path += strlen(new_path); |
|
699 |
if (new_path[-1] != '/') |
|
700 |
*new_path++ = '/'; |
|
701 |
} |
|
702 |
else { |
|
703 |
*new_path++ = '/'; |
|
704 |
path++; |
|
705 |
} |
|
706 |
/* Expand each slash-separated pathname component. */ |
|
707 |
while (*path != '\0') { |
|
708 |
/* Ignore stray "/". */ |
|
709 |
if (*path == '/') { |
|
710 |
path++; |
|
711 |
continue; |
|
712 |
} |
|
713 |
if (*path == '.') { |
|
714 |
/* Ignore ".". */ |
|
715 |
if (path[1] == '\0' || path[1] == '/') { |
|
716 |
path++; |
|
717 |
continue; |
|
718 |
} |
|
719 |
if (path[1] == '.') { |
|
720 |
if (path[2] == '\0' || path[2] == '/') { |
|
721 |
path += 2; |
|
722 |
/* Ignore ".." at root. */ |
|
723 |
if (new_path == resolved_path + 1) |
|
724 |
continue; |
|
725 |
/* Handle ".." by backing up. */ |
|
726 |
while ((--new_path)[-1] != '/') |
|
727 |
; |
|
728 |
continue; |
|
729 |
} |
|
730 |
} |
|
731 |
} |
|
732 |
/* Safely copy the next pathname component. */ |
|
733 |
while (*path != '\0' && *path != '/') { |
|
734 |
if (path > max_path) { |
|
735 |
errno = ENAMETOOLONG; |
|
736 |
return NULL; |
|
737 |
} |
|
738 |
*new_path++ = *path++; |
|
739 |
} |
|
740 |
#ifdef S_IFLNK |
|
741 |
/* Protect against infinite loops. */ |
|
742 |
if (readlinks++ > MAX_READLINKS) { |
|
743 |
errno = ELOOP; |
|
744 |
return NULL; |
|
745 |
} |
|
746 |
/* See if latest pathname component is a symlink. */ |
|
747 |
*new_path = '\0'; |
|
748 |
n = readlink(resolved_path, link_path, MAXPATHLEN - 1); |
|
749 |
if (n < 0) { |
|
750 |
/* EINVAL means the file exists but isn't a symlink. */ |
|
751 |
if (errno != EINVAL) |
|
752 |
return NULL; |
|
753 |
} |
|
754 |
else { |
|
755 |
/* Note: readlink doesn't add the null byte. */ |
|
756 |
link_path[n] = '\0'; |
|
757 |
if (*link_path == '/') |
|
758 |
/* Start over for an absolute symlink. */ |
|
759 |
new_path = resolved_path; |
|
760 |
else |
|
761 |
/* Otherwise back up over this component. */ |
|
762 |
while (*(--new_path) != '/') |
|
763 |
; |
|
764 |
/* Safe sex check. */ |
|
765 |
if (strlen(path) + n >= MAXPATHLEN) { |
|
766 |
errno = ENAMETOOLONG; |
|
767 |
return NULL; |
|
768 |
} |
|
769 |
/* Insert symlink contents into path. */ |
|
770 |
strcat(link_path, path); |
|
771 |
strcpy(copy_path, link_path); |
|
772 |
path = copy_path; |
|
773 |
} |
|
774 |
#endif /* S_IFLNK */ |
|
775 |
*new_path++ = '/'; |
|
776 |
} |
|
777 |
/* Delete trailing slash but don't whomp a lone slash. */ |
|
778 |
if (new_path != resolved_path + 1 && new_path[-1] == '/') |
|
779 |
new_path--; |
|
780 |
/* Make sure it's null terminated. */ |
|
781 |
*new_path = '\0'; |
|
782 |
return resolved_path; |
|
783 |
} |
|
784 |
# define HAS_REALPATH |
|
785 |
#endif /* WANT_REALPATH && not HAS_REALPATH */ |
|
786 |
%} |
|
787 |
! ! |
|
788 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
789 |
!OperatingSystem class methodsFor:'documentation'! |
2 | 790 |
|
88 | 791 |
copyright |
792 |
" |
|
793 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
185 | 794 |
All Rights Reserved |
88 | 795 |
|
796 |
This software is furnished under a license and may be used |
|
797 |
only in accordance with the terms of that license and with the |
|
798 |
inclusion of the above copyright notice. This software may not |
|
799 |
be provided or otherwise made available to, or used by, any |
|
800 |
other person. No title to or ownership of the software is |
|
801 |
hereby transferred. |
|
802 |
" |
|
803 |
! |
|
804 |
||
2 | 805 |
documentation |
806 |
" |
|
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
807 |
this class realizes access to most (all ?) required operating system services; |
68 | 808 |
some of it is very specific for unix, so do not depend on |
1619 | 809 |
things available here in your applications |
810 |
- some may not be found in other OS's or be slightly different ... |
|
68 | 811 |
|
812 |
(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
|
813 |
from you - in some situations it MAY be interesting to be |
792 | 814 |
able to get down to a select or fork system call easily (at least on Unix systems). |
68 | 815 |
You decide - portability vs. functionality) |
816 |
||
1286 | 817 |
[Class variables:] |
818 |
||
1487 | 819 |
HostName <String> remembered hostname |
820 |
||
821 |
DomainName <String> remembered domainname |
|
822 |
||
823 |
LastErrorNumber <Integer> the last value of errno |
|
824 |
||
825 |
OSSignals <Array> Array of signals to be raised for corresponding |
|
826 |
OperatingSystem signals. |
|
827 |
||
828 |
ForkFailed <Boolean> set if a fork (or popen) has failed; |
|
829 |
ST/X will avoid doing more forks/popens |
|
830 |
if this flag is set, for a slightly |
|
831 |
smoother operation. |
|
832 |
||
833 |
SlowFork <Boolean> if set, fork and popen are avoided; |
|
834 |
(more or less obsolete now) |
|
835 |
||
836 |
||
837 |
ErrorSignal <Signal> Parentsignal of all OS error signals. |
|
838 |
not directly raised. |
|
839 |
||
840 |
AccessDeniedErrorSignal |
|
841 |
||
842 |
FileNotFoundErrorSignal |
|
843 |
||
844 |
LocaleInfo <Dictionary> if non nil, that is taken instead of the operating |
|
845 |
systems locale definitions (allows for overwriting |
|
846 |
these, or provide a compatible info on systems which do |
|
847 |
not support locales) |
|
1286 | 848 |
|
849 |
[author:] |
|
1487 | 850 |
Claus Gittinger |
1286 | 851 |
|
852 |
[see also:] |
|
1487 | 853 |
OSProcessStatus |
854 |
Filename Date Time |
|
855 |
ExternalStream FileStream PipeStream Socket |
|
2 | 856 |
" |
1619 | 857 |
! |
858 |
||
859 |
examples |
|
860 |
" |
|
1622 | 861 |
various queries |
1632 | 862 |
[exBegin] |
1622 | 863 |
Transcript |
1632 | 864 |
showCR:'hello ' , (OperatingSystem getLoginName) |
865 |
[exEnd] |
|
866 |
||
867 |
[exBegin] |
|
1622 | 868 |
OperatingSystem isUNIXlike ifTrue:[ |
1632 | 869 |
Transcript showCR:'this is some UNIX-like OS' |
1622 | 870 |
] ifFalse:[ |
1632 | 871 |
Transcript showCR:'this OS is not UNIX-like' |
1622 | 872 |
] |
1632 | 873 |
[exEnd] |
874 |
||
875 |
[exBegin] |
|
1622 | 876 |
Transcript |
1632 | 877 |
showCR:'this machine is called ' , OperatingSystem getHostName |
878 |
[exEnd] |
|
879 |
||
880 |
[exBegin] |
|
1622 | 881 |
Transcript |
1632 | 882 |
showCR:('this machine is in the ' |
883 |
, OperatingSystem getDomainName |
|
884 |
, ' domain') |
|
885 |
[exEnd] |
|
886 |
||
887 |
[exBegin] |
|
1622 | 888 |
Transcript |
1632 | 889 |
showCR:('this machine''s CPU is a ' |
890 |
, OperatingSystem getCPUType |
|
891 |
) |
|
892 |
[exEnd] |
|
893 |
||
894 |
[exBegin] |
|
1622 | 895 |
Transcript showCR:'executing ls command ...'. |
896 |
OperatingSystem executeCommand:'ls'. |
|
897 |
Transcript showCR:'... done.'. |
|
1632 | 898 |
[exEnd] |
1622 | 899 |
|
1621 | 900 |
locking a file |
901 |
(should be executed on two running smalltalks - not in two threads): |
|
1632 | 902 |
[exBegin] |
1621 | 903 |
|f| |
904 |
||
905 |
f := 'testFile' asFilename readWriteStream. |
|
906 |
||
907 |
10 timesRepeat:[ |
|
1632 | 908 |
'about to lock ...' printCR. |
909 |
[ |
|
910 |
OperatingSystem |
|
911 |
lockFD:(f fileDescriptor) |
|
912 |
shared:false |
|
913 |
blocking:false |
|
914 |
] whileFalse:[ |
|
915 |
'process ' print. OperatingSystem getProcessId print. ' is waiting' printCR. |
|
916 |
Delay waitForSeconds:1 |
|
917 |
]. |
|
918 |
'LOCKED ...' printCR. |
|
919 |
Delay waitForSeconds:10. |
|
920 |
'unlock ...' printCR. |
|
921 |
(OperatingSystem |
|
922 |
unlockFD:(f fileDescriptor)) printCR. |
|
923 |
Delay waitForSeconds:3. |
|
1621 | 924 |
] |
1632 | 925 |
[exBegin] |
1619 | 926 |
" |
2 | 927 |
! ! |
928 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
929 |
!OperatingSystem class methodsFor:'initialization'! |
95 | 930 |
|
931 |
initialize |
|
185 | 932 |
"initialize the class" |
933 |
||
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
934 |
ObjectMemory addDependent:self. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
935 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
936 |
ErrorSignal isNil ifTrue:[ |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
937 |
ErrorSignal := Object errorSignal newSignalMayProceed:true.. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
938 |
ErrorSignal nameClass:self message:#errorSignal. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
939 |
ErrorSignal notifierString:'OS error encountered'. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
940 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
941 |
AccessDeniedErrorSignal := ErrorSignal newSignalMayProceed:true. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
942 |
AccessDeniedErrorSignal nameClass:self message:#accessDeniedError. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
943 |
AccessDeniedErrorSignal notifierString:'OS access denied'. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
944 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
945 |
FileNotFoundErrorSignal := ErrorSignal newSignalMayProceed:true. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
946 |
FileNotFoundErrorSignal nameClass:self message:#fileNotFoundErrorSignal. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
947 |
FileNotFoundErrorSignal notifierString:'OS file not found'. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
948 |
] |
95 | 949 |
! |
950 |
||
1470 | 951 |
update:something with:aParameter from:changedObject |
1247 | 952 |
"catch image restart and flush some cached data" |
953 |
||
95 | 954 |
something == #earlyRestart ifTrue:[ |
1487 | 955 |
" |
956 |
flush cached data |
|
957 |
" |
|
958 |
HostName := nil. |
|
959 |
DomainName := nil. |
|
960 |
LastErrorNumber := nil. |
|
95 | 961 |
] |
1247 | 962 |
|
963 |
"Modified: 22.4.1996 / 13:10:43 / cg" |
|
1470 | 964 |
"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
|
965 |
"Modified: 7.1.1997 / 19:36:11 / stefan" |
95 | 966 |
! ! |
967 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
968 |
!OperatingSystem class methodsFor:'OS signal constants'! |
616 | 969 |
|
970 |
sigABRT |
|
971 |
"return the signal number for SIGABRT - 0 if not supported by OS |
|
972 |
(the numeric value is not the same across unix-systems)" |
|
973 |
||
974 |
%{ /* NOCONTEXT */ |
|
975 |
#ifdef SIGABRT |
|
1135 | 976 |
RETURN ( __MKSMALLINT(SIGABRT) ); |
616 | 977 |
#else |
1135 | 978 |
RETURN ( __MKSMALLINT(0) ); |
616 | 979 |
#endif |
980 |
%} |
|
981 |
! |
|
982 |
||
983 |
sigALRM |
|
984 |
"return the signal number for SIGALRM - 0 if not supported |
|
985 |
(the numeric value is not the same across unix-systems)" |
|
986 |
||
987 |
%{ /* NOCONTEXT */ |
|
988 |
#ifdef SIGALRM |
|
1135 | 989 |
RETURN ( __MKSMALLINT(SIGALRM) ); |
616 | 990 |
#else |
1135 | 991 |
RETURN ( __MKSMALLINT(0) ); |
616 | 992 |
#endif |
993 |
%} |
|
994 |
! |
|
995 |
||
831 | 996 |
sigBREAK |
997 |
"return the signal number for SIGBREAK - 0 if not supported. |
|
998 |
This is an MSDOS specific signal" |
|
999 |
||
1000 |
%{ /* NOCONTEXT */ |
|
1001 |
#ifdef SIGBREAK |
|
1135 | 1002 |
RETURN ( __MKSMALLINT(SIGBREAK) ); |
831 | 1003 |
#else |
1135 | 1004 |
RETURN ( __MKSMALLINT(0) ); |
831 | 1005 |
#endif |
1006 |
%} |
|
1007 |
! |
|
1008 |
||
616 | 1009 |
sigBUS |
1010 |
"return the signal number for SIGBUS - 0 if not supported |
|
1011 |
(the numeric value is not the same across unix-systems)" |
|
1012 |
||
1013 |
%{ /* NOCONTEXT */ |
|
1014 |
#ifdef SIGBUS |
|
1135 | 1015 |
RETURN ( __MKSMALLINT(SIGBUS) ); |
616 | 1016 |
#else |
1135 | 1017 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1018 |
#endif |
1019 |
%} |
|
1020 |
! |
|
1021 |
||
1022 |
sigCHLD |
|
1023 |
"return the signal number for SIGCHLD - 0 if not supported |
|
1024 |
(the numeric value is not the same across unix-systems)" |
|
1025 |
||
1026 |
%{ /* NOCONTEXT */ |
|
1027 |
#if defined(SIGCHLD) |
|
1135 | 1028 |
RETURN ( __MKSMALLINT(SIGCHLD) ); |
616 | 1029 |
#else |
1030 |
# if defined(SIGCLD) |
|
1135 | 1031 |
RETURN ( __MKSMALLINT(SIGCLD) ); |
616 | 1032 |
# else |
1135 | 1033 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1034 |
# endif |
1035 |
#endif |
|
1036 |
%} |
|
1037 |
! |
|
1038 |
||
1039 |
sigCONT |
|
1040 |
"return the signal number for SIGCONT - 0 if not supported |
|
1041 |
(the numeric value is not the same across unix-systems)" |
|
1042 |
||
1043 |
%{ /* NOCONTEXT */ |
|
1044 |
#if defined(SIGCONT) |
|
1135 | 1045 |
RETURN ( __MKSMALLINT(SIGCONT) ); |
616 | 1046 |
#else |
1135 | 1047 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1048 |
#endif |
1049 |
%} |
|
1050 |
! |
|
1051 |
||
1052 |
sigDANGER |
|
1053 |
"return the signal number for SIGDANGER - 0 if not supported |
|
1054 |
(seems to be an AIX special)" |
|
1055 |
||
1056 |
%{ /* NOCONTEXT */ |
|
710 | 1057 |
#if defined(SIGDANGER) |
1135 | 1058 |
RETURN ( __MKSMALLINT(SIGDANGER) ); |
616 | 1059 |
#else |
1135 | 1060 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1061 |
#endif |
1062 |
%} |
|
1063 |
! |
|
1064 |
||
1065 |
sigEMT |
|
1066 |
"return the signal number for SIGEMT - 0 if not supported by OS |
|
1067 |
(the numeric value is not the same across unix-systems)" |
|
1068 |
||
1069 |
%{ /* NOCONTEXT */ |
|
1070 |
#ifdef SIGEMT |
|
1135 | 1071 |
RETURN ( __MKSMALLINT(SIGEMT) ); |
616 | 1072 |
#else |
1135 | 1073 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1074 |
#endif |
1075 |
%} |
|
1076 |
! |
|
1077 |
||
1078 |
sigFP |
|
1079 |
"return the signal number for SIGFP - 0 if not supported by OS |
|
1080 |
(the numeric value is not the same across unix-systems)" |
|
1081 |
||
1082 |
%{ /* NOCONTEXT */ |
|
1083 |
#ifdef SIGFPE |
|
1135 | 1084 |
RETURN ( __MKSMALLINT(SIGFPE) ); |
616 | 1085 |
#else |
1135 | 1086 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1087 |
#endif |
1088 |
%} |
|
1089 |
! |
|
1090 |
||
1091 |
sigGRANT |
|
1092 |
"return the signal number for SIGGRANT - 0 if not supported |
|
1093 |
(seems to be an AIX special)" |
|
1094 |
||
1095 |
%{ /* NOCONTEXT */ |
|
1096 |
#if defined(SIGGRANT) |
|
1135 | 1097 |
RETURN ( __MKSMALLINT(SIGGRANT) ); |
616 | 1098 |
#else |
1135 | 1099 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1100 |
#endif |
1101 |
%} |
|
1102 |
! |
|
1103 |
||
1104 |
sigHUP |
|
1105 |
"return the signal number for SIGHUP |
|
1106 |
(the numeric value is not the same across unix-systems)" |
|
1107 |
||
1108 |
%{ /* NOCONTEXT */ |
|
1109 |
#ifdef SIGHUP |
|
1135 | 1110 |
RETURN ( __MKSMALLINT(SIGHUP) ); |
616 | 1111 |
#else |
1135 | 1112 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1113 |
#endif |
1114 |
%} |
|
1115 |
! |
|
1116 |
||
1117 |
sigILL |
|
1118 |
"return the signal number for SIGILL - 0 if not supported by OS |
|
1119 |
(the numeric value is not the same across unix-systems)" |
|
1120 |
||
1121 |
%{ /* NOCONTEXT */ |
|
1122 |
#ifdef SIGILL |
|
1135 | 1123 |
RETURN ( __MKSMALLINT(SIGILL) ); |
616 | 1124 |
#else |
1135 | 1125 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1126 |
#endif |
1127 |
%} |
|
1128 |
! |
|
1129 |
||
1130 |
sigINT |
|
1131 |
"return the signal number for SIGINT |
|
1132 |
(the numeric value is not the same across unix-systems)" |
|
1133 |
||
1134 |
%{ /* NOCONTEXT */ |
|
1135 |
#ifdef SIGINT |
|
1135 | 1136 |
RETURN ( __MKSMALLINT(SIGINT) ); |
616 | 1137 |
#else |
1135 | 1138 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1139 |
#endif |
1140 |
%} |
|
1141 |
! |
|
1142 |
||
1143 |
sigIO |
|
1144 |
"return the signal number for SIGIO - 0 if not supported |
|
1145 |
(the numeric value is not the same across unix-systems)" |
|
1146 |
||
1147 |
%{ /* NOCONTEXT */ |
|
1148 |
#if defined(SIGIO) |
|
1135 | 1149 |
RETURN ( __MKSMALLINT(SIGIO) ); |
616 | 1150 |
#else |
1135 | 1151 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1152 |
#endif |
1153 |
%} |
|
1154 |
! |
|
1155 |
||
1156 |
sigIOT |
|
1157 |
"return the signal number for SIGIOT - 0 if not supported by OS |
|
1158 |
(the numeric value is not the same across unix-systems)" |
|
1159 |
||
1160 |
%{ /* NOCONTEXT */ |
|
1161 |
#ifdef SIGIOT |
|
1135 | 1162 |
RETURN ( __MKSMALLINT(SIGIOT) ); |
616 | 1163 |
#else |
1135 | 1164 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1165 |
#endif |
1166 |
%} |
|
1167 |
! |
|
1168 |
||
1169 |
sigKILL |
|
1170 |
"return the signal number for SIGKILL |
|
1171 |
(the numeric value is not the same across unix-systems)" |
|
1172 |
||
1173 |
%{ /* NOCONTEXT */ |
|
1174 |
#ifdef SIGKILL |
|
1135 | 1175 |
RETURN ( __MKSMALLINT(SIGKILL) ); |
616 | 1176 |
#else |
1135 | 1177 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1178 |
#endif |
1179 |
%} |
|
1180 |
! |
|
1181 |
||
1182 |
sigLOST |
|
1183 |
"return the signal number for SIGLOST - 0 if not supported |
|
1184 |
(the numeric value is not the same across unix-systems)" |
|
1185 |
||
1186 |
%{ /* NOCONTEXT */ |
|
1187 |
#if defined(SIGLOST) |
|
1135 | 1188 |
RETURN ( __MKSMALLINT(SIGLOST) ); |
616 | 1189 |
#else |
1135 | 1190 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1191 |
#endif |
1192 |
%} |
|
1193 |
! |
|
1194 |
||
1195 |
sigMIGRATE |
|
1196 |
"return the signal number for SIGMIGRATE - 0 if not supported |
|
1197 |
(seems to be an AIX special)" |
|
1198 |
||
1199 |
%{ /* NOCONTEXT */ |
|
1200 |
#if defined(SIGMIGRATE) |
|
1135 | 1201 |
RETURN ( __MKSMALLINT(SIGMIGRATE) ); |
616 | 1202 |
#else |
1135 | 1203 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1204 |
#endif |
1205 |
%} |
|
1206 |
! |
|
1207 |
||
1208 |
sigMSG |
|
1209 |
"return the signal number for SIGMSG - 0 if not supported |
|
1210 |
(seems to be an AIX special)" |
|
1211 |
||
1212 |
%{ /* NOCONTEXT */ |
|
1213 |
#if defined(SIGMSG) |
|
1135 | 1214 |
RETURN ( __MKSMALLINT(SIGMSG) ); |
616 | 1215 |
#else |
1135 | 1216 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1217 |
#endif |
1218 |
%} |
|
1219 |
! |
|
1220 |
||
1221 |
sigPIPE |
|
1222 |
"return the signal number for SIGPIPE - 0 if not supported |
|
1223 |
(the numeric value is not the same across unix-systems)" |
|
1224 |
||
1225 |
%{ /* NOCONTEXT */ |
|
1226 |
#ifdef SIGPIPE |
|
1135 | 1227 |
RETURN ( __MKSMALLINT(SIGPIPE) ); |
616 | 1228 |
#else |
1135 | 1229 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1230 |
#endif |
1231 |
%} |
|
1232 |
! |
|
1233 |
||
1234 |
sigPOLL |
|
1235 |
"return the signal number for SIGPOLL - 0 if not supported |
|
1236 |
(the numeric value is not the same across unix-systems)" |
|
1237 |
||
1238 |
%{ /* NOCONTEXT */ |
|
1239 |
#if defined(SIGPOLL) |
|
1135 | 1240 |
RETURN ( __MKSMALLINT(SIGPOLL) ); |
616 | 1241 |
#else |
1135 | 1242 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1243 |
#endif |
1244 |
%} |
|
1245 |
! |
|
1246 |
||
1247 |
sigPRE |
|
1248 |
"return the signal number for SIGPRE - 0 if not supported |
|
1249 |
(seems to be an AIX special)" |
|
1250 |
||
1251 |
%{ /* NOCONTEXT */ |
|
1252 |
#if defined(SIGPRE) |
|
1135 | 1253 |
RETURN ( __MKSMALLINT(SIGPRE) ); |
616 | 1254 |
#else |
1135 | 1255 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1256 |
#endif |
1257 |
%} |
|
1258 |
! |
|
1259 |
||
1260 |
sigPROF |
|
1261 |
"return the signal number for SIGPROF - 0 if not supported |
|
1262 |
(the numeric value is not the same across unix-systems)" |
|
1263 |
||
1264 |
%{ /* NOCONTEXT */ |
|
1265 |
#if defined(SIGPROF) |
|
1135 | 1266 |
RETURN ( __MKSMALLINT(SIGPROF) ); |
616 | 1267 |
#else |
1135 | 1268 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1269 |
#endif |
1270 |
%} |
|
1271 |
! |
|
1272 |
||
1273 |
sigPWR |
|
1274 |
"return the signal number for SIGPWR - 0 if not supported |
|
1275 |
(not available on all systems)" |
|
1276 |
||
1277 |
%{ /* NOCONTEXT */ |
|
1278 |
#if defined(SIGPWR) |
|
1135 | 1279 |
RETURN ( __MKSMALLINT(SIGPWR) ); |
616 | 1280 |
#else |
1135 | 1281 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1282 |
#endif |
1283 |
%} |
|
1284 |
! |
|
1285 |
||
1286 |
sigQUIT |
|
1287 |
"return the signal number for SIGQUIT |
|
1288 |
(the numeric value is not the same across unix-systems)" |
|
1289 |
||
1290 |
%{ /* NOCONTEXT */ |
|
1291 |
#ifdef SIGQUIT |
|
1135 | 1292 |
RETURN ( __MKSMALLINT(SIGQUIT) ); |
616 | 1293 |
#else |
1135 | 1294 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1295 |
#endif |
1296 |
%} |
|
1297 |
! |
|
1298 |
||
1299 |
sigRETRACT |
|
1300 |
"return the signal number for SIGRETRACT - 0 if not supported |
|
1301 |
(seems to be an AIX special)" |
|
1302 |
||
1303 |
%{ /* NOCONTEXT */ |
|
1304 |
#if defined(SIGRETRACT) |
|
1135 | 1305 |
RETURN ( __MKSMALLINT(SIGRETRACT) ); |
616 | 1306 |
#else |
1135 | 1307 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1308 |
#endif |
1309 |
%} |
|
1310 |
! |
|
1311 |
||
1312 |
sigSAK |
|
1313 |
"return the signal number for SIGSAK - 0 if not supported |
|
1314 |
(seems to be an AIX special)" |
|
1315 |
||
1316 |
%{ /* NOCONTEXT */ |
|
1317 |
#if defined(SIGSAK) |
|
1135 | 1318 |
RETURN ( __MKSMALLINT(SIGSAK) ); |
616 | 1319 |
#else |
1135 | 1320 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1321 |
#endif |
1322 |
%} |
|
1323 |
! |
|
1324 |
||
1325 |
sigSEGV |
|
1326 |
"return the signal number for SIGSEGV - 0 if not supported |
|
1327 |
(the numeric value is not the same across unix-systems)" |
|
1328 |
||
1329 |
%{ /* NOCONTEXT */ |
|
1330 |
#ifdef SIGSEGV |
|
1135 | 1331 |
RETURN ( __MKSMALLINT(SIGSEGV) ); |
616 | 1332 |
#else |
1135 | 1333 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1334 |
#endif |
1335 |
%} |
|
1336 |
! |
|
1337 |
||
1338 |
sigSOUND |
|
1339 |
"return the signal number for SIGSOUND - 0 if not supported |
|
1340 |
(seems to be an AIX special)" |
|
1341 |
||
1342 |
%{ /* NOCONTEXT */ |
|
1343 |
#if defined(SIGSOUND) |
|
1135 | 1344 |
RETURN ( __MKSMALLINT(SIGSOUND) ); |
616 | 1345 |
#else |
1135 | 1346 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1347 |
#endif |
1348 |
%} |
|
1349 |
! |
|
1350 |
||
1351 |
sigSTOP |
|
1352 |
"return the signal number for SIGSTOP - 0 if not supported |
|
1353 |
(the numeric value is not the same across unix-systems)" |
|
1354 |
||
1355 |
%{ /* NOCONTEXT */ |
|
1356 |
#if defined(SIGSTOP) |
|
1135 | 1357 |
RETURN ( __MKSMALLINT(SIGSTOP) ); |
616 | 1358 |
#else |
1135 | 1359 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1360 |
#endif |
1361 |
%} |
|
1362 |
! |
|
1363 |
||
1364 |
sigSYS |
|
1365 |
"return the signal number for SIGSYS - 0 if not supported |
|
1366 |
(the numeric value is not the same across unix-systems)" |
|
1367 |
||
1368 |
%{ /* NOCONTEXT */ |
|
1369 |
#ifdef SIGSYS |
|
1135 | 1370 |
RETURN ( __MKSMALLINT(SIGSYS) ); |
616 | 1371 |
#else |
1135 | 1372 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1373 |
#endif |
1374 |
%} |
|
1375 |
! |
|
1376 |
||
1377 |
sigTERM |
|
1378 |
"return the signal number for SIGTERM - 0 if not supported |
|
1379 |
(the numeric value is not the same across unix-systems)" |
|
1380 |
||
1381 |
%{ /* NOCONTEXT */ |
|
1382 |
#ifdef SIGTERM |
|
1135 | 1383 |
RETURN ( __MKSMALLINT(SIGTERM) ); |
616 | 1384 |
#else |
1135 | 1385 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1386 |
#endif |
1387 |
%} |
|
1388 |
! |
|
1389 |
||
1390 |
sigTRAP |
|
1391 |
"return the signal number for SIGTRAP - 0 if not supported by OS |
|
1392 |
(the numeric value is not the same across unix-systems)" |
|
1393 |
||
1394 |
%{ /* NOCONTEXT */ |
|
1395 |
#ifdef SIGTRAP |
|
1135 | 1396 |
RETURN ( __MKSMALLINT(SIGTRAP) ); |
616 | 1397 |
#else |
1135 | 1398 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1399 |
#endif |
1400 |
%} |
|
1401 |
! |
|
1402 |
||
1403 |
sigTSTP |
|
1404 |
"return the signal number for SIGTSTP - 0 if not supported |
|
1405 |
(the numeric value is not the same across unix-systems)" |
|
1406 |
||
1407 |
%{ /* NOCONTEXT */ |
|
1408 |
#if defined(SIGTSTP) |
|
1135 | 1409 |
RETURN ( __MKSMALLINT(SIGTSTP) ); |
616 | 1410 |
#else |
1135 | 1411 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1412 |
#endif |
1413 |
%} |
|
1414 |
! |
|
1415 |
||
1416 |
sigTTIN |
|
1417 |
"return the signal number for SIGTTIN - 0 if not supported |
|
1418 |
(the numeric value is not the same across unix-systems)" |
|
1419 |
||
1420 |
%{ /* NOCONTEXT */ |
|
1421 |
#if defined(SIGTTIN) |
|
1135 | 1422 |
RETURN ( __MKSMALLINT(SIGTTIN) ); |
616 | 1423 |
#else |
1135 | 1424 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1425 |
#endif |
1426 |
%} |
|
1427 |
! |
|
1428 |
||
1429 |
sigTTOU |
|
1430 |
"return the signal number for SIGTTOU - 0 if not supported |
|
1431 |
(the numeric value is not the same across unix-systems)" |
|
1432 |
||
1433 |
%{ /* NOCONTEXT */ |
|
1434 |
#if defined(SIGTTOU) |
|
1135 | 1435 |
RETURN ( __MKSMALLINT(SIGTTOU) ); |
616 | 1436 |
#else |
1135 | 1437 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1438 |
#endif |
1439 |
%} |
|
1440 |
! |
|
1441 |
||
1442 |
sigURG |
|
1443 |
"return the signal number for SIGURG - 0 if not supported |
|
1444 |
(the numeric value is not the same across unix-systems)" |
|
1445 |
||
1446 |
%{ /* NOCONTEXT */ |
|
1447 |
#if defined(SIGURG) |
|
1135 | 1448 |
RETURN ( __MKSMALLINT(SIGURG) ); |
616 | 1449 |
#else |
1135 | 1450 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1451 |
#endif |
1452 |
%} |
|
1453 |
! |
|
1454 |
||
1455 |
sigUSR1 |
|
1456 |
"return the signal number for SIGUSR1 - 0 if not supported |
|
1457 |
(the numeric value is not the same across unix-systems)" |
|
1458 |
||
1459 |
%{ /* NOCONTEXT */ |
|
1460 |
#if defined(SIGUSR1) |
|
1135 | 1461 |
RETURN ( __MKSMALLINT(SIGUSR1) ); |
616 | 1462 |
#else |
1135 | 1463 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1464 |
#endif |
1465 |
%} |
|
1466 |
! |
|
1467 |
||
1468 |
sigUSR2 |
|
1469 |
"return the signal number for SIGUSR2 - 0 if not supported |
|
1470 |
(the numeric value is not the same across unix-systems)" |
|
1471 |
||
1472 |
%{ /* NOCONTEXT */ |
|
1473 |
#if defined(SIGUSR2) |
|
1135 | 1474 |
RETURN ( __MKSMALLINT(SIGUSR2) ); |
616 | 1475 |
#else |
1135 | 1476 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1477 |
#endif |
1478 |
%} |
|
1479 |
! |
|
1480 |
||
1481 |
sigVTALRM |
|
1482 |
"return the signal number for SIGVTALRM - 0 if not supported |
|
1483 |
(the numeric value is not the same across unix-systems)" |
|
1484 |
||
1485 |
%{ /* NOCONTEXT */ |
|
1486 |
#if defined(SIGVTALRM) |
|
1135 | 1487 |
RETURN ( __MKSMALLINT(SIGVTALRM) ); |
616 | 1488 |
#else |
1135 | 1489 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1490 |
#endif |
1491 |
%} |
|
1492 |
! |
|
1493 |
||
1494 |
sigWINCH |
|
1495 |
"return the signal number for SIGWINCH - 0 if not supported |
|
1496 |
(the numeric value is not the same across unix-systems)" |
|
1497 |
||
1498 |
%{ /* NOCONTEXT */ |
|
1499 |
#if defined(SIGWINCH) |
|
1135 | 1500 |
RETURN ( __MKSMALLINT(SIGWINCH) ); |
616 | 1501 |
#else |
1135 | 1502 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1503 |
#endif |
1504 |
%} |
|
1505 |
! |
|
1506 |
||
1507 |
sigXCPU |
|
1508 |
"return the signal number for SIGXCPU - 0 if not supported |
|
1509 |
(the numeric value is not the same across unix-systems)" |
|
1510 |
||
1511 |
%{ /* NOCONTEXT */ |
|
1512 |
#if defined(SIGXCPU) |
|
1135 | 1513 |
RETURN ( __MKSMALLINT(SIGXCPU) ); |
616 | 1514 |
#else |
1135 | 1515 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1516 |
#endif |
1517 |
%} |
|
1518 |
! |
|
1519 |
||
1520 |
sigXFSZ |
|
1521 |
"return the signal number for SIGXFSZ - 0 if not supported |
|
1522 |
(the numeric value is not the same across unix-systems)" |
|
1523 |
||
1524 |
%{ /* NOCONTEXT */ |
|
1525 |
#if defined(SIGXFSZ) |
|
1135 | 1526 |
RETURN ( __MKSMALLINT(SIGXFSZ) ); |
616 | 1527 |
#else |
1135 | 1528 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1529 |
#endif |
1530 |
%} |
|
1531 |
! ! |
|
1532 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
1533 |
!OperatingSystem class methodsFor:'Signal constants'! |
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1534 |
|
616 | 1535 |
accessDeniedErrorSignal |
1536 |
"return the signal raised when a (file-) access is denied." |
|
1537 |
||
1538 |
^ AccessDeniedErrorSignal |
|
1539 |
! |
|
1540 |
||
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1541 |
errorSignal |
1247 | 1542 |
"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
|
1543 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1544 |
^ ErrorSignal |
1247 | 1545 |
|
1546 |
"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
|
1547 |
! |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1548 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1549 |
fileNotFoundErrorSignal |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1550 |
"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
|
1551 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1552 |
^ FileNotFoundErrorSignal |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1553 |
! ! |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1554 |
|
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
1555 |
!OperatingSystem class methodsFor:'error messages'! |
1 | 1556 |
|
1153
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1557 |
clearLastErrorNumber |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1558 |
"return the last errors number. |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1559 |
See also: #lastErrorSymbol and #lastErrorString. |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1560 |
Notice: having a single error number is a bad idea in a multithreaded |
1487 | 1561 |
environment - this interface will change." |
1153
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 |
LastErrorNumber := nil. |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1564 |
|
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 |
OperatingSystem clearLastErrorNumber |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1567 |
" |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1568 |
|
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1569 |
"Created: 12.4.1996 / 09:28:58 / stefan" |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1570 |
"Modified: 12.4.1996 / 09:38:51 / stefan" |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1571 |
! |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1572 |
|
85 | 1573 |
currentErrorNumber |
68 | 1574 |
"returns the OS's last error nr (i.e. the value of errno). |
1575 |
Notice, that the value of this flag is only valid immediately |
|
1576 |
after the error occurred - it gets updated with every other |
|
85 | 1577 |
request to the OS. |
1578 |
Use lastErrorNumber - currentErrorNumber is invalidated by |
|
1579 |
many, many internal calls." |
|
68 | 1580 |
|
1581 |
%{ /* NOCONTEXT */ |
|
1582 |
||
1135 | 1583 |
RETURN ( __MKSMALLINT(errno) ); |
68 | 1584 |
%} |
1585 |
" |
|
85 | 1586 |
OperatingSystem currentErrorNumber |
1587 |
" |
|
1588 |
! |
|
1589 |
||
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1590 |
errorNumberFor:aSymbol |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1591 |
"given a symbolic error, return the numeric; |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1592 |
(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
|
1593 |
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
|
1594 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1595 |
%{ /* NOCONTEXT */ |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1596 |
OBJ sym = aSymbol; |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1597 |
|
1058
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 |
* POSIX errnos - these should be defined |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1600 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1601 |
#ifdef EPERM |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1602 |
if (sym == @symbol(EPERM)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1603 |
RETURN ( __MKSMALLINT(EPERM) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1606 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1607 |
#ifdef ENOENT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1608 |
if (sym == @symbol(ENOENT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1609 |
RETURN ( __MKSMALLINT(ENOENT) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1612 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1613 |
#ifdef ESRCH |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1614 |
if (sym == @symbol(ESRCH)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1615 |
RETURN ( __MKSMALLINT(ESRCH) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1618 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1619 |
#ifdef EINTR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1620 |
if (sym == @symbol(EINTR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1621 |
RETURN ( __MKSMALLINT(EINTR) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1624 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1625 |
#ifdef EIO |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1626 |
if (sym == @symbol(EIO)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1627 |
RETURN ( __MKSMALLINT(EIO) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1630 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1631 |
#ifdef ENXIO |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1632 |
if (sym == @symbol(ENXIO)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1633 |
RETURN ( __MKSMALLINT(ENXIO) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1636 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1637 |
#ifdef E2BIG |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1638 |
if (sym == @symbol(E2BIG)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1639 |
RETURN ( __MKSMALLINT(E2BIG) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1642 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1643 |
#ifdef ENOEXEC |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1644 |
if (sym == @symbol(ENOEXEC)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1645 |
RETURN ( __MKSMALLINT(ENOEXEC) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1648 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1649 |
#ifdef EBADF |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1650 |
if (sym == @symbol(EBADF)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1651 |
RETURN ( __MKSMALLINT(EBADF) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1654 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1655 |
#ifdef ECHILD |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1656 |
if (sym == @symbol(ECHILD)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1657 |
RETURN ( __MKSMALLINT(ECHILD) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1660 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1661 |
#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
|
1662 |
if (sym == @symbol(EAGAIN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1663 |
RETURN ( __MKSMALLINT(EAGAIN) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1666 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1667 |
#ifdef ENOMEM |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1668 |
if (sym == @symbol(ENOMEM)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1669 |
RETURN ( __MKSMALLINT(ENOMEM) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1672 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1673 |
#ifdef EACCES |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1674 |
if (sym == @symbol(EACCES)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1675 |
RETURN ( __MKSMALLINT(EACCES) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1678 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1679 |
#ifdef EFAULT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1680 |
if (sym == @symbol(EFAULT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1681 |
RETURN ( __MKSMALLINT(EFAULT) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1684 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1685 |
#ifdef EBUSY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1686 |
if (sym == @symbol(EBUSY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1687 |
RETURN ( __MKSMALLINT(EBUSY) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1690 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1691 |
#ifdef EXDEV |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1692 |
if (sym == @symbol(EXDEV)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1693 |
RETURN ( __MKSMALLINT(EXDEV) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1696 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1697 |
#ifdef ENODEV |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1698 |
if (sym == @symbol(ENODEV)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1699 |
RETURN ( __MKSMALLINT(ENODEV) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1702 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1703 |
#ifdef ENOTDIR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1704 |
if (sym == @symbol(ENOTDIR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1705 |
RETURN ( __MKSMALLINT(ENOTDIR) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1708 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1709 |
#ifdef EISDIR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1710 |
if (sym == @symbol(EISDIR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1711 |
RETURN ( __MKSMALLINT(EISDIR) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1714 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1715 |
#ifdef EINVAL |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1716 |
if (sym == @symbol(EINVAL)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1717 |
RETURN ( __MKSMALLINT(EINVAL) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1720 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1721 |
#ifdef ENFILE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1722 |
if (sym == @symbol(ENFILE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1723 |
RETURN ( __MKSMALLINT(ENFILE) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1726 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1727 |
#ifdef EMFILE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1728 |
if (sym == @symbol(EMFILE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1729 |
RETURN ( __MKSMALLINT(EMFILE) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1732 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1733 |
#ifdef ENOTTY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1734 |
if (sym == @symbol(ENOTTY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1735 |
RETURN ( __MKSMALLINT(ENOTTY) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1738 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1739 |
#ifdef EFBIG |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1740 |
if (sym == @symbol(EFBIG)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1741 |
RETURN ( __MKSMALLINT(EFBIG) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1744 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1745 |
#ifdef ENOSPC |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1746 |
if (sym == @symbol(ENOSPC)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1747 |
RETURN ( __MKSMALLINT(ENOSPC) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1750 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1751 |
#ifdef ESPIPE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1752 |
if (sym == @symbol(ESPIPE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1753 |
RETURN ( __MKSMALLINT(ESPIPE) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1756 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1757 |
#ifdef EROFS |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1758 |
if (sym == @symbol(EROFS)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1759 |
RETURN ( __MKSMALLINT(EROFS) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1762 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1763 |
#ifdef EMLINK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1764 |
if (sym == @symbol(EMLINK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1765 |
RETURN ( __MKSMALLINT(EMLINK) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1768 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1769 |
#ifdef EPIPE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1770 |
if (sym == @symbol(EPIPE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1771 |
RETURN ( __MKSMALLINT(EPIPE) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1774 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1775 |
#ifdef EDOM |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1776 |
if (sym == @symbol(EDOM)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1777 |
RETURN ( __MKSMALLINT(EDOM) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1780 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1781 |
#ifdef ERANGE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1782 |
if (sym == @symbol(ERANGE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1783 |
RETURN ( __MKSMALLINT(ERANGE) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1786 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1787 |
#ifdef EDEADLK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1788 |
if (sym == @symbol(EDEADLK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1789 |
RETURN ( __MKSMALLINT(EDEADLK) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1792 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1793 |
#ifdef ENAMETOOLONG |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1794 |
if (sym == @symbol(ENAMETOOLONG)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1795 |
RETURN ( __MKSMALLINT(ENAMETOOLONG) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1798 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1799 |
#ifdef ENOLCK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1800 |
if (sym == @symbol(ENOLCK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1801 |
RETURN ( __MKSMALLINT(ENOLCK) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1804 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1805 |
#ifdef ENOSYS |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1806 |
if (sym == @symbol(ENOSYS)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1807 |
RETURN ( __MKSMALLINT(ENOSYS) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1810 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1811 |
#ifdef ENOTEMPTY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1812 |
if (sym == @symbol(ENOTEMPTY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1813 |
RETURN ( __MKSMALLINT(ENOTEMPTY) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1816 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1817 |
#ifdef EEXIST |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1818 |
if (sym == @symbol(EEXIST)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1819 |
RETURN ( __MKSMALLINT(EEXIST) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1822 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1823 |
#ifdef EILSEQ |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1824 |
if (sym == @symbol(EILSEQ)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1825 |
RETURN ( __MKSMALLINT(EILSEQ) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1828 |
|
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 |
* XPG3 errnos - defined on most systems |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1831 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1832 |
#ifdef ENOTBLK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1833 |
if (sym == @symbol(ENOTBLK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1834 |
RETURN ( __MKSMALLINT(ENOTBLK) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1837 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1838 |
#ifdef ETXTBSY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1839 |
if (sym == @symbol(ETXTBSY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1840 |
RETURN ( __MKSMALLINT(ETXTBSY) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1843 |
|
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 |
* some others |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1846 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1847 |
#ifdef EWOULDBLOCK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1848 |
if (sym == @symbol(EWOULDBLOCK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1849 |
RETURN ( __MKSMALLINT(EWOULDBLOCK) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1852 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1853 |
#ifdef ENOMSG |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1854 |
if (sym == @symbol(ENOMSG)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1855 |
RETURN ( __MKSMALLINT(ENOMSG) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1858 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1859 |
#ifdef ELOOP |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1860 |
if (sym == @symbol(ELOOP)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1861 |
RETURN ( __MKSMALLINT(ELOOP) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1864 |
|
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 |
* some stream errors |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1867 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1868 |
#ifdef ETIME |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1869 |
if (sym == @symbol(ETIME)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1870 |
RETURN ( __MKSMALLINT(ETIME) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1873 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1874 |
#ifdef ENOSR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1875 |
if (sym == @symbol(ENOSR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1876 |
RETURN ( __MKSMALLINT(ENOSR) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1879 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1880 |
#ifdef ENOSTR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1881 |
if (sym == @symbol(ENOSTR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1882 |
RETURN ( __MKSMALLINT(ENOSTR) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1885 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1886 |
#ifdef ECOMM |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1887 |
if (sym == @symbol(ECOMM)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1888 |
RETURN ( __MKSMALLINT(ECOMM) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1891 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1892 |
#ifdef EPROTO |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1893 |
if (sym == @symbol(EPROTO)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1894 |
RETURN ( __MKSMALLINT(EPROTO) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1897 |
|
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 |
* nfs errors |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1900 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1901 |
#ifdef ESTALE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1902 |
if (sym == @symbol(ESTALE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1903 |
RETURN ( __MKSMALLINT(ESTALE) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1906 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1907 |
#ifdef EREMOTE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1908 |
if (sym == @symbol(EREMOTE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1909 |
RETURN ( __MKSMALLINT(EREMOTE) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1912 |
|
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 |
* some networking errors |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1915 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1916 |
#ifdef EINPROGRESS |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1917 |
if (sym == @symbol(EINPROGRESS)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1918 |
RETURN ( __MKSMALLINT(EINPROGRESS) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1921 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1922 |
#ifdef EALREADY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1923 |
if (sym == @symbol(EALREADY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1924 |
RETURN ( __MKSMALLINT(EALREADY) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1927 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1928 |
#ifdef ENOTSOCK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1929 |
if (sym == @symbol(ENOTSOCK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1930 |
RETURN ( __MKSMALLINT(ENOTSOCK) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1933 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1934 |
#ifdef EDESTADDRREQ |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1935 |
if (sym == @symbol(EDESTADDRREQ)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1936 |
RETURN ( __MKSMALLINT(EDESTADDRREQ) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1939 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1940 |
#ifdef EMSGSIZE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1941 |
if (sym == @symbol(EMSGSIZE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1942 |
RETURN ( __MKSMALLINT(EMSGSIZE) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1945 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1946 |
#ifdef EPROTOTYPE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1947 |
if (sym == @symbol(EPROTOTYPE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1948 |
RETURN ( __MKSMALLINT(EPROTOTYPE) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1951 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1952 |
#ifdef ENOPROTOOPT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1953 |
if (sym == @symbol(ENOPROTOOPT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1954 |
RETURN ( __MKSMALLINT(ENOPROTOOPT) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1957 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1958 |
#ifdef EPROTONOSUPPORT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1959 |
if (sym == @symbol(EPROTONOSUPPORT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1960 |
RETURN ( __MKSMALLINT(EPROTONOSUPPORT) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1963 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1964 |
#ifdef ESOCKTNOSUPPORT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1965 |
if (sym == @symbol(ESOCKTNOSUPPORT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1966 |
RETURN ( __MKSMALLINT(ESOCKTNOSUPPORT) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1969 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1970 |
#ifdef EOPNOTSUPP |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1971 |
if (sym == @symbol(EOPNOTSUPP)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1972 |
RETURN ( __MKSMALLINT(EOPNOTSUPP) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1975 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1976 |
#ifdef EPFNOSUPPORT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1977 |
if (sym == @symbol(EPFNOSUPPORT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1978 |
RETURN ( __MKSMALLINT(EPFNOSUPPORT) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1981 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1982 |
#ifdef EAFNOSUPPORT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1983 |
if (sym == @symbol(EAFNOSUPPORT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1984 |
RETURN ( __MKSMALLINT(EAFNOSUPPORT) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1987 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1988 |
#ifdef EADDRINUSE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1989 |
if (sym == @symbol(EADDRINUSE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1990 |
RETURN ( __MKSMALLINT(EADDRINUSE) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1993 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1994 |
#ifdef EADDRNOTAVAIL |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1995 |
if (sym == @symbol(EADDRNOTAVAIL)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1996 |
RETURN ( __MKSMALLINT(EADDRNOTAVAIL) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1999 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2000 |
#ifdef ETIMEDOUT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2001 |
if (sym == @symbol(ETIMEDOUT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2002 |
RETURN ( __MKSMALLINT(ETIMEDOUT) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2005 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2006 |
#ifdef ECONNREFUSED |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2007 |
if (sym == @symbol(ECONNREFUSED)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2008 |
RETURN ( __MKSMALLINT(ECONNREFUSED) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2011 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2012 |
#ifdef ENETDOWN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2013 |
if (sym == @symbol(ENETDOWN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2014 |
RETURN ( __MKSMALLINT(ENETDOWN) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2017 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2018 |
#ifdef ENETUNREACH |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2019 |
if (sym == @symbol(ENETUNREACH)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2020 |
RETURN ( __MKSMALLINT(ENETUNREACH) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2023 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2024 |
#ifdef ENETRESET |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2025 |
if (sym == @symbol(ENETRESET)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2026 |
RETURN ( __MKSMALLINT(ENETRESET) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2029 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2030 |
#ifdef ECONNABORTED |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2031 |
if (sym == @symbol(ECONNABORTED)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2032 |
RETURN ( __MKSMALLINT(ECONNABORTED) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2035 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2036 |
#ifdef ECONNRESET |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2037 |
if (sym == @symbol(ECONNRESET)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2038 |
RETURN ( __MKSMALLINT(ECONNRESET) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2041 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2042 |
#ifdef EISCONN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2043 |
if (sym == @symbol(EISCONN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2044 |
RETURN ( __MKSMALLINT(EISCONN) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2047 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2048 |
#ifdef ENOTCONN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2049 |
if (sym == @symbol(ENOTCONN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2050 |
RETURN ( __MKSMALLINT(ENOTCONN) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2053 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2054 |
#ifdef ESHUTDOWN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2055 |
if (sym == @symbol(ESHUTDOWN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2056 |
RETURN ( __MKSMALLINT(ESHUTDOWN) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2059 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2060 |
#ifdef EHOSTDOWN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2061 |
if (sym == @symbol(EHOSTDOWN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2062 |
RETURN ( __MKSMALLINT(EHOSTDOWN) ); |
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 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2065 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2066 |
#ifdef EHOSTUNREACH |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2067 |
if (sym == @symbol(EHOSTUNREACH)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2068 |
RETURN ( __MKSMALLINT(EHOSTUNREACH) ); |
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 |
#endif |
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 |
^ -1 |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2073 |
! |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2074 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2075 |
errorSymbolAndTextForNumber:errNr |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2076 |
"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
|
2077 |
(as returned by a system call). |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2078 |
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
|
2079 |
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
|
2080 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2081 |
|sym text| |
1 | 2082 |
|
77 | 2083 |
%{ |
2084 |
/* claus: |
|
2085 |
* I made this some primitive code, since errnos are not |
|
2086 |
* standard across unixes |
|
2087 |
*/ |
|
2088 |
char *msg = "unknown error"; |
|
2089 |
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
|
2090 |
OBJ eno = errNr; |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2091 |
|
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2092 |
if (__isSmallInteger(eno)) { |
1135 | 2093 |
switch (__intVal(eno)) { |
185 | 2094 |
/* |
2095 |
* POSIX errnos - these should be defined |
|
2096 |
*/ |
|
443 | 2097 |
#ifdef EPERM |
185 | 2098 |
case EPERM: |
2099 |
msg = "Operation not permitted"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2100 |
sym = @symbol(EPERM); |
185 | 2101 |
break; |
443 | 2102 |
#endif |
2103 |
#ifdef ENOENT |
|
185 | 2104 |
case ENOENT: |
2105 |
msg = "No such file or directory"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2106 |
sym = @symbol(ENOENT); |
185 | 2107 |
break; |
443 | 2108 |
#endif |
2109 |
#ifdef ESRCH |
|
185 | 2110 |
case ESRCH: |
2111 |
msg = "No such process"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2112 |
sym = @symbol(ESRCH); |
185 | 2113 |
break; |
443 | 2114 |
#endif |
2115 |
#ifdef EINTR |
|
185 | 2116 |
case EINTR: |
2117 |
msg = "Interrupted system call"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2118 |
sym = @symbol(EINTR); |
185 | 2119 |
break; |
443 | 2120 |
#endif |
2121 |
#ifdef EIO |
|
185 | 2122 |
case EIO: |
2123 |
msg = "I/O error"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2124 |
sym = @symbol(EIO); |
185 | 2125 |
break; |
443 | 2126 |
#endif |
2127 |
#ifdef ENXIO |
|
185 | 2128 |
case ENXIO: |
2129 |
msg = "No such device or address"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2130 |
sym = @symbol(ENXIO); |
185 | 2131 |
break; |
443 | 2132 |
#endif |
2133 |
#ifdef E2BIG |
|
185 | 2134 |
case E2BIG: |
2135 |
msg = "Arg list too long"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2136 |
sym = @symbol(E2BIG); |
185 | 2137 |
break; |
443 | 2138 |
#endif |
2139 |
#ifdef ENOEXEC |
|
185 | 2140 |
case ENOEXEC: |
2141 |
msg = "Exec format error"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2142 |
sym = @symbol(ENOEXEC); |
185 | 2143 |
break; |
443 | 2144 |
#endif |
2145 |
#ifdef EBADF |
|
185 | 2146 |
case EBADF: |
2147 |
msg = "Bad file number"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2148 |
sym = @symbol(EBADF); |
185 | 2149 |
break; |
443 | 2150 |
#endif |
2151 |
#ifdef ECHILD |
|
185 | 2152 |
case ECHILD: |
2153 |
msg = "No child processes"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2154 |
sym = @symbol(ECHILD); |
185 | 2155 |
break; |
443 | 2156 |
#endif |
77 | 2157 |
#if !defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN) |
185 | 2158 |
case EAGAIN: |
2159 |
msg = "Try again"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2160 |
sym = @symbol(EAGAIN); |
185 | 2161 |
break; |
77 | 2162 |
#endif |
443 | 2163 |
#ifdef ENOMEM |
185 | 2164 |
case ENOMEM: |
2165 |
msg = "Out of memory"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2166 |
sym = @symbol(ENOMEM); |
185 | 2167 |
break; |
443 | 2168 |
#endif |
2169 |
#ifdef EACCES |
|
185 | 2170 |
case EACCES: |
2171 |
msg = "Permission denied"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2172 |
sym = @symbol(EACCES); |
185 | 2173 |
break; |
443 | 2174 |
#endif |
2175 |
#ifdef EFAULT |
|
185 | 2176 |
case EFAULT: |
2177 |
msg = "Bad address"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2178 |
sym = @symbol(EFAULT); |
185 | 2179 |
break; |
443 | 2180 |
#endif |
2181 |
#ifdef EBUSY |
|
185 | 2182 |
case EBUSY: |
2183 |
msg = "Device or resource busy"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2184 |
sym = @symbol(EBUSY); |
185 | 2185 |
break; |
443 | 2186 |
#endif |
2187 |
#ifdef EEXIST |
|
185 | 2188 |
case EEXIST: |
2189 |
msg = "File exists"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2190 |
sym = @symbol(EEXIST); |
185 | 2191 |
break; |
443 | 2192 |
#endif |
2193 |
#ifdef EXDEV |
|
185 | 2194 |
case EXDEV: |
2195 |
msg = "Cross-device link"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2196 |
sym = @symbol(EXDEV); |
185 | 2197 |
break; |
443 | 2198 |
#endif |
2199 |
#ifdef ENODEV |
|
185 | 2200 |
case ENODEV: |
2201 |
msg = "No such device"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2202 |
sym = @symbol(ENODEV); |
185 | 2203 |
break; |
443 | 2204 |
#endif |
2205 |
#ifdef ENOTDIR |
|
185 | 2206 |
case ENOTDIR: |
2207 |
msg = "Not a directory"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2208 |
sym = @symbol(ENOTDIR); |
185 | 2209 |
break; |
443 | 2210 |
#endif |
2211 |
#ifdef EISDIR |
|
185 | 2212 |
case EISDIR: |
2213 |
msg = "Is a directory"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2214 |
sym = @symbol(EISDIR); |
185 | 2215 |
break; |
443 | 2216 |
#endif |
2217 |
#ifdef EINVAL |
|
185 | 2218 |
case EINVAL: |
2219 |
msg = "Invalid argument"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2220 |
sym = @symbol(EINVAL); |
185 | 2221 |
break; |
443 | 2222 |
#endif |
2223 |
#ifdef ENFILE |
|
185 | 2224 |
case ENFILE: |
2225 |
msg = "File table overflow"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2226 |
sym = @symbol(ENFILE); |
185 | 2227 |
break; |
443 | 2228 |
#endif |
2229 |
#ifdef EMFILE |
|
185 | 2230 |
case EMFILE: |
2231 |
msg = "Too many open files"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2232 |
sym = @symbol(EMFILE); |
185 | 2233 |
break; |
443 | 2234 |
#endif |
2235 |
#ifdef ENOTTY |
|
185 | 2236 |
case ENOTTY: |
2237 |
msg = "Not a typewriter"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2238 |
sym = @symbol(ENOTTY); |
185 | 2239 |
break; |
443 | 2240 |
#endif |
2241 |
#ifdef EFBIG |
|
185 | 2242 |
case EFBIG: |
2243 |
msg = "File too large"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2244 |
sym = @symbol(EFBIG); |
185 | 2245 |
break; |
443 | 2246 |
#endif |
2247 |
#ifdef ENOSPC |
|
185 | 2248 |
case ENOSPC: |
2249 |
msg = "No space left on device"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2250 |
sym = @symbol(ENOSPC); |
185 | 2251 |
break; |
443 | 2252 |
#endif |
2253 |
#ifdef ESPIPE |
|
185 | 2254 |
case ESPIPE: |
2255 |
msg = "Illegal seek"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2256 |
sym = @symbol(ESPIPE); |
185 | 2257 |
break; |
443 | 2258 |
#endif |
2259 |
#ifdef EROFS |
|
185 | 2260 |
case EROFS: |
2261 |
msg = "Read-only file system"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2262 |
sym = @symbol(EROFS); |
185 | 2263 |
break; |
443 | 2264 |
#endif |
2265 |
#ifdef EMLINK |
|
185 | 2266 |
case EMLINK: |
2267 |
msg = "Too many links"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2268 |
sym = @symbol(EMLINK); |
185 | 2269 |
break; |
443 | 2270 |
#endif |
2271 |
#ifdef EPIPE |
|
185 | 2272 |
case EPIPE: |
2273 |
msg = "Broken pipe"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2274 |
sym = @symbol(EPIPE); |
185 | 2275 |
break; |
443 | 2276 |
#endif |
2277 |
#ifdef EDOM |
|
185 | 2278 |
case EDOM: |
2279 |
msg = "Math argument out of domain"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2280 |
sym = @symbol(EDOM); |
185 | 2281 |
break; |
443 | 2282 |
#endif |
2283 |
#ifdef ERANGE |
|
185 | 2284 |
case ERANGE: |
2285 |
msg = "Math result not representable"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2286 |
sym = @symbol(ERANGE); |
185 | 2287 |
break; |
443 | 2288 |
#endif |
77 | 2289 |
#ifdef EDEADLK |
308 | 2290 |
# if EDEADLK != EWOULDBLOCK |
185 | 2291 |
case EDEADLK: |
2292 |
msg = "Resource deadlock would occur"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2293 |
sym = @symbol(EDEADLK); |
185 | 2294 |
break; |
308 | 2295 |
# endif |
77 | 2296 |
#endif |
2297 |
#ifdef ENAMETOOLONG |
|
185 | 2298 |
case ENAMETOOLONG: |
2299 |
msg = "File name too long"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2300 |
sym = @symbol(ENAMETOOLONG); |
185 | 2301 |
break; |
77 | 2302 |
#endif |
2303 |
#ifdef ENOLCK |
|
185 | 2304 |
case ENOLCK: |
2305 |
msg = "No record locks available"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2306 |
sym = @symbol(ENOLCK); |
185 | 2307 |
break; |
77 | 2308 |
#endif |
2309 |
#ifdef ENOSYS |
|
185 | 2310 |
case ENOSYS: |
2311 |
msg = "Function not implemented"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2312 |
sym = @symbol(ENOSYS); |
185 | 2313 |
break; |
77 | 2314 |
#endif |
359 | 2315 |
#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST) |
185 | 2316 |
case ENOTEMPTY: |
2317 |
msg = "Directory not empty"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2318 |
sym = @symbol(ENOTEMPTY); |
185 | 2319 |
break; |
77 | 2320 |
#endif |
2321 |
#ifdef EILSEQ |
|
185 | 2322 |
case EILSEQ: |
2323 |
msg = "Illegal byte sequence"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2324 |
sym = @symbol(EILSEQ); |
185 | 2325 |
break; |
77 | 2326 |
#endif |
185 | 2327 |
/* |
2328 |
* XPG3 errnos - defined on most systems |
|
2329 |
*/ |
|
77 | 2330 |
#ifdef ENOTBLK |
185 | 2331 |
case ENOTBLK: |
2332 |
msg = "Block device required"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2333 |
sym = @symbol(ENOTBLK); |
185 | 2334 |
break; |
77 | 2335 |
#endif |
2336 |
#ifdef ETXTBSY |
|
185 | 2337 |
case ETXTBSY: |
2338 |
msg = "Text file busy"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2339 |
sym = @symbol(ETXTBSY); |
185 | 2340 |
break; |
77 | 2341 |
#endif |
185 | 2342 |
/* |
2343 |
* some others |
|
2344 |
*/ |
|
77 | 2345 |
#ifdef EWOULDBLOCK |
185 | 2346 |
case EWOULDBLOCK: |
2347 |
msg = "Operation would block"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2348 |
sym = @symbol(EWOULDBLOCK); |
185 | 2349 |
break; |
77 | 2350 |
#endif |
2351 |
#ifdef ENOMSG |
|
185 | 2352 |
case ENOMSG: |
2353 |
msg = "No message of desired type"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2354 |
sym = @symbol(ENOMSG); |
185 | 2355 |
break; |
77 | 2356 |
#endif |
2357 |
#ifdef ELOOP |
|
185 | 2358 |
case ELOOP: |
2359 |
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
|
2360 |
sym = @symbol(ELOOP); |
185 | 2361 |
break; |
77 | 2362 |
#endif |
2363 |
||
185 | 2364 |
/* |
2365 |
* some stream errors |
|
2366 |
*/ |
|
77 | 2367 |
#ifdef ETIME |
185 | 2368 |
case ETIME: |
2369 |
msg = "Timer expired"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2370 |
sym = @symbol(ETIME); |
185 | 2371 |
break; |
77 | 2372 |
#endif |
2373 |
#ifdef ENOSR |
|
185 | 2374 |
case ENOSR: |
2375 |
msg = "Out of streams resources"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2376 |
sym = @symbol(ENOSR); |
185 | 2377 |
break; |
77 | 2378 |
#endif |
2379 |
#ifdef ENOSTR |
|
185 | 2380 |
case ENOSTR: |
2381 |
msg = "Device not a stream"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2382 |
sym = @symbol(ENOSTR); |
185 | 2383 |
break; |
77 | 2384 |
#endif |
2385 |
#ifdef ECOMM |
|
185 | 2386 |
case ECOMM: |
2387 |
msg = "Communication error on send"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2388 |
sym = @symbol(ECOMM); |
185 | 2389 |
break; |
77 | 2390 |
#endif |
2391 |
#ifdef EPROTO |
|
185 | 2392 |
case EPROTO: |
2393 |
msg = "Protocol error"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2394 |
sym = @symbol(EPROTO); |
185 | 2395 |
break; |
77 | 2396 |
#endif |
185 | 2397 |
/* |
2398 |
* nfs errors |
|
2399 |
*/ |
|
77 | 2400 |
#ifdef ESTALE |
185 | 2401 |
case ESTALE: |
2402 |
msg = "Stale NFS file handle"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2403 |
sym = @symbol(ESTALE); |
185 | 2404 |
break; |
77 | 2405 |
#endif |
2406 |
#ifdef EREMOTE |
|
185 | 2407 |
case EREMOTE: |
2408 |
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
|
2409 |
sym = @symbol(EREMOTE); |
185 | 2410 |
break; |
77 | 2411 |
#endif |
185 | 2412 |
/* |
2413 |
* some networking errors |
|
2414 |
*/ |
|
77 | 2415 |
#ifdef EINPROGRESS |
185 | 2416 |
case EINPROGRESS: |
2417 |
msg = "Operation now in progress"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2418 |
sym = @symbol(EINPROGRESS); |
185 | 2419 |
break; |
77 | 2420 |
#endif |
2421 |
#ifdef EALREADY |
|
185 | 2422 |
case EALREADY: |
2423 |
msg = "Operation already in progress"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2424 |
sym = @symbol(EALREADY); |
185 | 2425 |
break; |
77 | 2426 |
#endif |
2427 |
#ifdef ENOTSOCK |
|
185 | 2428 |
case ENOTSOCK: |
2429 |
msg = "Socket operation on non-socket"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2430 |
sym = @symbol(ENOTSOCK); |
185 | 2431 |
break; |
77 | 2432 |
#endif |
2433 |
#ifdef EDESTADDRREQ |
|
185 | 2434 |
case EDESTADDRREQ: |
2435 |
msg = "Destination address required"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2436 |
sym = @symbol(EDESTADDRREQ); |
185 | 2437 |
break; |
77 | 2438 |
#endif |
2439 |
#ifdef EMSGSIZE |
|
185 | 2440 |
case EMSGSIZE: |
2441 |
msg = "Message too long"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2442 |
sym = @symbol(EMSGSIZE); |
185 | 2443 |
break; |
77 | 2444 |
#endif |
2445 |
#ifdef EPROTOTYPE |
|
185 | 2446 |
case EPROTOTYPE: |
2447 |
msg = "Protocol wrong type for socket"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2448 |
sym = @symbol(EPROTOTYPE); |
185 | 2449 |
break; |
77 | 2450 |
#endif |
2451 |
#ifdef ENOPROTOOPT |
|
185 | 2452 |
case ENOPROTOOPT: |
2453 |
msg = "Protocol not available"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2454 |
sym = @symbol(ENOPROTOOPT); |
185 | 2455 |
break; |
77 | 2456 |
#endif |
2457 |
#ifdef EPROTONOSUPPORT |
|
185 | 2458 |
case EPROTONOSUPPORT: |
2459 |
msg = "Protocol not supported"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2460 |
sym = @symbol(EPROTONOSUPPORT); |
185 | 2461 |
break; |
77 | 2462 |
#endif |
2463 |
#ifdef ESOCKTNOSUPPORT |
|
185 | 2464 |
case ESOCKTNOSUPPORT: |
2465 |
msg = "Socket type not supported"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2466 |
sym = @symbol(ESOCKTNOSUPPORT); |
185 | 2467 |
break; |
77 | 2468 |
#endif |
2469 |
#ifdef EOPNOTSUPP |
|
185 | 2470 |
case EOPNOTSUPP: |
2471 |
msg = "Operation not supported on socket"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2472 |
sym = @symbol(EOPNOTSUPP); |
185 | 2473 |
break; |
77 | 2474 |
#endif |
2475 |
#ifdef EPFNOSUPPORT |
|
185 | 2476 |
case EPFNOSUPPORT: |
2477 |
msg = "Protocol family not supported"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2478 |
sym = @symbol(EPFNOSUPPORT); |
185 | 2479 |
break; |
77 | 2480 |
#endif |
2481 |
#ifdef EAFNOSUPPORT |
|
185 | 2482 |
case EAFNOSUPPORT: |
2483 |
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
|
2484 |
sym = @symbol(EAFNOSUPPORT); |
185 | 2485 |
break; |
77 | 2486 |
#endif |
2487 |
#ifdef EADDRINUSE |
|
185 | 2488 |
case EADDRINUSE: |
2489 |
msg = "Address already in use"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2490 |
sym = @symbol(EADDRINUSE); |
185 | 2491 |
break; |
77 | 2492 |
#endif |
2493 |
#ifdef EADDRNOTAVAIL |
|
185 | 2494 |
case EADDRNOTAVAIL: |
2495 |
msg = "Can\'t assign requested address"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2496 |
sym = @symbol(EADDRNOTAVAIL); |
185 | 2497 |
break; |
77 | 2498 |
#endif |
2499 |
#ifdef ETIMEDOUT |
|
185 | 2500 |
case ETIMEDOUT: |
2501 |
msg = "Connection timed out"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2502 |
sym = @symbol(ETIMEDOUT); |
185 | 2503 |
break; |
77 | 2504 |
#endif |
2505 |
#ifdef ECONNREFUSED |
|
185 | 2506 |
case ECONNREFUSED: |
2507 |
msg = "Connection refused"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2508 |
sym = @symbol(ECONNREFUSED); |
185 | 2509 |
break; |
77 | 2510 |
#endif |
362 | 2511 |
#ifdef ENETDOWN |
2512 |
case ENETDOWN: |
|
2513 |
msg = "Network is down"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2514 |
sym = @symbol(ENETDOWN); |
362 | 2515 |
break; |
2516 |
#endif |
|
2517 |
#ifdef ENETUNREACH |
|
2518 |
case ENETUNREACH: |
|
2519 |
msg = "Network is unreachable"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2520 |
sym = @symbol(ENETUNREACH); |
362 | 2521 |
break; |
2522 |
#endif |
|
2523 |
#ifdef ENETRESET |
|
2524 |
case ENETRESET: |
|
2525 |
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
|
2526 |
sym = @symbol(ENETRESET); |
362 | 2527 |
break; |
2528 |
#endif |
|
2529 |
#ifdef ECONNABORTED |
|
2530 |
case ECONNABORTED: |
|
2531 |
msg = "Software caused connection abort"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2532 |
sym = @symbol(ECONNABORTED); |
362 | 2533 |
break; |
2534 |
#endif |
|
2535 |
#ifdef ECONNRESET |
|
2536 |
case ECONNRESET: |
|
2537 |
msg = "Connection reset by peer"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2538 |
sym = @symbol(ECONNRESET); |
362 | 2539 |
break; |
2540 |
#endif |
|
2541 |
#ifdef EISCONN |
|
2542 |
case EISCONN: |
|
2543 |
msg = "Socket is already connected"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2544 |
sym = @symbol(EISCONN); |
362 | 2545 |
break; |
2546 |
#endif |
|
2547 |
#ifdef ENOTCONN |
|
2548 |
case ENOTCONN: |
|
2549 |
msg = "Socket is not connected"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2550 |
sym = @symbol(ENOTCONN); |
362 | 2551 |
break; |
2552 |
#endif |
|
2553 |
#ifdef ESHUTDOWN |
|
2554 |
case ESHUTDOWN: |
|
2555 |
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
|
2556 |
sym = @symbol(ESHUTDOWN); |
362 | 2557 |
break; |
2558 |
#endif |
|
2559 |
#ifdef EHOSTDOWN |
|
2560 |
case EHOSTDOWN: |
|
2561 |
msg = "Host is down"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2562 |
sym = @symbol(EHOSTDOWN); |
362 | 2563 |
break; |
2564 |
#endif |
|
2565 |
#ifdef EHOSTUNREACH |
|
2566 |
case EHOSTUNREACH: |
|
2567 |
msg = "No route to host"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2568 |
sym = @symbol(EHOSTUNREACH); |
362 | 2569 |
break; |
2570 |
#endif |
|
2571 |
||
185 | 2572 |
default: |
368 | 2573 |
{ |
809
5eef87c2907b
e convenient macro for register saving (sparc only)
Claus Gittinger <cg@exept.de>
parents:
805
diff
changeset
|
2574 |
__BEGIN_PROTECT_REGISTERS__ |
1135 | 2575 |
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
|
2576 |
__END_PROTECT_REGISTERS__ |
368 | 2577 |
} |
185 | 2578 |
msg = buffer; |
2579 |
break; |
|
2580 |
} |
|
77 | 2581 |
} |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2582 |
text = __MKSTRING(msg); |
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 |
^ Array with:sym with:text |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2585 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2586 |
" |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2587 |
OperatingSystem errorSymbolAndTextForNumber:4 |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2588 |
" |
616 | 2589 |
! |
2590 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2591 |
errorSymbolForNumber:errNr |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2592 |
"return a symbol for a unix errorNumber |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2593 |
(as returned by a system call)." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2594 |
|
1153
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
2595 |
^ (self errorSymbolAndTextForNumber:errNr) at:1 |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2596 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2597 |
" |
1666 | 2598 |
OperatingSystem errorSymbolForNumber:4 |
2599 |
OperatingSystem errorSymbolForNumber:2 |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2600 |
" |
1153
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
2601 |
|
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
2602 |
"Modified: 12.4.1996 / 09:16:29 / stefan" |
1666 | 2603 |
"Modified: 13.9.1996 / 16:23:35 / cg" |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2604 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2605 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2606 |
errorTextForNumber:errNr |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2607 |
"return a message string from a unix errorNumber |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2608 |
(as returned by a system call). |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2609 |
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
|
2610 |
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
|
2611 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2612 |
^ (self errorSymbolAndTextForNumber:errNr) at:2 |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2613 |
|
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 |
OperatingSystem errorTextForNumber:4 |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2616 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2617 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2618 |
|
616 | 2619 |
lastErrorNumber |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2620 |
"return the last errors number. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2621 |
See also: #lastErrorSymbol and #lastErrorString. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2622 |
Notice: having a single error number is a bad idea in a multithreaded |
1487 | 2623 |
environment - this interface will change." |
616 | 2624 |
|
2625 |
^ LastErrorNumber |
|
2626 |
||
2627 |
" |
|
2628 |
OperatingSystem lastErrorNumber |
|
2629 |
" |
|
2630 |
! |
|
2631 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2632 |
lastErrorString |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2633 |
"return a message string describing the last error. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2634 |
See also: #lastErrorNumber and #lastErrorSymbol. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2635 |
Notice: having a single error number is a bad idea in a multithreaded |
1487 | 2636 |
environment - this interface will change." |
1084
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 |
^ self errorTextForNumber:LastErrorNumber |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2639 |
|
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 |
OperatingSystem lastErrorString |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2642 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2643 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2644 |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2645 |
lastErrorSymbol |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2646 |
"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
|
2647 |
See also: #lastErrorNumber and #lastErrorString. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2648 |
Notice: having a single error number is a bad idea in a multithreaded |
1487 | 2649 |
environment - this interface will change." |
1058
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 |
^ self errorSymbolForNumber:LastErrorNumber |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2652 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2653 |
" |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2654 |
OperatingSystem lastErrorSymbol |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2655 |
" |
1 | 2656 |
! ! |
2657 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
2658 |
!OperatingSystem class methodsFor:'executing OS commands'! |
616 | 2659 |
|
2660 |
canExecuteCommand:aCommandString |
|
2661 |
"return true, if the OS can execute aCommand." |
|
2662 |
||
2663 |
|cmd| |
|
2664 |
||
2665 |
cmd := aCommandString asCollectionOfWords first. |
|
2666 |
^ (self pathOfCommand:cmd) notNil |
|
2667 |
||
2668 |
" |
|
2669 |
OperatingSystem canExecuteCommand:'fooBar' |
|
2670 |
OperatingSystem canExecuteCommand:'ls' |
|
2671 |
OperatingSystem canExecuteCommand:'cvs' |
|
2672 |
" |
|
2673 |
||
2674 |
"Created: 4.11.1995 / 19:13:54 / cg" |
|
68 | 2675 |
! |
2676 |
||
616 | 2677 |
exec:aPath withArguments:argArray |
2678 |
"execute the unix command specified by the argument, aPath, with |
|
2679 |
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
|
2680 |
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
|
2681 |
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
|
2682 |
to another program." |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2683 |
|
792 | 2684 |
^ 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
|
2685 |
! |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2686 |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2687 |
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
|
2688 |
"Internal combined fork & exec; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2689 |
If fork is false: |
1487 | 2690 |
execute the unix command specified by the argument, aPath, with |
2691 |
arguments in argArray (no arguments, if nil). |
|
2692 |
If successful, this method does not return and smalltalk is gone. |
|
2693 |
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
|
2694 |
if its true: |
1487 | 2695 |
for a child to do the above. |
2696 |
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
|
2697 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2698 |
fdArray contains the filedescriptors, to be used for the child (if fork is true). |
1487 | 2699 |
fdArray[1] = 15 -> use fd 15 as stdin. |
2700 |
If an element of the array is set to nil, the corresponding filedescriptor |
|
2701 |
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
|
2702 |
|
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2703 |
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
|
2704 |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2705 |
If newPgrp is true, the subprocess will be established in a new process group. |
1487 | 2706 |
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
|
2707 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2708 |
Notice: this used to be two separate ST-methods; however, in order to use |
1487 | 2709 |
vfork on some machines, it had to be merged into one, to avoid write |
2710 |
accesses to ST/X memory from the vforked-child. The code below only does |
|
2711 |
read accesses." |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2712 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2713 |
%{ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2714 |
#ifndef MSDOS_LIKE |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2715 |
char **argv; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2716 |
int nargs, i, id; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2717 |
OBJ arg; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2718 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2719 |
if (__isString(aPath) && |
1487 | 2720 |
((argArray == nil) || __isArray(argArray)) && |
2721 |
((fdArray == nil) || __isArray(fdArray)) && |
|
2722 |
((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
|
2723 |
) { |
1487 | 2724 |
nargs = argArray == nil ? 0 : _arraySize(argArray); |
2725 |
argv = (char **) malloc(sizeof(char *) * (nargs + 1)); |
|
2726 |
if (argv) { |
|
2727 |
for (i=0; i < nargs; i++) { |
|
2728 |
arg = __ArrayInstPtr(argArray)->a_element[i]; |
|
2729 |
if (__isString(arg)) { |
|
2730 |
argv[i] = (char *) __stringVal(arg); |
|
2731 |
} else { |
|
2732 |
argv[i] = ""; |
|
2733 |
} |
|
2734 |
} |
|
2735 |
argv[i] = NULL; |
|
2736 |
||
2737 |
if (doFork == true) { |
|
2738 |
int nfd, nclose; |
|
2739 |
||
2740 |
nfd = fdArray == nil ? 0 : _arraySize(fdArray); |
|
2741 |
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
|
2742 |
#ifdef HAS_VFORK |
1487 | 2743 |
id = vfork(); |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2744 |
#else |
1487 | 2745 |
id = fork(); |
2746 |
#endif |
|
2747 |
if (id == 0) { |
|
2748 |
/* |
|
2749 |
** In child. |
|
2750 |
** first: dup filedescriptors |
|
2751 |
*/ |
|
2752 |
for (i = 0; i < nfd; i++) { |
|
2753 |
if (__isSmallInteger(__ArrayInstPtr(fdArray)->a_element[i]) && |
|
2754 |
__intVal(__ArrayInstPtr(fdArray)->a_element[i]) != i |
|
2755 |
) { |
|
2756 |
dup2(__intVal(__ArrayInstPtr(fdArray)->a_element[i]), i); |
|
2757 |
} |
|
2758 |
} |
|
2759 |
/* |
|
2760 |
** second: close unused filedescriptors |
|
2761 |
*/ |
|
2762 |
for (i = 0; i < nfd; i++) { |
|
2763 |
if (__ArrayInstPtr(fdArray)->a_element[i] == nil) { |
|
2764 |
close(i); |
|
2765 |
} |
|
2766 |
} |
|
2767 |
/* |
|
2768 |
** third: close filedescriptors |
|
2769 |
*/ |
|
2770 |
for (i = 0; i < nclose; i++) { |
|
2771 |
if (__isSmallInteger(__ArrayInstPtr(closeFdArray)->a_element[i])) { |
|
2772 |
close(__intVal(__ArrayInstPtr(closeFdArray)->a_element[i])); |
|
2773 |
} |
|
2774 |
} |
|
2775 |
if (newPgrp == true) { |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2776 |
#if defined(_POSIX_JOB_CONTROL) |
1487 | 2777 |
(void) setpgid(0, 0); |
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2778 |
#else |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2779 |
#if defined(BSD) |
1487 | 2780 |
(void) setpgrp(0); |
2781 |
#endif |
|
2782 |
#endif |
|
2783 |
} |
|
2784 |
||
2785 |
execv(__stringVal(aPath), argv); |
|
2786 |
/* should not be reached */ |
|
2787 |
_exit(127); /* POSIX 2 compatible exit value */ |
|
2788 |
} |
|
2789 |
/* |
|
2790 |
** In parent: succes or failure |
|
2791 |
*/ |
|
2792 |
free(argv); |
|
2793 |
RETURN (__MKSMALLINT(id)); |
|
2794 |
} else { |
|
2795 |
execv(__stringVal(aPath), argv); |
|
2796 |
/* |
|
2797 |
* should not be reached |
|
2798 |
* (well, it is, if you pass a wrong command-path) |
|
2799 |
*/ |
|
2800 |
free(argv); |
|
2801 |
RETURN ( false ); |
|
2802 |
} |
|
2803 |
} |
|
827
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 |
#endif |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2806 |
%}. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2807 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2808 |
path-argument not string |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2809 |
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
|
2810 |
or malloc failed |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2811 |
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
|
2812 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2813 |
^ self primitiveFailed |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2814 |
|
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| |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2817 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2818 |
id := OperatingSystem fork. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2819 |
id == 0 ifTrue:[ |
1487 | 2820 |
"I am the child" |
2821 |
OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp'). |
|
2822 |
"not reached" |
|
827
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 |
" |
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| |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2827 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2828 |
id := OperatingSystem fork. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2829 |
id == 0 ifTrue:[ |
1487 | 2830 |
"I am the child" |
2831 |
OperatingSystem exec:'/bin/sh' withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2'). |
|
2832 |
"not reached" |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2833 |
]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2834 |
id printNL. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2835 |
(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
|
2836 |
'killing ...' printNL. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2837 |
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
|
2838 |
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
|
2839 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2840 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2841 |
|
1076
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2842 |
exec:aPath withArguments:argArray fileDescriptors:fdArray fork:doFork |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2843 |
"Internal combined fork & exec; |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2844 |
If fork is false: |
1487 | 2845 |
execute the unix command specified by the argument, aPath, with |
2846 |
arguments in argArray (no arguments, if nil). |
|
2847 |
If successful, this method does not return and smalltalk is gone. |
|
2848 |
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
|
2849 |
if its true: |
1487 | 2850 |
for a child to do the above. |
2851 |
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
|
2852 |
|
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2853 |
fdArray contains the filedescriptors, to be used for the child (if fork is true). |
1487 | 2854 |
fdArray[1] = 15 -> use fd 15 as stdin. |
2855 |
If an element of the array is set to nil, the corresponding filedescriptor |
|
2856 |
will be closed for the child. |
|
1076
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2857 |
|
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2858 |
Notice: this used to be two separate ST-methods; however, in order to use |
1487 | 2859 |
vfork on some machines, it had to be merged into one, to avoid write |
2860 |
accesses to ST/X memory from the vforked-child. The code below only does |
|
2861 |
read accesses." |
|
1076
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2862 |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2863 |
^ 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
|
2864 |
|
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2865 |
"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
|
2866 |
! |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2867 |
|
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2868 |
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
|
2869 |
"Internal combined fork & exec; |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2870 |
If fork is false: |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2871 |
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
|
2872 |
arguments in argArray (no arguments, if nil). |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2873 |
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
|
2874 |
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
|
2875 |
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
|
2876 |
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
|
2877 |
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
|
2878 |
|
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2879 |
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
|
2880 |
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
|
2881 |
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
|
2882 |
read accesses." |
616 | 2883 |
|
2884 |
%{ |
|
792 | 2885 |
#ifndef MSDOS_LIKE |
616 | 2886 |
char **argv; |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2887 |
int nargs, i, id; |
616 | 2888 |
OBJ arg; |
2889 |
||
2890 |
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
|
2891 |
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
|
2892 |
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
|
2893 |
if (argv) { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2894 |
for (i=0; i < nargs; i++) { |
1135 | 2895 |
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
|
2896 |
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
|
2897 |
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
|
2898 |
} else { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2899 |
argv[i] = ""; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2900 |
} |
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 |
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
|
2903 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2904 |
if (doFork == true) { |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2905 |
#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
|
2906 |
id = vfork(); |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2907 |
#else |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2908 |
id = fork(); |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2909 |
#endif |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2910 |
if (id == 0) { |
1135 | 2911 |
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
|
2912 |
/* 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
|
2913 |
_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
|
2914 |
} |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2915 |
free(argv); |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2916 |
RETURN (__MKSMALLINT(id)); |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2917 |
} else { |
1135 | 2918 |
execv(__stringVal(aPath), argv); |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2919 |
/* |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2920 |
* should not be reached |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2921 |
* (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
|
2922 |
*/ |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2923 |
free(argv); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2924 |
RETURN ( false ); |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2925 |
} |
616 | 2926 |
} |
2927 |
} |
|
792 | 2928 |
#endif |
616 | 2929 |
%}. |
2930 |
" |
|
792 | 2931 |
path-argument not string |
2932 |
or argArray not an array/nil |
|
2933 |
or malloc failed |
|
2934 |
or not supported by OS |
|
616 | 2935 |
" |
2936 |
^ self primitiveFailed |
|
2937 |
||
2938 |
" |
|
2939 |
|id| |
|
2940 |
||
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2941 |
id := OperatingSystem fork. |
616 | 2942 |
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
|
2943 |
"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
|
2944 |
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
|
2945 |
"not reached" |
616 | 2946 |
] |
2947 |
" |
|
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2948 |
" |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2949 |
|id| |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2950 |
|
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2951 |
id := OperatingSystem fork. |
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2952 |
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
|
2953 |
"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
|
2954 |
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
|
2955 |
"not reached" |
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2956 |
]. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2957 |
id printNL. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2958 |
(Delay forSeconds:3.5) wait. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2959 |
'killing ...' printNL. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2960 |
OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2961 |
OperatingSystem sendSignal:(OperatingSystem sigKILL) to:id |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2962 |
" |
616 | 2963 |
! |
2964 |
||
2965 |
executeCommand:aCommandString |
|
2966 |
"execute the unix command specified by the argument, aCommandString. |
|
676 | 2967 |
The commandString is passed to a shell for execution - see the description of |
2968 |
'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
|
2969 |
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
|
2970 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2971 |
^ self executeCommand:aCommandString onError:[:status| false] |
2080
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 |
"/Old code: |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2974 |
"/ |
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 |
"/ int status; |
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 |
"/ if (__isString(aCommandString)) { |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2979 |
"/ /* |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2980 |
"/ * 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
|
2981 |
"/ * system() libc-function, which is interruptable ... |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2982 |
"/ */ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2983 |
"/# ifdef WANT_SYSTEM |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2984 |
"/ status = mySystem((char *) __stringVal(aCommandString)); |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2985 |
"/# else |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2986 |
"/ status = system((char *) __stringVal(aCommandString)); |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2987 |
"/# endif |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2988 |
"/ OperatingSystem_LastExecStatus = __MKSMALLINT(status); |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2989 |
"/ if (status == 0) { |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2990 |
"/ RETURN ( true ); |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2991 |
"/ } |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2992 |
"/ OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2993 |
"/ RETURN ( false ); |
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 |
"/%}. |
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 |
"/ "/ invalid argument (non-string) |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2998 |
"/ "/ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2999 |
"/ ^ self primitiveFailed |
616 | 3000 |
|
3001 |
" |
|
805 | 3002 |
OperatingSystem executeCommand:'sleep 30'. |
616 | 3003 |
OperatingSystem executeCommand:'pwd'. |
3004 |
OperatingSystem executeCommand:'ls -l'. |
|
3005 |
OperatingSystem executeCommand:'invalidCommand'. |
|
3006 |
OperatingSystem executeCommand:'rm /tmp/foofoofoofoo'. |
|
3007 |
" |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3008 |
|
2080
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
3009 |
"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
|
3010 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3011 |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3012 |
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
|
3013 |
"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
|
3014 |
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
|
3015 |
'sh -c' in your UNIX manual. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3016 |
Return true if successful. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3017 |
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
|
3018 |
as argument." |
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 |
|pid exitStatus sema| |
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 |
sema := Semaphore new. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3023 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3024 |
[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3025 |
pid := self |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3026 |
startProcess:aCommandString |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3027 |
inputFrom:anExternalInStream |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3028 |
outputTo:anExternalOutStream |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3029 |
errorTo:anExternalErrStream. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3030 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3031 |
pid > 0 ifTrue:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3032 |
Processor monitorPid:pid action:[:status | |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3033 |
status stillAlive ifFalse:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3034 |
exitStatus := status. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3035 |
sema signal |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3036 |
]. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3037 |
]. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3038 |
sema wait. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3039 |
] ifFalse:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3040 |
exitStatus := OSProcessStatus processCreationFailure. |
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 |
] valueUninterruptably. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3043 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3044 |
exitStatus success ifFalse:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3045 |
^ aBlock value:exitStatus |
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 |
^ true. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3048 |
! |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3049 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3050 |
executeCommand:aCommandString onError:aBlock |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3051 |
"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
|
3052 |
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
|
3053 |
'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
|
3054 |
Return true if successful. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3055 |
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
|
3056 |
as argument." |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3057 |
|
1034 | 3058 |
|pid exitStatus sema| |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3059 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3060 |
sema := Semaphore new. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3061 |
|
1034 | 3062 |
[ |
1487 | 3063 |
pid := self startProcess:aCommandString. |
3064 |
pid > 0 ifTrue:[ |
|
3065 |
Processor monitorPid:pid action:[:status | |
|
3066 |
status stillAlive ifFalse:[ |
|
3067 |
exitStatus := status. |
|
3068 |
sema signal |
|
3069 |
]. |
|
3070 |
]. |
|
3071 |
sema wait. |
|
3072 |
] ifFalse:[ |
|
3073 |
exitStatus := OSProcessStatus processCreationFailure. |
|
3074 |
]. |
|
1034 | 3075 |
] valueUninterruptably. |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3076 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3077 |
exitStatus success ifFalse:[ |
1487 | 3078 |
^ aBlock value:exitStatus |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3079 |
]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3080 |
^ true. |
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 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3083 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3084 |
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
|
3085 |
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
|
3086 |
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
|
3087 |
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
|
3088 |
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
|
3089 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3090 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3091 |
"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
|
3092 |
"Modified: 28.12.1995 / 15:25:48 / stefan" |
1034 | 3093 |
"Modified: 28.2.1996 / 21:41:23 / cg" |
616 | 3094 |
! |
3095 |
||
3096 |
fork |
|
3097 |
"fork a new (HEAVY-weight) unix process. |
|
3098 |
Dont confuse this with Block>>fork, which creates |
|
3099 |
lightweight smalltalk processes. This method will return |
|
676 | 3100 |
0 to the child process, and a non-zero number (which is the childs |
3101 |
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
|
3102 |
|
676 | 3103 |
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
|
3104 |
#startProcess: and #executCommand: for higher level interfaces." |
68 | 3105 |
|
3106 |
%{ /* NOCONTEXT */ |
|
792 | 3107 |
#ifndef MSDOS_LIKE |
616 | 3108 |
|
3109 |
int pid; |
|
3110 |
||
3111 |
pid = fork(); |
|
1135 | 3112 |
RETURN ( __MKSMALLINT(pid) ); |
792 | 3113 |
#endif |
3114 |
%}. |
|
3115 |
"/ |
|
3116 |
"/ not supported by OS |
|
3117 |
"/ |
|
3118 |
^ self primitiveFailed |
|
3119 |
||
616 | 3120 |
" |
3121 |
|id| |
|
3122 |
||
3123 |
id := OperatingSystem fork. |
|
3124 |
id == 0 ifTrue:[ |
|
3125 |
OperatingSystem exit |
|
3126 |
] |
|
3127 |
" |
|
68 | 3128 |
! |
3129 |
||
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3130 |
getStatusOfProcess:aProcessId |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3131 |
"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
|
3132 |
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
|
3133 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3134 |
%{ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3135 |
#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
|
3136 |
int status; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3137 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3138 |
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
|
3139 |
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
|
3140 |
{ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3141 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3142 |
# 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
|
3143 |
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
|
3144 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3145 |
do { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3146 |
__BEGIN_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3147 |
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
|
3148 |
__END_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3149 |
if (child < 0 && errno != EINTR) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
3150 |
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
|
3151 |
status = -1; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3152 |
break; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3153 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3154 |
} 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
|
3155 |
# else |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3156 |
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
|
3157 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3158 |
/* 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
|
3159 |
do { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3160 |
__BEGIN_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3161 |
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
|
3162 |
__END_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3163 |
} 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
|
3164 |
if (child != pid) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
3165 |
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
|
3166 |
status = -1; |
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 |
# 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
|
3169 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3170 |
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
|
3171 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3172 |
#endif |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3173 |
%}. |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3174 |
self primitiveFailed |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3175 |
|
1034 | 3176 |
! |
3177 |
||
3178 |
pathOfCommand:aCommand |
|
3179 |
"find where aCommand's executable file is" |
|
3180 |
||
3181 |
|path f| |
|
3182 |
||
3183 |
path := self getEnvironment:'PATH'. |
|
3184 |
path notNil ifTrue:[ |
|
3185 |
(path asCollectionOfSubstringsSeparatedBy:$:) do:[:path | |
|
3186 |
(f := (path asFilename construct:aCommand)) isExecutable ifTrue:[ |
|
3187 |
^ f pathName |
|
3188 |
] |
|
3189 |
]. |
|
3190 |
]. |
|
3191 |
^ nil |
|
3192 |
||
3193 |
" |
|
3194 |
OperatingSystem pathOfCommand:'fooBar' |
|
3195 |
OperatingSystem pathOfCommand:'ls' |
|
3196 |
OperatingSystem pathOfCommand:'cvs' |
|
3197 |
" |
|
3198 |
! |
|
3199 |
||
3200 |
startProcess:aCommandString |
|
3201 |
"start executing the unix command as specified by the argument, aCommandString |
|
3202 |
as a separate process; do not wait for the command to finish. |
|
3203 |
The commandString is passed to a shell for execution - see the description of |
|
3204 |
'sh -c' in your UNIX manual. |
|
3205 |
Return the processId if successful, nil otherwise. |
|
3206 |
Use #waitForProcess: for synchronization and exec status return, |
|
3207 |
or #killProcess: to stop it." |
|
3208 |
||
3209 |
^ self |
|
3210 |
exec:'/bin/sh' |
|
3211 |
withArguments:(Array with:'sh' with:'-c' with:aCommandString) |
|
3212 |
fork:true. |
|
3213 |
||
3214 |
" |
|
3215 |
|pid| |
|
3216 |
||
3217 |
pid := OperatingSystem startProcess:'sleep 2; echo 1; sleep 2; echo 2'. |
|
3218 |
(Delay forSeconds:3) wait. |
|
3219 |
OperatingSystem killProcess:pid. |
|
3220 |
" |
|
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3221 |
! |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3222 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3223 |
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
|
3224 |
"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
|
3225 |
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
|
3226 |
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
|
3227 |
'sh -c' in your UNIX manual. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3228 |
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
|
3229 |
each may be nil. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3230 |
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
|
3231 |
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
|
3232 |
or #killProcess: to stop it." |
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 |
|in out err| |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3235 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3236 |
anExternalInStream notNil ifTrue:[ |
1487 | 3237 |
in := anExternalInStream fileDescriptor. |
1046 | 3238 |
] ifFalse:[ |
1487 | 3239 |
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
|
3240 |
]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3241 |
anExternalOutStream notNil ifTrue:[ |
1487 | 3242 |
out := anExternalOutStream fileDescriptor. |
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3243 |
]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3244 |
anExternalErrStream notNil ifTrue:[ |
1487 | 3245 |
err := anExternalErrStream fileDescriptor. |
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3246 |
]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3247 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3248 |
^ self |
1487 | 3249 |
exec:'/bin/sh' |
3250 |
withArguments:(Array with:'sh' with:'-c' with:aCommandString) |
|
3251 |
fileDescriptors:(Array with:in with:out with:err) |
|
3252 |
fork:true. |
|
1045
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 |
"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
|
3255 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3256 |
OperatingSystem executeCommand:'ls -l > out'. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3257 |
" |
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 |
"non-blocking (lower prio threads continue): |
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 err pid sema| |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3262 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3263 |
in := 'out' asFilename readStream. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3264 |
out := 'out2' asFilename writeStream. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3265 |
err := 'err' asFilename writeStream. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3266 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3267 |
sema := Semaphore new. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3268 |
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
|
3269 |
pid notNil ifTrue:[ |
1487 | 3270 |
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
|
3271 |
]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3272 |
in close. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3273 |
out close. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3274 |
err close. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3275 |
sema wait. |
1422 | 3276 |
Transcript showCR:'finished' |
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3277 |
" |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3278 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3279 |
"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
|
3280 |
"Modified: 29.2.1996 / 12:49:14 / cg" |
616 | 3281 |
! ! |
3282 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
3283 |
!OperatingSystem class methodsFor:'file access'! |
616 | 3284 |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3285 |
closeFd:anInteger |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3286 |
"low level close of a filedescriptor" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3287 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3288 |
%{ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3289 |
#if !defined(transputer) && !defined(MSDOS_LIKE) |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3290 |
if (__isSmallInteger(anInteger)) { |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3291 |
close(__intVal(anInteger)); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3292 |
RETURN(self); |
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 |
#endif |
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 |
^ self primitiveFailed. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3297 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3298 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3299 |
createDirectory:newPathName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3300 |
"create a new directory with name 'newPathName'. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3301 |
Return true if successful, false if failed. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3302 |
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
|
3303 |
|
1497 | 3304 |
"/ if it already exists this is ok |
3305 |
||
3306 |
(self isDirectory:newPathName) ifTrue:[^ true]. |
|
3307 |
||
3308 |
"/ since createDirectory is not used too often, |
|
3309 |
"/ you'll forgive me using mkdir ... |
|
1084
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 |
^ self executeCommand:('mkdir 2>/dev/null ', newPathName) |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3312 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3313 |
" |
1497 | 3314 |
OperatingSystem createDirectory:'foo' |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3315 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3316 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3317 |
"Modified: 20.12.1995 / 11:24:13 / stefan" |
1497 | 3318 |
"Modified: 29.6.1996 / 14:06:54 / cg" |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3319 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3320 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3321 |
linkFile:oldPath to:newPath |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3322 |
"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
|
3323 |
Return true if successful, false if not." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3324 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3325 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3326 |
#ifndef MSDOS_LIKE |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3327 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3328 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3329 |
if (__isString(oldPath) && __isString(newPath)) { |
1487 | 3330 |
__BEGIN_INTERRUPTABLE__ |
3331 |
do { |
|
3332 |
ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath)); |
|
3333 |
} while (ret < 0 && errno == EINTR); |
|
3334 |
__END_INTERRUPTABLE__ |
|
3335 |
if (ret < 0) { |
|
3336 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3337 |
RETURN ( false ); |
|
3338 |
} |
|
3339 |
RETURN (true); |
|
1084
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 |
#endif |
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 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3344 |
|
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 |
OperatingSystem linkFile:'foo' to:'bar' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3347 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3348 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3349 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3350 |
makePipe |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3351 |
"make a pipe, return array with two filedescriptors on success, |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3352 |
nil on failure. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3353 |
This is a lowLevel entry, not for public use. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3354 |
See ExternalStream>>makePipe for a more user-friendly, public interface." |
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 |
|fd1 fd2| |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3357 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3358 |
%{ |
1597 | 3359 |
#ifdef UNIX_LIKE |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3360 |
int fds[2]; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3361 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3362 |
if (pipe(fds) < 0) { |
1487 | 3363 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
3364 |
RETURN ( nil ); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3365 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3366 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3367 |
fd1 = __MKSMALLINT(fds[0]); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3368 |
fd2 = __MKSMALLINT(fds[1]); |
1597 | 3369 |
#endif |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3370 |
%}. |
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 |
^ Array with:fd1 with:fd2. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3373 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3374 |
|
1132 | 3375 |
recursiveCopyDirectory:sourcePathName to:destination |
3376 |
"copy the directory named 'sourcePathName' and all contained files/directories to 'destination'. |
|
3377 |
Return true if successful." |
|
3378 |
||
3379 |
^ self executeCommand:('cp -rf ' , sourcePathName, ' ', destination) |
|
3380 |
||
3381 |
"Modified: 7.3.1996 / 15:26:30 / cg" |
|
3382 |
! |
|
3383 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3384 |
recursiveCreateDirectory:dirName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3385 |
"create a directory - with all parent dirs if needed. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3386 |
Return true if successful, false otherwise. If false |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3387 |
is returned, a partial created tree may be left, |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3388 |
which is not cleaned-up here." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3389 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3390 |
self createDirectory:dirName. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3391 |
(self isDirectory:dirName) ifFalse:[ |
1487 | 3392 |
(self recursiveCreateDirectory:(self directoryNameOf:dirName)) ifFalse:[^ false]. |
3393 |
^ self createDirectory:dirName |
|
1084
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 |
^ true |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3396 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3397 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3398 |
OperatingSystem recursiveCreateDirectory:'foo/bar/baz' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3399 |
OperatingSystem recursiveRemoveDirectory:'foo' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3400 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3401 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3402 |
"Modified: 7.3.1996 / 15:26:22 / cg" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3403 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3404 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3405 |
recursiveRemoveDirectory:fullPathName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3406 |
"remove the directory named 'fullPathName' and all contained files/directories. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3407 |
Return true if successful." |
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 |
^ self executeCommand:('rm -rf ' , fullPathName) |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3410 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3411 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3412 |
OperatingSystem recursiveCreateDirectory:'foo/bar/baz' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3413 |
OperatingSystem recursiveRemoveDirectory:'foo' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3414 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3415 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3416 |
"Modified: 7.3.1996 / 15:26:30 / cg" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3417 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3418 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3419 |
removeDirectory:fullPathName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3420 |
"remove the directory named 'fullPathName'. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3421 |
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
|
3422 |
This is a lowLevel entry - use Filename protocol for compatibility." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3423 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3424 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3425 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3426 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3427 |
if (__isString(fullPathName)) { |
1487 | 3428 |
__BEGIN_INTERRUPTABLE__ |
3429 |
do { |
|
3430 |
ret = rmdir((char *) __stringVal(fullPathName)); |
|
3431 |
} while (ret < 0 && errno == EINTR); |
|
3432 |
__END_INTERRUPTABLE__ |
|
3433 |
if (ret < 0) { |
|
3434 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3435 |
RETURN ( false ); |
|
3436 |
} |
|
3437 |
RETURN (true); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3438 |
} |
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 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3441 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3442 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3443 |
OperatingSystem createDirectory:'foo' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3444 |
OperatingSystem removeDirectory:'foo' |
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 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3448 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3449 |
removeFile:fullPathName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3450 |
"remove the file named 'fullPathName'; return true if successful. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3451 |
This is a lowLevel entry - use Filename protocol for compatibility." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3452 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3453 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3454 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3455 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3456 |
if (__isString(fullPathName)) { |
1487 | 3457 |
__BEGIN_INTERRUPTABLE__ |
3458 |
do { |
|
3459 |
ret = unlink((char *) __stringVal(fullPathName)); |
|
3460 |
} while (ret < 0 && errno == EINTR); |
|
3461 |
__END_INTERRUPTABLE__ |
|
3462 |
if (ret < 0) { |
|
3463 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3464 |
RETURN ( false ); |
|
3465 |
} |
|
3466 |
RETURN (true); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3467 |
} |
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 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3470 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3471 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3472 |
renameFile:oldPath to:newPath |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3473 |
"rename the file 'oldPath' to 'newPath'. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3474 |
Return true if successful, false if not" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3475 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3476 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3477 |
int ret, eno; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3478 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3479 |
if (__isString(oldPath) && __isString(newPath)) { |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3480 |
#if defined(HAS_RENAME) |
1487 | 3481 |
__BEGIN_INTERRUPTABLE__ |
3482 |
do { |
|
3483 |
ret = rename((char *) __stringVal(oldPath), (char *) __stringVal(newPath)); |
|
3484 |
} while (ret < 0 && errno == EINTR); |
|
3485 |
__END_INTERRUPTABLE__ |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3486 |
#else |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3487 |
# ifndef MSDOS_LIKE |
1487 | 3488 |
ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath)); |
3489 |
if (ret >= 0) { |
|
3490 |
ret = unlink((char *) __stringVal(oldPath)); |
|
3491 |
if (ret < 0) { |
|
3492 |
eno = errno; |
|
3493 |
unlink((char *) __stringVal(newPath)); |
|
3494 |
errno = eno; |
|
3495 |
} |
|
3496 |
} |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3497 |
# endif |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3498 |
#endif |
1487 | 3499 |
if (ret < 0) { |
3500 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3501 |
RETURN ( false ); |
|
3502 |
} |
|
3503 |
RETURN (true); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3504 |
} |
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 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3507 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3508 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3509 |
OperatingSystem renameFile:'foo' to:'bar' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3510 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3511 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3512 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3513 |
truncateFile:aPathName to:newSize |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3514 |
"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
|
3515 |
This may not be supported on all architectures. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3516 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3517 |
This is a low-level entry - use Filename protocol." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3518 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3519 |
%{ |
1623
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3520 |
#ifdef HAS_TRUNCATE |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3521 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3522 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3523 |
if (__isString(aPathName) |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3524 |
&& __isSmallInteger(newSize)) { |
1487 | 3525 |
__BEGIN_INTERRUPTABLE__ |
3526 |
do { |
|
3527 |
ret = truncate((char *) __stringVal(aPathName), __intVal(newSize)); |
|
3528 |
} while (ret < 0 && errno == EINTR); |
|
3529 |
__END_INTERRUPTABLE__ |
|
3530 |
if (ret < 0) { |
|
3531 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3532 |
RETURN ( false ); |
|
3533 |
} |
|
3534 |
RETURN (true); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3535 |
} |
1623
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3536 |
#else |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3537 |
# ifdef HAS_FTRUNCATE |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3538 |
int ret; |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3539 |
int fd; |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3540 |
|
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3541 |
if (__isString(aPathName) |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3542 |
&& __isSmallInteger(newSize)) { |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3543 |
do { |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3544 |
fd = open((char *) __stringVal(aPathName), 2); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3545 |
} while (fd < 0 && errno == EINTR); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3546 |
if (fd < 0) { |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3547 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3548 |
RETURN ( false ); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3549 |
} |
1632 | 3550 |
|
1623
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3551 |
ret = ftruncate(fd, __intVal(newSize)); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3552 |
close(fd); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3553 |
if (ret < 0) { |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3554 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3555 |
RETURN ( false ); |
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 |
RETURN (true); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3558 |
} |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3559 |
# endif /* using FTRUNCATE */ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3560 |
#endif |
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 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3563 |
! ! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3564 |
|
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
3565 |
!OperatingSystem class methodsFor:'file access rights'! |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3566 |
|
616 | 3567 |
accessMaskFor:aSymbol |
3568 |
"return the access bits mask for numbers as returned by |
|
3569 |
OperatingSystem>>accessModeOf: |
|
3570 |
and expected by OperatingSystem>>changeAccessModeOf:to:. |
|
3571 |
Since these numbers are OS dependent, always use the mask |
|
3572 |
(never hardcode 8rxxx into your code)." |
|
68 | 3573 |
|
3574 |
%{ /* NOCONTEXT */ |
|
616 | 3575 |
# ifndef S_IRUSR |
3576 |
/* posix systems should define these ... */ |
|
3577 |
# define S_IRUSR 0400 |
|
3578 |
# define S_IWUSR 0200 |
|
3579 |
# define S_IXUSR 0100 |
|
3580 |
# define S_IRGRP 0040 |
|
3581 |
# define S_IWGRP 0020 |
|
3582 |
# define S_IXGRP 0010 |
|
3583 |
# define S_IROTH 0004 |
|
3584 |
# define S_IWOTH 0002 |
|
3585 |
# define S_IXOTH 0001 |
|
3586 |
||
3587 |
# endif |
|
3588 |
||
3589 |
if (aSymbol == @symbol(readUser)) { |
|
1135 | 3590 |
RETURN ( __MKSMALLINT(S_IRUSR) ); |
616 | 3591 |
} |
3592 |
if (aSymbol == @symbol(writeUser)) { |
|
1135 | 3593 |
RETURN ( __MKSMALLINT(S_IWUSR) ); |
616 | 3594 |
} |
3595 |
if (aSymbol == @symbol(executeUser)) { |
|
1135 | 3596 |
RETURN ( __MKSMALLINT(S_IXUSR) ); |
616 | 3597 |
} |
3598 |
if (aSymbol == @symbol(readGroup)) { |
|
1135 | 3599 |
RETURN ( __MKSMALLINT(S_IRGRP) ); |
616 | 3600 |
} |
3601 |
if (aSymbol == @symbol(writeGroup)) { |
|
1135 | 3602 |
RETURN ( __MKSMALLINT(S_IWGRP) ); |
616 | 3603 |
} |
3604 |
if (aSymbol == @symbol(executeGroup)) { |
|
1135 | 3605 |
RETURN ( __MKSMALLINT(S_IXGRP) ); |
616 | 3606 |
} |
3607 |
if (aSymbol == @symbol(readOthers)) { |
|
1135 | 3608 |
RETURN ( __MKSMALLINT(S_IROTH) ); |
616 | 3609 |
} |
3610 |
if (aSymbol == @symbol(writeOthers)) { |
|
1135 | 3611 |
RETURN ( __MKSMALLINT(S_IWOTH) ); |
616 | 3612 |
} |
3613 |
if (aSymbol == @symbol(executeOthers)) { |
|
1135 | 3614 |
RETURN ( __MKSMALLINT(S_IXOTH) ); |
616 | 3615 |
} |
3616 |
%}. |
|
792 | 3617 |
^ self primitiveFailed |
616 | 3618 |
|
3619 |
" |
|
3620 |
OperatingSystem accessMaskFor:#readUser |
|
3621 |
" |
|
68 | 3622 |
! |
3623 |
||
616 | 3624 |
accessModeOf:aPathName |
3625 |
"return a number representing access rights rwxrwxrwx for owner, |
|
3626 |
group and others. Return nil if such a file does not exist. |
|
3627 |
Notice that the returned number is OS dependent - use the |
|
3628 |
modeMasks as returned by OperatingSystem>>accessMaskFor:" |
|
3629 |
||
3630 |
" |
|
3631 |
this could have been implemented as: |
|
1487 | 3632 |
(self infoOf:aPathName) at:#mode |
616 | 3633 |
but for huge directory searches the code below is faster |
3634 |
" |
|
345 | 3635 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3636 |
%{ |
616 | 3637 |
struct stat buf; |
3638 |
int ret; |
|
3639 |
||
3640 |
if (__isString(aPathName)) { |
|
1487 | 3641 |
__BEGIN_INTERRUPTABLE__ |
3642 |
do { |
|
3643 |
ret = stat((char *) __stringVal(aPathName), &buf); |
|
3644 |
} while ((ret < 0) && (errno == EINTR)); |
|
3645 |
__END_INTERRUPTABLE__ |
|
3646 |
||
3647 |
if (ret < 0) { |
|
3648 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3649 |
RETURN ( nil ); |
|
3650 |
} |
|
3651 |
RETURN ( __MKSMALLINT(buf.st_mode & 0777) ); |
|
616 | 3652 |
} |
3653 |
%}. |
|
792 | 3654 |
^ self primitiveFailed |
616 | 3655 |
|
3656 |
" |
|
3657 |
(OperatingSystem accessModeOf:'/') printStringRadix:8 |
|
3658 |
" |
|
345 | 3659 |
! |
3660 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3661 |
changeAccessModeOf:aPathName to:modeBits |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3662 |
"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
|
3663 |
You should construct this mask using accessMaskFor, to be OS |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3664 |
independent. Return true if changed, |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3665 |
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
|
3666 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3667 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3668 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3669 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3670 |
if (__isString(aPathName) && __isSmallInteger(modeBits)) { |
1487 | 3671 |
__BEGIN_INTERRUPTABLE__ |
3672 |
do { |
|
3673 |
ret = chmod((char *)__stringVal(aPathName), __intVal(modeBits)); |
|
3674 |
} while (ret < 0 && errno == EINTR); |
|
3675 |
__END_INTERRUPTABLE__ |
|
3676 |
if (ret < 0) { |
|
3677 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3678 |
RETURN ( false ); |
|
3679 |
} |
|
3680 |
RETURN ( true ); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3681 |
} |
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 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3684 |
! ! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3685 |
|
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
3686 |
!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
|
3687 |
|
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3688 |
lockFD:aFileDescriptor shared:isSharedReadLock blocking:blockIfLocked |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3689 |
"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
|
3690 |
(such as returned by ExternalStream>>fileDescriptor). |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3691 |
On some systems, only advisory locks are available - |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3692 |
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
|
3693 |
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
|
3694 |
(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
|
3695 |
The isSharedReadLock argument (if true) specifies if multiple readers |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3696 |
are to be allowed - if false, they are not. |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3697 |
On some systems, all locks are non-exclusive locks. |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3698 |
|
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3699 |
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
|
3700 |
|
1616
fa734ea238f8
type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents:
1615
diff
changeset
|
3701 |
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
|
3702 |
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
|
3703 |
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
|
3704 |
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
|
3705 |
argument." |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3706 |
|
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3707 |
%{ |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3708 |
if (__isSmallInteger(aFileDescriptor)) { |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3709 |
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
|
3710 |
int lockArg; |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3711 |
|
1617
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 |
* claus: sigh - each one has a different interface ... |
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 |
#if defined(F_SETLK) |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3716 |
{ |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3717 |
/* |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3718 |
* new fcntl(SETLK) interface; |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3719 |
* available on SYSV4 and Linux |
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 |
struct flock flock; |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3722 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3723 |
if (isSharedReadLock == true) { |
1632 | 3724 |
flock.l_type = F_RDLCK; |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3725 |
} else { |
1632 | 3726 |
flock.l_type = F_WRLCK; |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3727 |
} |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3728 |
flock.l_whence = 0; |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3729 |
flock.l_start = 0; |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3730 |
flock.l_len = 0; |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3731 |
lockArg = F_SETLK; |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3732 |
# if defined(F_SETLKW) |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3733 |
if (blockIfLocked == true) { |
1632 | 3734 |
lockArg = F_SETLKW; |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3735 |
} |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3736 |
# endif |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3737 |
if (fcntl(fd, lockArg, &flock) != -1) { |
1632 | 3738 |
RETURN (true); |
1617
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 |
} |
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 |
#else /* no F_SETLK available */ |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3743 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3744 |
# if defined(LOCK_EX) && defined(LOCK_UN) |
1632 | 3745 |
/* |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3746 |
* BSD 4.3 advisory locks |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3747 |
*/ |
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3748 |
lockArg = LOCK_EX; |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3749 |
# if defined(LOCK_SH) |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3750 |
if (isSharedReadLock == true) { |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3751 |
lockArg = LOCK_SH |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3752 |
} |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3753 |
# endif |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3754 |
# 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
|
3755 |
if (blockIfLocked == false) { |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3756 |
lockArg |= LOCK_NB; |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3757 |
} |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3758 |
# endif |
1632 | 3759 |
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
|
3760 |
RETURN (true); |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3761 |
} |
1617
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 |
# else /* no flock available */ |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3764 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3765 |
# if defined(F_LOCK) && defined(F_UNLOCK) |
1632 | 3766 |
/* |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3767 |
* SYSV3 advisory locks |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3768 |
*/ |
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3769 |
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
|
3770 |
RETURN (true); |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3771 |
} |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3772 |
# endif |
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3773 |
# endif |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3774 |
#endif |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3775 |
} |
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 |
^ false |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3778 |
! |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3779 |
|
1616
fa734ea238f8
type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents:
1615
diff
changeset
|
3780 |
supportsFileLocks |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3781 |
"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
|
3782 |
|
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3783 |
%{ /* NOCONTEXT */ |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3784 |
#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
|
3785 |
RETURN (true); |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3786 |
#else |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3787 |
# 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
|
3788 |
RETURN (true); |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3789 |
# else |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3790 |
# if defined(F_LOCK) && defined(F_UNLOCK) |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3791 |
RETURN (true); |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3792 |
# endif |
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3793 |
# endif |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3794 |
#endif |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3795 |
%}. |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3796 |
^ false |
1616
fa734ea238f8
type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents:
1615
diff
changeset
|
3797 |
|
fa734ea238f8
type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents:
1615
diff
changeset
|
3798 |
" |
fa734ea238f8
type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents:
1615
diff
changeset
|
3799 |
OperatingSystem supportsFileLocks |
fa734ea238f8
type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents:
1615
diff
changeset
|
3800 |
" |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3801 |
! |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3802 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3803 |
supportsNonBlockingFileLocks |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3804 |
"return true, if the OS supports nonBlocking file locking |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3805 |
(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
|
3806 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3807 |
%{ /* NOCONTEXT */ |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3808 |
#if defined(F_SETLK) && defined(F_SETLKW) |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3809 |
RETURN (true); |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3810 |
#else |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3811 |
# 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
|
3812 |
RETURN (true); |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3813 |
# endif |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3814 |
#endif |
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 |
^ false |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3817 |
|
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 |
OperatingSystem supportsNonBlockingFileLocks |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3820 |
" |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3821 |
! |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3822 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3823 |
supportsSharedLocks |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3824 |
"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
|
3825 |
file locking." |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3826 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3827 |
%{ /* NOCONTEXT */ |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3828 |
#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
|
3829 |
RETURN (true); |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3830 |
#else |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3831 |
# 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
|
3832 |
RETURN (true); |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3833 |
# endif |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3834 |
#endif |
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 |
^ false |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3837 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3838 |
" |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3839 |
OperatingSystem supportsNonBlockingFileLocks |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3840 |
" |
1621 | 3841 |
! |
3842 |
||
3843 |
unlockFD:aFileDescriptor |
|
3844 |
"clear a file lock on the file represented by aFileDescriptor, |
|
3845 |
which was previously aquired by #lockFD:. |
|
3846 |
Return false, if the unlock failed |
|
3847 |
(which may happens when a wrong fd is passed, |
|
3848 |
no lock was set previously, or the systsem does not support locks). |
|
3849 |
Notice, that not all OS's support file locks; |
|
3850 |
on some, this may simply be a no-op." |
|
3851 |
||
3852 |
%{ |
|
3853 |
if (__isSmallInteger(aFileDescriptor)) { |
|
1632 | 3854 |
int fd = __intVal(aFileDescriptor); |
3855 |
||
3856 |
/* |
|
3857 |
* claus: sigh - each one has a different interface ... |
|
3858 |
*/ |
|
1621 | 3859 |
#if defined(F_SETLK) |
3860 |
{ |
|
1632 | 3861 |
/* |
3862 |
* new fcntl(SETLK) interface; |
|
3863 |
* available on SYSV4 and Linux |
|
3864 |
*/ |
|
3865 |
struct flock flock; |
|
3866 |
||
3867 |
flock.l_type = F_UNLCK; |
|
3868 |
flock.l_whence = 0; |
|
3869 |
flock.l_start = 0; |
|
3870 |
flock.l_len = 0; |
|
3871 |
if (fcntl(fd, F_SETLK, &flock) != -1) { |
|
3872 |
RETURN (true); |
|
3873 |
} |
|
1621 | 3874 |
} |
3875 |
||
3876 |
#else /* no F_SETLK available */ |
|
3877 |
||
3878 |
# if defined(LOCK_EX) && defined(LOCK_UN) |
|
1632 | 3879 |
/* |
1621 | 3880 |
* BSD 4.3 advisory locks |
3881 |
*/ |
|
1632 | 3882 |
if (flock(fd, LOCK_UN) != -1) { |
3883 |
RETURN (true); |
|
3884 |
} |
|
1621 | 3885 |
|
3886 |
# else /* no flock available */ |
|
3887 |
||
3888 |
# if defined(F_LOCK) && defined(F_UNLOCK) |
|
3889 |
/* |
|
3890 |
* SYSV3 advisory locks |
|
3891 |
*/ |
|
3892 |
if (lockf(fd, F_UNLOCK, 0) != -1) { |
|
3893 |
RETURN (true); |
|
3894 |
} |
|
3895 |
# endif |
|
3896 |
# endif |
|
3897 |
#endif |
|
3898 |
} |
|
3899 |
%}. |
|
3900 |
^ false |
|
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3901 |
! ! |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3902 |
|
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
3903 |
!OperatingSystem class methodsFor:'file queries'! |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3904 |
|
616 | 3905 |
baseNameOf:aPathString |
3906 |
"return the baseName of the argument, aPathString |
|
3907 |
- thats the file/directory name without leading parent-dirs |
|
3908 |
(i.e. OperatingSystem baseNameOf:'/usr/lib/st/file' -> 'file' |
|
3909 |
and OperatingSystem baseNameOf:'/usr/lib' -> lib). |
|
3910 |
This method does not check if the path is valid |
|
3911 |
(i.e. if these directories really exist & is readable)." |
|
3912 |
||
3913 |
|prev index sep| |
|
3914 |
||
3915 |
sep := self fileSeparator. |
|
3916 |
((aPathString size == 1) and:[(aPathString at:1) == sep]) ifTrue:[ |
|
3917 |
^ aPathString |
|
3918 |
]. |
|
3919 |
prev := 1. |
|
3920 |
[true] whileTrue:[ |
|
3921 |
index := aPathString indexOf:sep startingAt:prev. |
|
3922 |
index == 0 ifTrue:[ |
|
3923 |
^ aPathString copyFrom:prev |
|
3924 |
]. |
|
3925 |
prev := index + 1 |
|
3926 |
] |
|
3927 |
||
3928 |
" |
|
3929 |
OperatingSystem baseNameOf:'/fee/foo/bar' |
|
3930 |
OperatingSystem baseNameOf:'foo/bar' |
|
3931 |
OperatingSystem baseNameOf:'../../foo/bar' |
|
3932 |
OperatingSystem baseNameOf:'hello' |
|
3933 |
" |
|
3934 |
! |
|
3935 |
||
3936 |
caseSensitiveFilenames |
|
3937 |
"return true, if the OS has caseSensitive file naming. |
|
3938 |
On MSDOS, this will return false. Since this is for Unix, we |
|
3939 |
return true." |
|
3940 |
||
3941 |
^ true |
|
3942 |
! |
|
3943 |
||
3944 |
compressPath:pathName |
|
3945 |
"return the pathName compressed - that is, remove all ..-entries |
|
3946 |
and . entries. This does not always (in case of symbolic links) |
|
3947 |
return the true pathName and is therefore used as a fallback |
|
3948 |
if realPath and popen failed." |
|
3949 |
||
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
3950 |
|names n "{ Class: SmallInteger }" | |
616 | 3951 |
|
3952 |
names := pathName |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3953 |
asCollectionOfSubstringsSeparatedBy:self fileSeparator. |
616 | 3954 |
names := names asOrderedCollection. |
3955 |
" |
|
3956 |
cut off initial double-slashes |
|
3957 |
" |
|
3958 |
[names startsWith:#('' '')] whileTrue:[ |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3959 |
names removeFirst. |
616 | 3960 |
]. |
3961 |
" |
|
3962 |
cut off double-slashes at end |
|
3963 |
" |
|
3964 |
[names endsWith:#('')] whileTrue:[ |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3965 |
names removeLast. |
616 | 3966 |
]. |
3967 |
" |
|
3968 |
cut off current-dir at beginning |
|
3969 |
" |
|
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
3970 |
n := names size. |
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
3971 |
[(n >= 2) and:[names startsWith:#('.')]] whileTrue:[ |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3972 |
names removeFirst. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3973 |
n := n - 1. |
616 | 3974 |
]. |
3975 |
||
3976 |
" |
|
3977 |
cut off parent-dirs at end |
|
3978 |
" |
|
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
3979 |
[(n > 2) |
616 | 3980 |
and:[(names endsWith:#('..')) |
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
3981 |
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
|
3982 |
names removeLast; removeLast. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3983 |
n := n - 2. |
616 | 3984 |
]. |
3985 |
||
3986 |
^ names asStringWith:self fileSeparator |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3987 |
from:1 |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3988 |
to:n |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3989 |
compressTabs:false final:nil |
616 | 3990 |
|
3991 |
" |
|
3992 |
OperatingSystem compressPath:'./..' |
|
3993 |
OperatingSystem compressPath:'/foo/bar/baz/..' |
|
3994 |
OperatingSystem compressPath:'foo/bar/baz/..' |
|
3995 |
OperatingSystem compressPath:'foo/bar/baz/../' |
|
3996 |
OperatingSystem compressPath:'foo/bar/baz/..///' |
|
3997 |
OperatingSystem compressPath:'///foo/bar/baz/..///' |
|
3998 |
" |
|
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
3999 |
|
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4000 |
"Modified: 1.11.1996 / 20:13:48 / cg" |
68 | 4001 |
! |
4002 |
||
616 | 4003 |
directoryNameOf:aPathString |
4004 |
"return the directoryName of the argument, aPath |
|
4005 |
- thats the name of the directory where aPath is |
|
4006 |
(i.e. OperatingSystem directoryNameOf:'/usr/lib/st/file' -> '/usr/lib/st' |
|
4007 |
and OperatingSystem directoryNameOf:'/usr/lib' -> /usr'). |
|
4008 |
This method does not check if the path is valid |
|
4009 |
(i.e. if these directories really exist & are readable)." |
|
4010 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4011 |
|last index sep sepString p| |
616 | 4012 |
|
4013 |
sep := self fileSeparator. |
|
4014 |
sepString := sep asString. |
|
4015 |
(aPathString = sepString) ifTrue:[ |
|
1885
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 |
the trivial '/' case |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4018 |
" |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4019 |
^ aPathString |
616 | 4020 |
]. |
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4021 |
|
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4022 |
p := aPathString. |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4023 |
[p endsWith:sepString] whileTrue:[ |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4024 |
(p = sepString) ifTrue:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4025 |
^ p |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4026 |
]. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4027 |
p := p copyWithoutLast:1 |
616 | 4028 |
]. |
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4029 |
|
616 | 4030 |
last := 1. |
4031 |
[true] whileTrue:[ |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4032 |
index := p indexOf:sep startingAt:(last + 1). |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4033 |
index == 0 ifTrue:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4034 |
(last == 1) ifTrue:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4035 |
(p startsWith:sepString) ifTrue:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4036 |
^ sepString |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4037 |
]. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4038 |
^ '.' |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4039 |
]. |
616 | 4040 |
" |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4041 |
(p startsWith:sepString) ifFalse:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4042 |
(p startsWith:('..' , sepString)) ifFalse:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4043 |
^ './' , (p copyTo:(last - 1)) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4044 |
] |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4045 |
]. |
616 | 4046 |
" |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4047 |
^ p copyTo:(last - 1) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4048 |
]. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4049 |
last := index. |
616 | 4050 |
] |
4051 |
||
4052 |
" |
|
4053 |
OperatingSystem directoryNameOf:'/fee/foo/bar' |
|
4054 |
OperatingSystem directoryNameOf:'foo/bar' |
|
4055 |
OperatingSystem directoryNameOf:'../../foo/bar' |
|
4056 |
OperatingSystem directoryNameOf:'bar' |
|
4057 |
OperatingSystem directoryNameOf:'/bar' |
|
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4058 |
OperatingSystem directoryNameOf:'/tmp' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4059 |
OperatingSystem directoryNameOf:'/tmp///' |
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 |
OperatingSystem directoryNameOf:'./bar' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4063 |
OperatingSystem directoryNameOf:'/./bar' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4064 |
" |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4065 |
|
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4066 |
"Modified: 22.10.1996 / 18:53:47 / cg" |
616 | 4067 |
! |
4068 |
||
4069 |
fileSeparator |
|
4070 |
"return the character used to separate names in a path. |
|
4071 |
This character differs for MSDOS and other systems, |
|
4072 |
(but those are currently not supported - so this is some |
|
4073 |
preparation for the future)" |
|
4074 |
||
4075 |
^ $/ |
|
4076 |
! |
|
4077 |
||
4078 |
idOf:aPathName |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4079 |
"return the fileNumber (i.e. inode number) of a file. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4080 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4081 |
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
|
4082 |
some dummy id will be returned. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4083 |
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
|
4084 |
physically identical, even if found in different directories |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4085 |
(i.e. if they are hardLinked)." |
616 | 4086 |
|
4087 |
" |
|
4088 |
this could have been implemented as: |
|
1487 | 4089 |
(self infoOf:aPathName) at:#id |
616 | 4090 |
but for huge directory searches the code below is faster |
4091 |
" |
|
68 | 4092 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4093 |
%{ |
616 | 4094 |
struct stat buf; |
4095 |
int ret; |
|
4096 |
||
4097 |
if (__isString(aPathName)) { |
|
1487 | 4098 |
__BEGIN_INTERRUPTABLE__ |
4099 |
do { |
|
4100 |
ret = stat((char *) __stringVal(aPathName), &buf); |
|
4101 |
} while (ret < 0 && errno == EINTR); |
|
4102 |
__END_INTERRUPTABLE__ |
|
4103 |
if (ret >= 0) { |
|
4104 |
RETURN (__MKSMALLINT(buf.st_ino)); |
|
4105 |
} |
|
4106 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
4107 |
RETURN (nil); |
|
616 | 4108 |
} |
68 | 4109 |
%} |
616 | 4110 |
. |
792 | 4111 |
^ self primitiveFailed |
616 | 4112 |
|
4113 |
"OperatingSystem idOf:'/'" |
|
68 | 4114 |
! |
4115 |
||
616 | 4116 |
infoOf:aPathName |
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4117 |
"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
|
4118 |
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
|
4119 |
the returned object) is: |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4120 |
type - a symbol giving the files fileType |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4121 |
mode - numeric access mode |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4122 |
uid - owners user id |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4123 |
gid - owners group id |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4124 |
size - files size |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4125 |
id - files number (i.e. inode number) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4126 |
accessed - last access time (as osTime-stamp) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4127 |
modified - last modification time (as osTime-stamp) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4128 |
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
|
4129 |
|
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4130 |
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
|
4131 |
all of the information. |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4132 |
Return nil if such a file does not exist. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4133 |
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
|
4134 |
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
|
4135 |
" |
616 | 4136 |
|
4137 |
|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
|
4138 |
atime mtime ctime| |
616 | 4139 |
|
4140 |
%{ |
|
4141 |
struct stat buf; |
|
4142 |
int ret; |
|
4143 |
||
4144 |
if (__isString(aPathName)) { |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4145 |
__BEGIN_INTERRUPTABLE__ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4146 |
do { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4147 |
ret = stat((char *) __stringVal(aPathName), &buf); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4148 |
} while ((ret < 0) && (errno == EINTR)); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4149 |
__END_INTERRUPTABLE__ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4150 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4151 |
if (ret < 0) { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4152 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4153 |
RETURN ( nil ); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4154 |
} |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4155 |
switch (buf.st_mode & S_IFMT) { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4156 |
case S_IFDIR: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4157 |
type = @symbol(directory); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4158 |
break; |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4159 |
case S_IFREG: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4160 |
type = @symbol(regular); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4161 |
break; |
616 | 4162 |
#ifdef S_IFCHR |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4163 |
case S_IFCHR: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4164 |
type = @symbol(characterSpecial); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4165 |
break; |
616 | 4166 |
#endif |
4167 |
#ifdef S_IFBLK |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4168 |
case S_IFBLK: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4169 |
type = @symbol(blockSpecial); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4170 |
break; |
616 | 4171 |
#endif |
4172 |
#ifdef S_IFLNK |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4173 |
case S_IFLNK: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4174 |
type = @symbol(symbolicLink); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4175 |
break; |
616 | 4176 |
#endif |
4177 |
#ifdef S_IFSOCK |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4178 |
case S_IFSOCK: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4179 |
type = @symbol(socket); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4180 |
break; |
616 | 4181 |
#endif |
4182 |
#ifdef S_IFIFO |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4183 |
case S_IFIFO: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4184 |
type = @symbol(fifo); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4185 |
break; |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4186 |
#endif |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4187 |
default: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4188 |
type = @symbol(unknown); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4189 |
break; |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4190 |
} |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4191 |
mode = __MKSMALLINT(buf.st_mode & 0777); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4192 |
uid = __MKSMALLINT(buf.st_uid); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4193 |
gid = __MKSMALLINT(buf.st_gid); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4194 |
size = __MKSMALLINT(buf.st_size); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4195 |
id = __MKSMALLINT(buf.st_ino); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4196 |
atime = __MKUINT(buf.st_atime); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4197 |
mtime = __MKUINT(buf.st_mtime); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4198 |
ctime = __MKUINT(buf.st_ctime); |
616 | 4199 |
} |
4200 |
%}. |
|
4201 |
mode notNil ifTrue:[ |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4202 |
^ FileStatusInfo |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4203 |
type:type |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4204 |
mode:mode |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4205 |
uid:uid |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4206 |
gid:gid |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4207 |
size:size |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4208 |
id:id |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4209 |
accessed:(AbsoluteTime fromOSTime:(atime * 1000)) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4210 |
modified:(AbsoluteTime fromOSTime:(mtime * 1000)) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4211 |
statusChanged:(AbsoluteTime fromOSTime:(ctime * 1000)) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4212 |
path:nil |
616 | 4213 |
]. |
792 | 4214 |
^ self primitiveFailed |
616 | 4215 |
|
4216 |
" |
|
4217 |
OperatingSystem infoOf:'/' |
|
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4218 |
(OperatingSystem infoOf:'/') uid |
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4219 |
(OperatingSystem infoOf:'/') accessed |
616 | 4220 |
" |
68 | 4221 |
! |
4222 |
||
616 | 4223 |
isDirectory:aPathName |
4224 |
"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
|
4225 |
(i.e. exists and is a directory). |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4226 |
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
|
4227 |
if you need to check for this, use #linkInfo:." |
68 | 4228 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4229 |
%{ |
616 | 4230 |
struct stat buf; |
4231 |
int ret; |
|
4232 |
||
4233 |
if (__isString(aPathName)) { |
|
1487 | 4234 |
__BEGIN_INTERRUPTABLE__ |
4235 |
do { |
|
4236 |
ret = stat((char *) __stringVal(aPathName), &buf); |
|
4237 |
} while ((ret < 0) && (errno == EINTR)); |
|
4238 |
__END_INTERRUPTABLE__ |
|
4239 |
if (ret < 0) { |
|
4240 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
4241 |
RETURN ( false ); |
|
4242 |
} |
|
4243 |
RETURN ( ((buf.st_mode & S_IFMT) == S_IFDIR) ? true : false); |
|
616 | 4244 |
} |
4245 |
%}. |
|
792 | 4246 |
^ self primitiveFailed |
616 | 4247 |
|
4248 |
"an alternative implementation would be: |
|
1487 | 4249 |
^ (self infoOf:aPathName) at:#type == #directory |
616 | 4250 |
" |
68 | 4251 |
! |
4252 |
||
616 | 4253 |
isExecutable:aPathName |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4254 |
"return true, if the given file is executable. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4255 |
For symbolic links, the pointed-to-file is checked." |
68 | 4256 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4257 |
%{ |
616 | 4258 |
int ret; |
4259 |
||
4260 |
if (__isString(aPathName)) { |
|
1487 | 4261 |
__BEGIN_INTERRUPTABLE__ |
4262 |
do { |
|
4263 |
ret = access(__stringVal(aPathName), X_OK); |
|
4264 |
} while ((ret < 0) && (errno == EINTR)); |
|
4265 |
__END_INTERRUPTABLE__ |
|
4266 |
if (ret < 0) { |
|
4267 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
4268 |
} |
|
4269 |
RETURN ( ((ret == 0) ? true : false) ); |
|
616 | 4270 |
} |
4271 |
%}. |
|
792 | 4272 |
^ self primitiveFailed |
68 | 4273 |
! |
4274 |
||
616 | 4275 |
isReadable:aPathName |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4276 |
"return true, if the file/dir 'aPathName' is readable. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4277 |
For symbolic links, the pointed-to-file is checked." |
68 | 4278 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4279 |
%{ |
616 | 4280 |
int ret; |
4281 |
||
4282 |
if (__isString(aPathName)) { |
|
1487 | 4283 |
__BEGIN_INTERRUPTABLE__ |
4284 |
do { |
|
4285 |
ret = access(__stringVal(aPathName), R_OK); |
|
4286 |
} while ((ret < 0) && (errno == EINTR)); |
|
4287 |
__END_INTERRUPTABLE__ |
|
4288 |
if (ret < 0) { |
|
4289 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
4290 |
} |
|
4291 |
RETURN ( ((ret == 0) ? true : false) ); |
|
616 | 4292 |
} |
4293 |
%}. |
|
792 | 4294 |
^ self primitiveFailed |
68 | 4295 |
! |
4296 |
||
616 | 4297 |
isSymbolicLink:aPathName |
4298 |
"return true, if the given file is a symbolic link" |
|
4299 |
||
4300 |
^ (self linkInfoOf:aPathName) notNil |
|
4301 |
||
4302 |
" |
|
4303 |
OperatingSystem isSymbolicLink:'Make.proto' |
|
4304 |
OperatingSystem isSymbolicLink:'Makefile' |
|
4305 |
" |
|
4306 |
! |
|
4307 |
||
4308 |
isValidPath:aPathName |
|
4309 |
"return true, if 'aPathName' is a valid path name |
|
4310 |
(i.e. the file or directory exists)" |
|
68 | 4311 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4312 |
%{ |
616 | 4313 |
struct stat buf; |
4314 |
int ret; |
|
4315 |
||
4316 |
if (__isString(aPathName) || __isSymbol(aPathName) ) { |
|
4317 |
__BEGIN_INTERRUPTABLE__ |
|
4318 |
do { |
|
1135 | 4319 |
ret = stat((char *) __stringVal(aPathName), &buf); |
616 | 4320 |
} while ((ret < 0) && (errno == EINTR)); |
4321 |
__END_INTERRUPTABLE__ |
|
4322 |
if (ret < 0) { |
|
1135 | 4323 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 4324 |
RETURN (false); |
4325 |
} |
|
4326 |
RETURN ( ret ? false : true ); |
|
4327 |
} |
|
792 | 4328 |
%}. |
4329 |
^ self primitiveFailed |
|
68 | 4330 |
! |
4331 |
||
616 | 4332 |
isWritable:aPathName |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4333 |
"return true, if the given file is writable. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4334 |
For symbolic links, the pointed-to-file is checked." |
68 | 4335 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4336 |
%{ |
616 | 4337 |
int ret; |
4338 |
||
4339 |
if (__isString(aPathName)) { |
|
1487 | 4340 |
__BEGIN_INTERRUPTABLE__ |
4341 |
do { |
|
4342 |
ret = access(__stringVal(aPathName), W_OK); |
|
4343 |
} while ((ret < 0) && (errno == EINTR)); |
|
4344 |
__END_INTERRUPTABLE__ |
|
4345 |
if (ret < 0) { |
|
4346 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
4347 |
} |
|
4348 |
RETURN ( ((ret == 0) ? true : false) ); |
|
616 | 4349 |
} |
4350 |
%}. |
|
792 | 4351 |
^ self primitiveFailed |
68 | 4352 |
! |
4353 |
||
616 | 4354 |
linkInfoOf:aPathName |
4355 |
"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
|
4356 |
IFF aPathName is a symbolic link. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4357 |
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
|
4358 |
|
616 | 4359 |
The contents of the dictionary gives info about the link itself, |
4360 |
on contrast to #infoOf:, which returns the info of the pointed to file |
|
4361 |
in case of a symbolic link." |
|
4362 |
||
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4363 |
|info type mode uid gid size id atime mtime ctime path| |
616 | 4364 |
|
4365 |
%{ /* STACK: 1200 */ |
|
792 | 4366 |
#ifdef S_IFLNK |
616 | 4367 |
struct stat buf; |
4368 |
int ret; |
|
4369 |
char pathBuffer[1024]; |
|
4370 |
||
4371 |
if (__isString(aPathName)) { |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4372 |
__BEGIN_INTERRUPTABLE__ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4373 |
do { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4374 |
ret = lstat((char *) __stringVal(aPathName), &buf); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4375 |
} while ((ret < 0) && (errno == EINTR)); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4376 |
__END_INTERRUPTABLE__ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4377 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4378 |
if (ret < 0) { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4379 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4380 |
RETURN ( nil ); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4381 |
} |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4382 |
switch (buf.st_mode & S_IFMT) { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4383 |
default: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4384 |
RETURN ( nil ); /* not a symbolic link */ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4385 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4386 |
case S_IFLNK: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4387 |
type = @symbol(symbolicLink); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4388 |
break; |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4389 |
} |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4390 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4391 |
mode = __MKSMALLINT(buf.st_mode & 0777); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4392 |
uid = __MKSMALLINT(buf.st_uid); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4393 |
gid = __MKSMALLINT(buf.st_gid); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4394 |
size = __MKSMALLINT(buf.st_size); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4395 |
id = __MKSMALLINT(buf.st_ino); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4396 |
atime = __MKUINT(buf.st_atime); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4397 |
mtime = __MKUINT(buf.st_mtime); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4398 |
ctime = __MKUINT(buf.st_ctime); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4399 |
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
|
4400 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4401 |
RETURN ( nil ); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4402 |
} |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4403 |
pathBuffer[ret] = '\0'; /* readlink does not 0-terminate */ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4404 |
path = __MKSTRING(pathBuffer); |
616 | 4405 |
} |
792 | 4406 |
#else |
4407 |
RETURN ( nil ); |
|
4408 |
#endif |
|
616 | 4409 |
%}. |
4410 |
mode notNil ifTrue:[ |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4411 |
info := IdentityDictionary new. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4412 |
^ FileStatusInfo |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4413 |
type:type |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4414 |
mode:mode |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4415 |
uid:uid |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4416 |
gid:gid |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4417 |
size:size |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4418 |
id:id |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4419 |
accessed:(AbsoluteTime fromOSTime:(atime * 1000)) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4420 |
modified:(AbsoluteTime fromOSTime:(mtime * 1000)) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4421 |
statusChanged:(AbsoluteTime fromOSTime:(ctime * 1000)) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4422 |
path:path |
616 | 4423 |
]. |
792 | 4424 |
^ self primitiveFailed |
616 | 4425 |
|
4426 |
" |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4427 |
OperatingSystem infoOf:'Make.proto' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4428 |
OperatingSystem linkInfoOf:'Make.proto' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4429 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4430 |
OperatingSystem infoOf:'resources/motif.style' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4431 |
OperatingSystem linkInfoOf:'resources/motif.style' |
616 | 4432 |
" |
4433 |
! |
|
4434 |
||
4435 |
parentDirectoryName |
|
4436 |
"return the name used to refer to parent directories. |
|
4437 |
In MSDOS, Unix and other systems this is '..', but maybe different |
|
4438 |
for other systems. |
|
4439 |
(but those are currently not supported - so this is some |
|
4440 |
preparation for the future)" |
|
4441 |
||
4442 |
^ '..' |
|
68 | 4443 |
! |
4444 |
||
616 | 4445 |
pathNameOf:pathName |
4446 |
"return the pathName of the argument, aPathString, |
|
4447 |
- thats the full pathname of the directory, starting at '/'. |
|
4448 |
This method needs the path to be valid |
|
4449 |
(i.e. all directories must exist, be readable and executable). |
|
4450 |
Notice: if symbolic links are involved, the result may look different |
|
4451 |
from what you expect." |
|
4452 |
||
4453 |
|p path command| |
|
4454 |
||
4455 |
"some systems have a convenient function for this ..." |
|
4456 |
path := self primPathNameOf:pathName. |
|
4457 |
||
4458 |
path isNil ifTrue:[ |
|
2080
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4459 |
(self isValidPath:pathName) ifFalse:[ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4460 |
p := pathName. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4461 |
[(p size > 1) |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4462 |
and:[p endsWith:(self fileSeparator)] |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4463 |
] whileTrue:[ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4464 |
p := p copyWithoutLast:1. |
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 |
^ p |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4467 |
]. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4468 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4469 |
(SlowFork==true or:[ForkFailed==true]) ifFalse:[ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4470 |
PipeStream openErrorSignal handle:[:ex | |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4471 |
ForkFailed := true. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4472 |
'OS: cannot fork/popen' errorPrintNL. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4473 |
ex return. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4474 |
] do:[ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4475 |
"have to fall back ..." |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4476 |
command := 'cd ' , pathName , '; pwd'. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4477 |
p := PipeStream readingFrom:command. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4478 |
]. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4479 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4480 |
(p isNil or:[p atEnd]) ifTrue:[ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4481 |
('OS: PipeStream for <' , command , '> failed') errorPrintNL. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4482 |
] ifFalse:[ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4483 |
path := p nextLine. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4484 |
p close. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4485 |
]. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4486 |
]. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4487 |
path isNil ifTrue:[ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4488 |
path := pathName |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4489 |
]. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4490 |
(SlowFork==true or:[ForkFailed==true]) ifTrue:[ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4491 |
path := self compressPath:path |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4492 |
] |
616 | 4493 |
]. |
4494 |
^ path. |
|
4495 |
||
4496 |
" |
|
4497 |
OperatingSystem pathNameOf:'.' |
|
4498 |
OperatingSystem pathNameOf:'../smalltalk/../smalltalk' |
|
4499 |
OperatingSystem pathNameOf:'../../..' |
|
4500 |
OperatingSystem pathNameOf:'..' |
|
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4501 |
OperatingSystem pathNameOf:'/tmp////' |
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 |
OperatingSystem pathNameOf:'/foo/bar/' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4504 |
OperatingSystem pathNameOf:'/foo/bar//' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4505 |
" |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4506 |
|
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4507 |
"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
|
4508 |
"Modified: 29.11.1996 / 18:02:12 / stefan" |
359 | 4509 |
! |
4510 |
||
616 | 4511 |
primPathNameOf:pathName |
4512 |
"return the pathName of the argument, aPathString, |
|
4513 |
- thats the full pathname of the directory, starting at '/'. |
|
4514 |
This method here returns nil, if the OS does not provide a |
|
4515 |
realPath library function. |
|
4516 |
Notice: if symbolic links are involved, the result may look different |
|
4517 |
from what you expect." |
|
4518 |
||
4519 |
|path| |
|
4520 |
||
4521 |
"some systems have a convenient function for this ..." |
|
4522 |
%{ /* STACK: 16000 */ |
|
4523 |
#ifdef HAS_REALPATH |
|
4524 |
char nameBuffer[MAXPATHLEN + 1]; |
|
4525 |
||
4526 |
if (__isString(pathName)) { |
|
1135 | 4527 |
if (realpath(__stringVal(pathName), nameBuffer)) { |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
4528 |
RETURN ( __MKSTRING(nameBuffer) ); |
616 | 4529 |
} |
4530 |
} |
|
1632 | 4531 |
#else |
4532 |
# ifdef WIN32 |
|
4533 |
char nameBuffer[MAXPATHLEN + 1]; |
|
4534 |
char *pFinal; |
|
4535 |
||
4536 |
if (__isString(pathName)) { |
|
4537 |
if (GetFullPathName(__stringVal(pathName), sizeof(nameBuffer), |
|
4538 |
nameBuffer, &pFinal)) { |
|
4539 |
RETURN ( __MKSTRING(nameBuffer) ); |
|
4540 |
} |
|
4541 |
} |
|
4542 |
# endif |
|
616 | 4543 |
#endif |
4544 |
%}. |
|
4545 |
^ nil |
|
359 | 4546 |
! |
4547 |
||
616 | 4548 |
timeOfLastAccess:aPathName |
4549 |
"return the time, when the file was last accessed. |
|
4550 |
For nonexistent files, nil is returned." |
|
4551 |
||
4552 |
"could be implemented as: |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4553 |
(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
|
4554 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4555 |
|osSeconds| |
616 | 4556 |
%{ |
4557 |
struct stat buf; |
|
4558 |
time_t mtime; |
|
4559 |
int ret; |
|
4560 |
||
4561 |
if (__isString(aPathName)) { |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4562 |
__BEGIN_INTERRUPTABLE__ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4563 |
do { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4564 |
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
|
4565 |
} while (ret < 0 && errno == EINTR); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4566 |
__END_INTERRUPTABLE__ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4567 |
if (ret < 0) { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4568 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4569 |
RETURN (nil); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4570 |
} |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4571 |
osSeconds = __MKUINT(buf.st_atime); |
616 | 4572 |
} |
792 | 4573 |
%}. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4574 |
osSeconds notNil ifTrue:[^ AbsoluteTime fromOSTime:(osSeconds * 1000)]. |
792 | 4575 |
^ self primitiveFailed |
616 | 4576 |
|
4577 |
" |
|
4578 |
OperatingSystem timeOfLastAccess:'/' |
|
4579 |
" |
|
359 | 4580 |
! |
4581 |
||
616 | 4582 |
timeOfLastChange:aPathName |
4583 |
"return the time, when the file was last changed. |
|
4584 |
For nonexistent files, nil is returned." |
|
4585 |
||
4586 |
"could be implemented as: |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4587 |
(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
|
4588 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4589 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4590 |
|osSeconds| |
616 | 4591 |
%{ |
4592 |
struct stat buf; |
|
4593 |
int ret; |
|
4594 |
time_t mtime; |
|
4595 |
||
4596 |
if (__isString(aPathName)) { |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4597 |
__BEGIN_INTERRUPTABLE__ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4598 |
do { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4599 |
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
|
4600 |
} while (ret < 0 && errno == EINTR); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4601 |
__END_INTERRUPTABLE__ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4602 |
if (ret < 0) { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4603 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4604 |
RETURN ( nil ); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4605 |
} |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4606 |
osSeconds = __MKUINT(buf.st_mtime); |
616 | 4607 |
} |
792 | 4608 |
%}. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4609 |
osSeconds notNil ifTrue:[^ AbsoluteTime fromOSTime:(osSeconds * 1000)]. |
792 | 4610 |
^ self primitiveFailed |
616 | 4611 |
|
4612 |
" |
|
4613 |
OperatingSystem timeOfLastChange:'/' |
|
4614 |
" |
|
4615 |
! |
|
4616 |
||
4617 |
typeOf:aPathName |
|
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4618 |
"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
|
4619 |
nil is returned. |
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4620 |
Notice: for symbolic links, the type of the pointed-to file is returned." |
616 | 4621 |
|
4622 |
" |
|
4623 |
this could have been implemented as: |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4624 |
(self infoOf:aPathName) at:#type |
616 | 4625 |
but for huge directory searches the code below is faster |
4626 |
" |
|
359 | 4627 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4628 |
%{ |
616 | 4629 |
struct stat buf; |
4630 |
int ret; |
|
4631 |
||
4632 |
if (__isString(aPathName)) { |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4633 |
__BEGIN_INTERRUPTABLE__ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4634 |
do { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4635 |
ret = stat((char *) __stringVal(aPathName), &buf); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4636 |
} while (ret < 0 && errno == EINTR); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4637 |
__END_INTERRUPTABLE__ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4638 |
if (ret < 0) { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4639 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4640 |
RETURN ( nil ); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4641 |
} |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4642 |
switch (buf.st_mode & S_IFMT) { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4643 |
case S_IFDIR: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4644 |
RETURN ( @symbol(directory) ); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4645 |
case S_IFREG: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4646 |
RETURN ( @symbol(regular) ); |
616 | 4647 |
#ifdef S_IFCHR |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4648 |
case S_IFCHR: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4649 |
RETURN ( @symbol(characterSpecial) ); |
616 | 4650 |
#endif |
4651 |
#ifdef S_IFBLK |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4652 |
case S_IFBLK: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4653 |
RETURN ( @symbol(blockSpecial) ); |
616 | 4654 |
#endif |
4655 |
#ifdef S_IFLNK |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4656 |
case S_IFLNK: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4657 |
RETURN ( @symbol(symbolicLink) ); |
616 | 4658 |
#endif |
4659 |
#ifdef S_IFSOCK |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4660 |
case S_IFSOCK: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4661 |
RETURN ( @symbol(socket) ); |
616 | 4662 |
#endif |
4663 |
#ifdef S_IFIFO |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4664 |
case S_IFIFO: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4665 |
RETURN ( @symbol(fifo) ); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4666 |
#endif |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4667 |
default: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4668 |
RETURN ( @symbol(unknown) ); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4669 |
} |
616 | 4670 |
} |
4671 |
%}. |
|
792 | 4672 |
^ self primitiveFailed |
616 | 4673 |
|
4674 |
" |
|
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4675 |
OperatingSystem typeOf:'/' |
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4676 |
OperatingSystem typeOf:'.' |
616 | 4677 |
OperatingSystem typeOf:'Make.proto' |
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4678 |
OperatingSystem typeOf:'resources/motif.style' |
616 | 4679 |
" |
68 | 4680 |
! ! |
4681 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4682 |
!OperatingSystem class methodsFor:'interrupts & signals'! |
63 | 4683 |
|
10 | 4684 |
blockInterrupts |
95 | 4685 |
"disable interrupt processing - if disabled, incoming |
4686 |
interrupts will be registered and handled as soon as |
|
4687 |
interrupts are reenabled by OperatingSystemclass>>unblockInterrupts. |
|
4688 |
Returns the previous blocking status i.e. true if interrupts |
|
4689 |
where already blocked. You need this information for proper |
|
4690 |
unblocking, in case of nested block/unblock calls." |
|
4691 |
||
4692 |
%{ /* NOCONTEXT */ |
|
710 | 4693 |
RETURN ( __BLOCKINTERRUPTS() ); |
10 | 4694 |
%} |
4695 |
! |
|
4696 |
||
616 | 4697 |
defaultSignal:signalNumber |
4698 |
"revert to the default action on arrival of a (Unix-)signal. |
|
4699 |
Dont confuse Unix signals with smalltalk signals. |
|
4700 |
WARNING: for some signals, it is no good idea to revert to default; |
|
4701 |
for example, the default for SIGINT (i.e. ^C) is to exit; while the |
|
4702 |
default for SIGQUIT (^ \) is to dump core. |
|
4703 |
Also, NOTICE that signal numbers are not portable between unix |
|
4704 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
4705 |
a signal." |
|
4706 |
||
4707 |
%{ /* NOCONTEXT */ |
|
4708 |
||
4709 |
if (__isSmallInteger(signalNumber)) { |
|
831 | 4710 |
#ifdef SIG_DFL |
1135 | 4711 |
signal(__intVal(signalNumber), SIG_DFL); |
616 | 4712 |
RETURN (self); |
831 | 4713 |
#endif |
616 | 4714 |
} |
4715 |
%}. |
|
4716 |
" |
|
4717 |
this error is triggered on non-integer argument |
|
4718 |
" |
|
792 | 4719 |
^ self primitiveFailed |
616 | 4720 |
|
4721 |
"you better save a snapshot image before trying this ..." |
|
4722 |
" |
|
4723 |
'if you hit ^C now, Smalltalk will exit immediately' printNewline. |
|
4724 |
OperatingSystem defaultSignal:(OperatingSystem sigINT). |
|
4725 |
1 to:1000000 do:[:i| ]. |
|
4726 |
OperatingSystem enableSignal:(OperatingSystem sigINT). |
|
4727 |
'normal ^C handling again.' printNewline |
|
4728 |
" |
|
4729 |
! |
|
4730 |
||
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4731 |
disableChildSignalInterrupts |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4732 |
"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
|
4733 |
(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
|
4734 |
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
|
4735 |
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
|
4736 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4737 |
^ 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
|
4738 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4739 |
"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
|
4740 |
! |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4741 |
|
616 | 4742 |
disableIOInterruptsOn:fd |
4743 |
"turn off IO interrupts for a filedescriptor" |
|
4744 |
||
4745 |
%{ /* NOCONTEXT */ |
|
4746 |
||
4747 |
int ret, flags, f; |
|
4748 |
||
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4749 |
#if (defined(F_GETFL) && defined(F_SETFL) && defined(FASYNC)) || defined(SYSV4) |
616 | 4750 |
if (__isSmallInteger(fd)) { |
1135 | 4751 |
f = __intVal(fd); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4752 |
# if defined(SYSV4) |
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
756
diff
changeset
|
4753 |
ret = ioctl(f, I_SETSIG, 0); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4754 |
# else /*! SYSV4*/ |
616 | 4755 |
flags = fcntl(f, F_GETFL, 0); |
4756 |
/* |
|
4757 |
* if already clear, there is no need for this syscall ... |
|
4758 |
*/ |
|
4759 |
if (flags & FASYNC) { |
|
4760 |
ret = fcntl(f, F_SETFL, flags & ~FASYNC); |
|
4761 |
if (ret >= 0) ret = flags; |
|
4762 |
} else { |
|
4763 |
ret = flags; |
|
4764 |
} |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4765 |
# endif /* !SYSV4 */ |
1135 | 4766 |
RETURN ( __MKSMALLINT(ret) ); |
616 | 4767 |
} |
4768 |
#endif |
|
4769 |
%}. |
|
4770 |
" |
|
4771 |
this error is triggered on non-integer argument |
|
4772 |
or if the OS does not support IO interrupts. |
|
4773 |
" |
|
792 | 4774 |
^ self primitiveFailed |
10 | 4775 |
! |
4776 |
||
63 | 4777 |
disableSignal:signalNumber |
95 | 4778 |
"disable (Unix-) signal processing for signalNumber. |
4779 |
Dont confuse Unix signals with smalltalk signals. |
|
63 | 4780 |
WARNING: for some signals, it is no good idea to disable |
95 | 4781 |
them; for example, disabling the SIGINT signal turns off ^C |
63 | 4782 |
handling. |
68 | 4783 |
Also, NOTICE that signal numbers are not portable between unix |
4784 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
4785 |
a signal. |
|
63 | 4786 |
Use only for fully debugged stand alone applications." |
4787 |
||
4788 |
%{ /* NOCONTEXT */ |
|
4789 |
||
252 | 4790 |
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
|
4791 |
int sigNo = __intVal(signalNumber); |
831 | 4792 |
|
4793 |
if (sigNo == 0) { |
|
4794 |
RETURN (self); |
|
4795 |
} |
|
4796 |
#ifdef SIG_IGN |
|
4797 |
signal(sigNo, SIG_IGN); |
|
185 | 4798 |
RETURN (self); |
831 | 4799 |
#endif |
63 | 4800 |
} |
68 | 4801 |
%}. |
4802 |
" |
|
4803 |
this error is triggered on non-integer argument |
|
4804 |
" |
|
792 | 4805 |
^ self primitiveFailed |
68 | 4806 |
|
4807 |
" |
|
4808 |
'now, ^C is totally ignored ...' printNewline. |
|
4809 |
OperatingSystem disableSignal:(OperatingSystem sigINT). |
|
4810 |
1 to:1000000 do:[:i| ]. |
|
4811 |
OperatingSystem enableSignal:(OperatingSystem sigINT). |
|
4812 |
'^C handled again.' printNewline |
|
4813 |
" |
|
4814 |
! |
|
4815 |
||
616 | 4816 |
disableTimer |
831 | 4817 |
"disable timer interrupts. |
4818 |
WARNING: |
|
4819 |
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
|
4820 |
disabled, because no scheduling or timeouts are possible." |
616 | 4821 |
|
4822 |
%{ /* NOCONTEXT */ |
|
4823 |
||
1632 | 4824 |
#if defined(WIN32) |
4825 |
KillTimer(NULL, w32TimerId); |
|
4826 |
w32TimerId = 0; |
|
4827 |
RETURN (true); |
|
4828 |
#else |
|
4829 |
# if defined(ITIMER_REAL) |
|
616 | 4830 |
struct itimerval dt; |
4831 |
||
4832 |
dt.it_interval.tv_sec = 0; |
|
4833 |
dt.it_interval.tv_usec = 0; |
|
4834 |
dt.it_value.tv_sec = 0; |
|
4835 |
dt.it_value.tv_usec = 0; |
|
4836 |
setitimer(ITIMER_REAL, &dt, 0); |
|
4837 |
RETURN (true); |
|
1632 | 4838 |
# endif /* ITIMER_REAL */ |
4839 |
#endif |
|
616 | 4840 |
%} |
4841 |
. |
|
4842 |
^ false |
|
4843 |
! |
|
4844 |
||
4845 |
disableUserInterrupts |
|
4846 |
"disable userInterrupt processing; |
|
4847 |
when disabled, no ^C processing takes place. |
|
831 | 4848 |
WARNING: |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4849 |
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
|
4850 |
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
|
4851 |
We recommend setting up a handler for the signal instead of disabling it." |
831 | 4852 |
|
4853 |
self disableSignal:(self sigBREAK). |
|
4854 |
self disableSignal:(self sigINT). |
|
616 | 4855 |
! |
4856 |
||
4857 |
enableAbortInterrupts |
|
4858 |
"enable abort signalhandling, and make it a regular signalInterrupt. |
|
4859 |
(the default will dump core and exit - which is not a good idea for |
|
4860 |
end-user applications ...). |
|
4861 |
This is especially useful, if linked-in C-libraries call abort() ..." |
|
4862 |
||
831 | 4863 |
self enableSignal:(self sigABRT) |
616 | 4864 |
! |
4865 |
||
4866 |
enableChildSignalInterrupts |
|
4867 |
"enable childSignal interrupts |
|
4868 |
(SIGCHLD, if the architecture supports it). |
|
831 | 4869 |
After enabling, these signals will send the message |
616 | 4870 |
'childSignalInterrupt' to the ChildSignalInterruptHandler object." |
4871 |
||
831 | 4872 |
self enableSignal:(self sigCHLD) |
616 | 4873 |
! |
4874 |
||
4875 |
enableFpExceptionInterrupts |
|
4876 |
"enable floating point exception interrupts (if the |
|
4877 |
architecture supports it). |
|
831 | 4878 |
After enabling, fpu-exceptions will send the message |
616 | 4879 |
'fpuExceptionInterrupt' to the FPUExceptionInterruptHandler object." |
4880 |
||
831 | 4881 |
self enableSignal:(self sigFP) |
616 | 4882 |
! |
4883 |
||
4884 |
enableHardSignalInterrupts |
|
4885 |
"enable hard signal exception interrupts (trap, buserror & segm. violation). |
|
831 | 4886 |
After enabling, these exceptions will send the message |
616 | 4887 |
'signalInterrupt' to the SignalInterruptHandler object." |
68 | 4888 |
|
855
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
4889 |
"/ 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
|
4890 |
"/ 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
|
4891 |
|
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
4892 |
"/ ... 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
|
4893 |
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
|
4894 |
|
1808
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
4895 |
self enableSignal:(self sigILL). |
640
be94dfc60eaa
Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents:
630
diff
changeset
|
4896 |
self enableSignal:(self sigBUS). |
be94dfc60eaa
Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents:
630
diff
changeset
|
4897 |
self enableSignal:(self sigSEGV) |
616 | 4898 |
! |
4899 |
||
4900 |
enableIOInterruptsOn:fd |
|
4901 |
"turn on IO interrupts for a filedescriptor" |
|
4902 |
||
4903 |
%{ /* NOCONTEXT */ |
|
4904 |
||
4905 |
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
|
4906 |
#ifndef __signalIoInterrupt |
616 | 4907 |
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
|
4908 |
#endif |
616 | 4909 |
static int firstCall = 1; |
4910 |
||
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4911 |
#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
|
4912 |
/* |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4913 |
* SIGIO/SIGPOLL - data available for I/O |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4914 |
* (used to wake up waiting processes) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4915 |
*/ |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4916 |
#ifdef SIGIO |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4917 |
# define THESIGNAL SIGIO |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4918 |
#else |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4919 |
# ifdef SIGPOLL |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4920 |
# define THESIGNAL SIGPOLL |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4921 |
# else |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4922 |
# ifdef SIGURG |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4923 |
# define THESIGNAL SIGURG |
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 |
# endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4926 |
#endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4927 |
|
616 | 4928 |
if (__isSmallInteger(fd)) { |
4929 |
if (firstCall) { |
|
762
cea705669628
ok, stefan was right: HAS_SIGACTION works
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
4930 |
#ifdef HAS_SIGACTION |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4931 |
struct sigaction act; |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4932 |
|
1487 | 4933 |
/* |
4934 |
* Do not add SA_RESTART here. A signal can cause a |
|
4935 |
* thread switch, another thread can do a garbage collect |
|
4936 |
* and restarted system calls may write into old |
|
4937 |
* (collected) addresses. |
|
4938 |
*/ |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4939 |
|
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4940 |
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
|
4941 |
sigemptyset(&act.sa_mask); |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4942 |
act.sa_handler = __signalIoInterrupt; |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4943 |
sigaction(THESIGNAL, &act, 0); |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4944 |
#else |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4945 |
# ifdef HAS_SIGVEC |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4946 |
struct sigvec vec; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4947 |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4948 |
vec.sv_flags = SV_INTERRUPT; |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4949 |
sigemptyset(&vec.sv_mask); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4950 |
vec.sv_handler = __signalIoInterrupt; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4951 |
sigvec(THESIGNAL, &vec, NULL); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4952 |
# else |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4953 |
signal(THESIGNAL, __signalIoInterrupt); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4954 |
# endif |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4955 |
#endif |
616 | 4956 |
firstCall = 0; |
4957 |
} |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4958 |
#undef THESIGNAL |
616 | 4959 |
|
1135 | 4960 |
f = __intVal(fd); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4961 |
# if defined(SYSV4) |
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
756
diff
changeset
|
4962 |
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
|
4963 |
# else /*! SYSV4*/ |
616 | 4964 |
flags = fcntl(f, F_GETFL, 0); |
4965 |
/* |
|
4966 |
* if already set, there is no need for this syscall ... |
|
4967 |
*/ |
|
4968 |
if (flags & FASYNC) { |
|
4969 |
ret = flags; |
|
4970 |
} else { |
|
4971 |
ret = fcntl(f, F_SETFL, flags | FASYNC); |
|
4972 |
if (ret >= 0) ret = flags; |
|
4973 |
} |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4974 |
# endif /*!SYSV4*/ |
1135 | 4975 |
RETURN ( __MKSMALLINT(ret) ); |
68 | 4976 |
} |
616 | 4977 |
#endif |
68 | 4978 |
%}. |
4979 |
" |
|
4980 |
this error is triggered on non-integer argument |
|
616 | 4981 |
or if the system does not support SIGIO |
68 | 4982 |
" |
792 | 4983 |
^ self primitiveFailed |
616 | 4984 |
! |
4985 |
||
4986 |
enableQuitInterrupts |
|
4987 |
"enable quitInterrupt (usually ^\) handling, and make it a userInterrupt. |
|
4988 |
(the default will dump core and exit - which is not a good idea for |
|
4989 |
end-user applications ...)" |
|
4990 |
||
831 | 4991 |
self enableSignal:(self sigQUIT) |
68 | 4992 |
! |
4993 |
||
4994 |
enableSignal:signalNumber |
|
95 | 4995 |
"enable (Unix-)signal processing for signalNumber. |
4996 |
Dont confuse Unix signals with smalltalk signals. |
|
68 | 4997 |
The signal will be delivered to one of the standard handlers |
4998 |
(SIGINT, SIGQUIT, etc) or to a general handler, which |
|
4999 |
sends #signalInterrupt:. |
|
5000 |
||
5001 |
NOTICE that signal numbers are not portable between unix |
|
5002 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
5003 |
a signal." |
|
5004 |
||
5005 |
%{ /* NOCONTEXT */ |
|
5006 |
||
5007 |
#ifdef NSIG |
|
5008 |
# define SIG_LIMIT NSIG |
|
5009 |
#else |
|
5010 |
# ifdef SIGUSR2 |
|
5011 |
# define SIG_LIMIT SIGUSR2 |
|
5012 |
# else |
|
5013 |
# ifdef SIGUSR |
|
5014 |
# define SIG_LIMIT SIGUSR |
|
5015 |
# endif |
|
5016 |
# endif |
|
5017 |
#endif |
|
5018 |
||
5019 |
#if defined(SIGPOLL) && !defined(SIGIO) |
|
5020 |
# define SIGIO SIGPOLL |
|
5021 |
#endif |
|
5022 |
||
5023 |
#ifdef SIGCHLD |
|
5024 |
# define CHILD_SIGNAL SIGCHLD |
|
5025 |
#else |
|
5026 |
# ifdef SIGCLD |
|
5027 |
# define CHILD_SIGNAL SIGCLD |
|
5028 |
# endif |
|
5029 |
#endif |
|
5030 |
||
5031 |
int sigNr; |
|
443 | 5032 |
#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
|
5033 |
# ifndef __signalUserInterrupt |
831 | 5034 |
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
|
5035 |
# endif |
443 | 5036 |
#endif |
5037 |
#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
|
5038 |
# ifndef __signalFpExceptionInterrupt |
831 | 5039 |
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
|
5040 |
# endif |
443 | 5041 |
#endif |
5042 |
#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
|
5043 |
# ifndef __signalIoInterrupt |
831 | 5044 |
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
|
5045 |
# endif |
443 | 5046 |
#endif |
68 | 5047 |
#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
|
5048 |
# ifndef __signalChildInterrupt |
831 | 5049 |
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
|
5050 |
# endif |
68 | 5051 |
#endif |
443 | 5052 |
#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
|
5053 |
# ifndef __signalPIPEInterrupt |
831 | 5054 |
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
|
5055 |
# endif |
443 | 5056 |
#endif |
5057 |
#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
|
5058 |
# ifndef __signalBUSInterrupt |
831 | 5059 |
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
|
5060 |
# endif |
443 | 5061 |
#endif |
5062 |
#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
|
5063 |
# ifndef __signalSEGVInterrupt |
831 | 5064 |
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
|
5065 |
# endif |
443 | 5066 |
#endif |
1808
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
5067 |
#ifdef SIGILL |
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
5068 |
# ifndef __signalTrapInterrupt |
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
5069 |
extern void __signalTrapInterrupt(SIGHANDLER_ARG); |
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
5070 |
# endif |
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
5071 |
#endif |
443 | 5072 |
#ifdef SIGALRM |
831 | 5073 |
# 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
|
5074 |
# ifndef __signalTimerInterrupt |
831 | 5075 |
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
|
5076 |
# endif |
831 | 5077 |
# endif |
5078 |
#endif |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5079 |
#ifndef __signalInterrupt |
831 | 5080 |
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
|
5081 |
#endif |
831 | 5082 |
void (*handler)(SIGHANDLER_ARG); |
68 | 5083 |
|
252 | 5084 |
if (__isSmallInteger(signalNumber) |
1135 | 5085 |
&& ((sigNr = __intVal(signalNumber)) >= 0) |
831 | 5086 |
#ifdef SIG_LIMIT |
5087 |
&& (sigNr <= SIG_LIMIT) |
|
5088 |
#endif |
|
5089 |
) { |
|
185 | 5090 |
/* |
5091 |
* standard signals are forced into standard handlers |
|
5092 |
* - all others go into general signalInterrupt |
|
5093 |
*/ |
|
68 | 5094 |
#if defined(SIGPOLL) && defined(SIGIO) |
185 | 5095 |
if (sigNr == SIGPOLL) |
5096 |
sigNr = SIGIO; |
|
68 | 5097 |
#endif |
185 | 5098 |
switch (sigNr) { |
831 | 5099 |
case 0: |
5100 |
/* enabling a non-supported signal */ |
|
5101 |
RETURN (self); |
|
5102 |
||
5103 |
#ifdef SIGBREAK |
|
5104 |
case SIGBREAK: |
|
5105 |
#endif |
|
443 | 5106 |
#ifdef SIGINT |
185 | 5107 |
case SIGINT: |
443 | 5108 |
#endif |
5109 |
#ifdef SIGQUIT |
|
185 | 5110 |
case SIGQUIT: |
443 | 5111 |
#endif |
831 | 5112 |
#if defined(SIGINT) || defined(SIGQUIT) || defined(SIGBREAK) |
329 | 5113 |
handler = __signalUserInterrupt; |
185 | 5114 |
break; |
443 | 5115 |
#endif |
5116 |
||
5117 |
#ifdef SIGFPE |
|
185 | 5118 |
case SIGFPE: |
329 | 5119 |
handler = __signalFpExceptionInterrupt; |
185 | 5120 |
break; |
443 | 5121 |
#endif |
5122 |
||
5123 |
#ifdef SIGPIPE |
|
185 | 5124 |
case SIGPIPE: |
329 | 5125 |
handler = __signalPIPEInterrupt; |
185 | 5126 |
break; |
443 | 5127 |
#endif |
68 | 5128 |
#ifdef SIGBUS |
185 | 5129 |
case SIGBUS: |
329 | 5130 |
handler = __signalBUSInterrupt; |
185 | 5131 |
break; |
68 | 5132 |
#endif |
443 | 5133 |
#ifdef SIGSEGV |
185 | 5134 |
case SIGSEGV: |
329 | 5135 |
handler = __signalSEGVInterrupt; |
185 | 5136 |
break; |
443 | 5137 |
#endif |
1982
8d4f97279e55
oops - SIGILL was never cought
Claus Gittinger <cg@exept.de>
parents:
1966
diff
changeset
|
5138 |
#ifdef SIGILL |
8d4f97279e55
oops - SIGILL was never cought
Claus Gittinger <cg@exept.de>
parents:
1966
diff
changeset
|
5139 |
case SIGILL: |
1808
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
5140 |
handler = __signalTrapInterrupt; |
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
5141 |
break; |
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
5142 |
#endif |
68 | 5143 |
#ifdef SIGIO |
185 | 5144 |
case SIGIO: |
329 | 5145 |
handler = __signalIoInterrupt; |
185 | 5146 |
break; |
68 | 5147 |
#endif |
5148 |
||
5149 |
#ifdef CHILD_SIGNAL |
|
185 | 5150 |
case CHILD_SIGNAL: |
329 | 5151 |
handler = __signalChildInterrupt; |
185 | 5152 |
break; |
68 | 5153 |
#endif |
443 | 5154 |
#ifdef SIGALRM |
831 | 5155 |
# ifndef WIN32 |
185 | 5156 |
case SIGALRM: |
329 | 5157 |
handler = __signalTimerInterrupt; |
185 | 5158 |
break; |
831 | 5159 |
# endif |
443 | 5160 |
#endif |
185 | 5161 |
|
5162 |
default: |
|
329 | 5163 |
handler = __signalInterrupt; |
185 | 5164 |
break; |
5165 |
} |
|
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5166 |
|
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5167 |
{ |
762
cea705669628
ok, stefan was right: HAS_SIGACTION works
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
5168 |
#ifdef HAS_SIGACTION |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5169 |
struct sigaction act; |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5170 |
|
1487 | 5171 |
/* |
5172 |
* Do not add SA_RESTART here. A signal can cause a |
|
5173 |
* thread switch, another thread can do a garbage collect |
|
5174 |
* and restarted system calls may write into old |
|
5175 |
* (collected) addresses. |
|
5176 |
*/ |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
5177 |
|
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
5178 |
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
|
5179 |
sigemptyset(&act.sa_mask); |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5180 |
act.sa_handler = handler; |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5181 |
sigaction(sigNr, &act, 0); |
213 | 5182 |
#else |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5183 |
# ifdef HAS_SIGVEC |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5184 |
struct sigvec vec; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5185 |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
5186 |
vec.sv_flags = SV_INTERRUPT; |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5187 |
sigemptyset(&vec.sv_mask); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5188 |
vec.sv_handler = handler; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5189 |
sigvec(sigNr, &vec, NULL); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5190 |
# else |
831 | 5191 |
(void) signal(sigNr, handler); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5192 |
# endif |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5193 |
#endif |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5194 |
} |
213 | 5195 |
|
185 | 5196 |
/* |
5197 |
* maybe, we should return the old enable-status |
|
5198 |
* as boolean here ... |
|
5199 |
*/ |
|
5200 |
RETURN (self); |
|
68 | 5201 |
} |
5202 |
%}. |
|
5203 |
||
5204 |
" |
|
5205 |
this error is triggered on non-integer argument, or |
|
5206 |
if the signal number is not in the valid range (1..NSIG) |
|
5207 |
" |
|
792 | 5208 |
^ self primitiveFailed |
63 | 5209 |
! |
5210 |
||
831 | 5211 |
enableTimer:milliSeconds |
616 | 5212 |
"trigger a timerInterrupt, to be signalled after some (real) time." |
5213 |
||
5214 |
%{ /* NOCONTEXT */ |
|
831 | 5215 |
int millis; |
5216 |
||
5217 |
millis = __intVal(milliSeconds); |
|
616 | 5218 |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
5219 |
#if defined(ITIMER_REAL) |
831 | 5220 |
{ |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5221 |
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
|
5222 |
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
|
5223 |
#ifndef __signalTimerInterrupt |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5224 |
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
|
5225 |
#endif |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5226 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5227 |
if (firstCall) { |
831 | 5228 |
# ifdef HAS_SIGACTION |
5229 |
struct sigaction act; |
|
5230 |
||
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
5231 |
act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */ |
831 | 5232 |
sigemptyset(&act.sa_mask); |
5233 |
act.sa_handler = __signalTimerInterrupt; |
|
5234 |
sigaction(SIGALRM, &act, 0); |
|
5235 |
# else |
|
5236 |
# 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
|
5237 |
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
|
5238 |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
5239 |
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
|
5240 |
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
|
5241 |
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
|
5242 |
sigvec(SIGALRM, &vec, NULL); |
831 | 5243 |
# else |
5244 |
signal(SIGALRM, __signalTimerInterrupt); |
|
5245 |
# endif |
|
5246 |
# endif |
|
5247 |
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
|
5248 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5249 |
|
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_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
|
5251 |
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
|
5252 |
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
|
5253 |
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
|
5254 |
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
|
5255 |
RETURN (true); |
831 | 5256 |
} |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
5257 |
#else |
831 | 5258 |
# ifdef WIN32 |
5259 |
{ |
|
5260 |
/* |
|
5261 |
* two mechanisms - which one to use ? |
|
5262 |
*/ |
|
5263 |
# ifdef USE_TimerProc |
|
5264 |
||
5265 |
extern VOID CALLBACK __win32TimerProc(HWND, UINT, UINT, DWORD); |
|
1632 | 5266 |
w32TimerId = SetTimer(NULL, 0, millis, __win32TimerProc); |
831 | 5267 |
|
5268 |
# else /* USE_TimeProc */ |
|
5269 |
||
5270 |
extern void CALLBACK __win32TimeProc(UINT, UINT, DWORD, DWORD, DWORD, DWORD); |
|
1632 | 5271 |
timeSetEvent(millis, 5, (LPTIMECALLBACK)__win32TimeProc, 0, TIME_ONESHOT); |
831 | 5272 |
# endif |
1632 | 5273 |
RETURN (true); |
640
be94dfc60eaa
Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents:
630
diff
changeset
|
5274 |
} |
831 | 5275 |
# endif /* WIN32 */ |
5276 |
#endif /* ITIMER_REAL */ |
|
5277 |
%}. |
|
616 | 5278 |
^ false |
5279 |
! |
|
5280 |
||
1 | 5281 |
enableUserInterrupts |
5282 |
"enable userInterrupt (^C) handling; |
|
95 | 5283 |
when enabled, ^C in the terminal window will send the message |
5284 |
'userInterrupt' to the UserInterruptHandler object." |
|
1 | 5285 |
|
831 | 5286 |
self enableSignal:(self sigINT). |
5287 |
self enableSignal:(self sigBREAK). |
|
63 | 5288 |
! |
5289 |
||
616 | 5290 |
interruptPending |
5291 |
"return true, if an interrupt is pending. The returned value is |
|
5292 |
invalid if interrupts are not currently blocked, since otherwise |
|
5293 |
the interrupt is usually already handled before arriving here, |
|
5294 |
or may be served while returning from here." |
|
5295 |
||
2117
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5296 |
%{ /* NOCONTEXT */ |
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5297 |
extern OBJ __INTERRUPTPENDING(); |
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5298 |
|
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5299 |
RETURN ( __INTERRUPTPENDING() ); |
616 | 5300 |
%} |
1 | 5301 |
! |
5302 |
||
2117
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5303 |
interruptsBlocked |
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5304 |
"return true, if interrupt handling is currently disabled; |
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5305 |
false otherwise." |
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5306 |
|
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5307 |
%{ /* NOCONTEXT */ |
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5308 |
extern OBJ __INTERRUPTS_BLOCKED(); |
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5309 |
|
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5310 |
RETURN ( __INTERRUPTS_BLOCKED() ); |
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5311 |
%} |
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5312 |
! |
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5313 |
|
704 | 5314 |
killProcess:processId |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5315 |
"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
|
5316 |
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
|
5317 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5318 |
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
|
5319 |
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
|
5320 |
OperatingSystem>>getStatusOfProcess:aProcessId." |
704 | 5321 |
|
5322 |
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
|
5323 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5324 |
"Modified: 28.12.1995 / 15:06:18 / stefan" |
704 | 5325 |
! |
5326 |
||
616 | 5327 |
nameForSignal:aSignalNumber |
5328 |
"for a given Unix signalnumber, return a descriptive string" |
|
5329 |
||
5330 |
aSignalNumber == self sigHUP ifTrue:[^ 'hangup']. |
|
5331 |
aSignalNumber == self sigINT ifTrue:[^ 'interrupt']. |
|
5332 |
aSignalNumber == self sigKILL ifTrue:[^ 'kill']. |
|
5333 |
aSignalNumber == self sigQUIT ifTrue:[^ 'quit']. |
|
5334 |
aSignalNumber == self sigILL ifTrue:[^ 'illegal instruction']. |
|
5335 |
aSignalNumber == self sigTRAP ifTrue:[^ 'trap']. |
|
5336 |
aSignalNumber == self sigABRT ifTrue:[^ 'abort']. |
|
5337 |
aSignalNumber == self sigIOT ifTrue:[^ 'iot trap']. |
|
5338 |
aSignalNumber == self sigEMT ifTrue:[^ 'emt trap']. |
|
5339 |
aSignalNumber == self sigFP ifTrue:[^ 'fp exception']. |
|
5340 |
aSignalNumber == self sigBUS ifTrue:[^ 'bus error']. |
|
5341 |
aSignalNumber == self sigSEGV ifTrue:[^ 'segmentation violation']. |
|
5342 |
aSignalNumber == self sigSYS ifTrue:[^ 'bad system call']. |
|
5343 |
aSignalNumber == self sigPIPE ifTrue:[^ 'broken pipe']. |
|
5344 |
aSignalNumber == self sigALRM ifTrue:[^ 'alarm timer']. |
|
5345 |
aSignalNumber == self sigTERM ifTrue:[^ 'termination']. |
|
5346 |
aSignalNumber == self sigSTOP ifTrue:[^ 'stop']. |
|
5347 |
aSignalNumber == self sigTSTP ifTrue:[^ 'tty stop']. |
|
5348 |
aSignalNumber == self sigCONT ifTrue:[^ 'continue']. |
|
5349 |
aSignalNumber == self sigCHLD ifTrue:[^ 'child death']. |
|
5350 |
aSignalNumber == self sigTTIN ifTrue:[^ 'background tty input']. |
|
5351 |
aSignalNumber == self sigTTOU ifTrue:[^ 'background tty output']. |
|
5352 |
aSignalNumber == self sigIO ifTrue:[^ 'io available']. |
|
5353 |
aSignalNumber == self sigXCPU ifTrue:[^ 'cpu time expired']. |
|
5354 |
aSignalNumber == self sigXFSZ ifTrue:[^ 'file size limit']. |
|
5355 |
aSignalNumber == self sigVTALRM ifTrue:[^ 'virtual alarm timer']. |
|
5356 |
aSignalNumber == self sigPROF ifTrue:[^ 'profiling timer']. |
|
5357 |
aSignalNumber == self sigWINCH ifTrue:[^ 'winsize changed']. |
|
5358 |
aSignalNumber == self sigLOST ifTrue:[^ 'resource lost']. |
|
5359 |
aSignalNumber == self sigUSR1 ifTrue:[^ 'user signal 1']. |
|
5360 |
aSignalNumber == self sigUSR2 ifTrue:[^ 'user signal 2']. |
|
5361 |
aSignalNumber == self sigMSG ifTrue:[^ 'HFT message']. |
|
5362 |
aSignalNumber == self sigPWR ifTrue:[^ 'power-fail']. |
|
5363 |
aSignalNumber == self sigPRE ifTrue:[^ 'programming exception']. |
|
5364 |
aSignalNumber == self sigGRANT ifTrue:[^ 'HFT access wanted']. |
|
5365 |
aSignalNumber == self sigRETRACT ifTrue:[^ 'HFT access relinquish']. |
|
5366 |
aSignalNumber == self sigSOUND ifTrue:[^ 'HFT sound complete']. |
|
5367 |
aSignalNumber == self sigDANGER ifTrue:[^ 'low on paging space']. |
|
5368 |
||
5369 |
"notice: many systems map SIGPOLL and/or SIGUSR onto SIGIO |
|
5370 |
therefore, keep SIGIO always above the two below" |
|
5371 |
aSignalNumber == self sigPOLL ifTrue:[^ 'io available']. |
|
5372 |
aSignalNumber == self sigURG ifTrue:[^ 'urgent']. |
|
5373 |
||
5374 |
^ 'unknown signal' |
|
5375 |
||
68 | 5376 |
" |
616 | 5377 |
OperatingSystem nameForSignal:9 |
5378 |
OperatingSystem nameForSignal:(OperatingSystem sigPOLL) |
|
68 | 5379 |
" |
616 | 5380 |
! |
5381 |
||
5382 |
operatingSystemSignal:signalNumber |
|
5383 |
"return the signal to be raised when an |
|
5384 |
operatingSystem-signal occurs, or nil" |
|
5385 |
||
5386 |
OSSignals notNil ifTrue:[ |
|
5387 |
^ OSSignals at:signalNumber ifAbsent:[nil] |
|
5388 |
]. |
|
5389 |
^ nil |
|
10 | 5390 |
! |
5391 |
||
616 | 5392 |
operatingSystemSignal:signalNumber install:aSignal |
5393 |
"install a signal to be raised when an operatingSystem-signal occurs" |
|
5394 |
||
5395 |
OSSignals isNil ifTrue:[ |
|
5396 |
OSSignals := Array new:32 |
|
5397 |
]. |
|
5398 |
OSSignals at:signalNumber put:aSignal |
|
5399 |
! |
|
5400 |
||
5401 |
sendSignal:signalNumber to:processId |
|
5402 |
"send a unix signal to some process (maybe myself). |
|
5403 |
Returns false if any error occurred, true otherwise. |
|
5404 |
||
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5405 |
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
|
5406 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5407 |
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
|
5408 |
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
|
5409 |
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
|
5410 |
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
|
5411 |
|
616 | 5412 |
%{ |
792 | 5413 |
#ifndef MSDOS_LIKE |
616 | 5414 |
if (__bothSmallInteger(signalNumber, processId)) { |
5415 |
if (kill(__intVal(processId), __intVal(signalNumber)) < 0) { |
|
1135 | 5416 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 5417 |
RETURN ( false ); |
216 | 5418 |
} |
616 | 5419 |
RETURN ( true ); |
10 | 5420 |
} |
792 | 5421 |
#endif |
68 | 5422 |
%}. |
792 | 5423 |
"/ |
5424 |
"/ either invalid argument (non-integers) |
|
5425 |
"/ or not supported by OS |
|
5426 |
"/ |
|
5427 |
^ self primitiveFailed |
|
1 | 5428 |
! |
5429 |
||
5430 |
startSpyTimer |
|
63 | 5431 |
"trigger a spyInterrupt, to be signalled after some short (virtual) time. |
359 | 5432 |
This is used by the old MessageTally for profiling. |
63 | 5433 |
Should be changed to use real profiling timer if available. |
68 | 5434 |
On systems, where no virtual timer is available, use the real timer |
359 | 5435 |
(which is of course less correct). |
5436 |
OBSOLETE: the new messageTally runs as a high prio process, not using |
|
5437 |
spy interrupts." |
|
1 | 5438 |
|
5439 |
%{ /* NOCONTEXT */ |
|
5440 |
||
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5441 |
#ifndef __spyInterrupt |
329 | 5442 |
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
|
5443 |
#endif |
10 | 5444 |
#if defined(ITIMER_VIRTUAL) |
1 | 5445 |
struct itimerval dt; |
5446 |
||
13 | 5447 |
# ifdef SIGVTALRM |
329 | 5448 |
signal(SIGVTALRM, __spyInterrupt); |
13 | 5449 |
# else |
329 | 5450 |
signal(SIGALRM, __spyInterrupt); |
13 | 5451 |
# endif |
5452 |
||
348 | 5453 |
dt.it_interval.tv_sec = 0; |
5454 |
dt.it_interval.tv_usec = 0; |
|
5455 |
dt.it_value.tv_sec = 0; |
|
5456 |
dt.it_value.tv_usec = 1000; /* 1000 Hz */ |
|
5457 |
setitimer(ITIMER_VIRTUAL, &dt, 0); |
|
5458 |
||
13 | 5459 |
RETURN (true); |
1 | 5460 |
#endif |
5461 |
%} |
|
13 | 5462 |
. |
5463 |
^ false |
|
1 | 5464 |
! |
5465 |
||
5466 |
stopSpyTimer |
|
359 | 5467 |
"stop spy timing - disable spy timer. |
5468 |
OBSOLETE: the new messageTally runs as a high prio process, not using |
|
5469 |
spy interrupts." |
|
1 | 5470 |
|
5471 |
%{ /* NOCONTEXT */ |
|
5472 |
||
10 | 5473 |
#if defined(ITIMER_VIRTUAL) |
1 | 5474 |
struct itimerval dt; |
5475 |
||
5476 |
dt.it_interval.tv_sec = 0; |
|
5477 |
dt.it_interval.tv_usec = 0; |
|
5478 |
dt.it_value.tv_sec = 0; |
|
5479 |
dt.it_value.tv_usec = 0; |
|
5480 |
setitimer(ITIMER_VIRTUAL, &dt, 0); |
|
13 | 5481 |
RETURN (true); |
10 | 5482 |
#endif |
5483 |
%} |
|
13 | 5484 |
. |
5485 |
^ false |
|
10 | 5486 |
! |
5487 |
||
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5488 |
terminateProcess:processId |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5489 |
"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
|
5490 |
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
|
5491 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5492 |
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
|
5493 |
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
|
5494 |
OperatingSystem>>getStatusOfProcess:aProcessId." |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5495 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5496 |
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
|
5497 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5498 |
"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
|
5499 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5500 |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5501 |
terminateProcessGroup:processGroupId |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5502 |
"terminate a unix process group. |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5503 |
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
|
5504 |
|
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5505 |
WARNING: in order to avoid zombie processes (on unix), |
1487 | 5506 |
you may have to fetch the processes exitstatus with |
5507 |
OperatingSystem>>getStatusOfProcess:aProcessId." |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5508 |
|
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5509 |
self sendSignal:(self sigTERM) to:(processGroupId negated). |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5510 |
|
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5511 |
"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
|
5512 |
"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
|
5513 |
! |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5514 |
|
616 | 5515 |
unblockInterrupts |
5516 |
"enable interrupt processing - if any interrupts are pending, |
|
5517 |
these will be handled immediately. |
|
5518 |
When unblocking interrupts, take care of nested block/unblock |
|
5519 |
calls - you must only unblock after a blockcall if they where |
|
5520 |
really not blocked before. See OperatingSystemclass>>blockInterrupts." |
|
5521 |
%{ |
|
5522 |
__UNBLOCKINTERRUPTS(); |
|
1040
60e4c4bbbca2
return nil from unblockInterrupts (thats what the inlined code returns)
Claus Gittinger <cg@exept.de>
parents:
1034
diff
changeset
|
5523 |
RETURN (nil); |
616 | 5524 |
%} |
5525 |
! ! |
|
5526 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
5527 |
!OperatingSystem class methodsFor:'misc'! |
616 | 5528 |
|
5529 |
exit |
|
710 | 5530 |
"shutdown smalltalk immediately - this method does not return. |
5531 |
Return 'good'-status (0) to the parent unix process." |
|
616 | 5532 |
|
5533 |
%{ /* NOCONTEXT */ |
|
5534 |
__mainExit(0); |
|
5535 |
%} |
|
5536 |
"OperatingSystem exit - dont evaluate this" |
|
5537 |
! |
|
5538 |
||
5539 |
exit:exitCode |
|
5540 |
"shutdown smalltalk immediately - |
|
5541 |
returning an exit-code to the parent unix process." |
|
5542 |
||
5543 |
%{ /* NOCONTEXT */ |
|
5544 |
int code = 1; |
|
5545 |
||
5546 |
if (__isSmallInteger(exitCode)) { |
|
1135 | 5547 |
code = __intVal(exitCode); |
616 | 5548 |
} |
5549 |
__mainExit(code); |
|
5550 |
%} |
|
5551 |
"OperatingSystem exit:1 - dont evaluate this" |
|
5552 |
! |
|
5553 |
||
5554 |
exitWithCoreDump |
|
5555 |
"shutdown smalltalk immediately - dumping core. |
|
5556 |
This always returns 'bad'-status to the parent unix process. |
|
5557 |
Notice, that no cleanup is performed at all - you may have to |
|
5558 |
manually remove any tempfiles. |
|
5559 |
Use this only for debugging ST/X itself" |
|
5560 |
||
5561 |
%{ /* NOCONTEXT */ |
|
5562 |
abort(); |
|
5563 |
%} |
|
831 | 5564 |
" |
5565 |
OperatingSystem exitWithCoreDump - dont evaluate this |
|
5566 |
" |
|
616 | 5567 |
! |
5568 |
||
5569 |
slowFork:aBoolean |
|
1247 | 5570 |
"set/clear the `avoid-fork-if-possible-because-its-slow' flag. |
5571 |
Only used internally on SYSV3 systems" |
|
5572 |
||
616 | 5573 |
SlowFork := aBoolean |
1247 | 5574 |
|
5575 |
"Modified: 22.4.1996 / 13:13:09 / cg" |
|
616 | 5576 |
! ! |
5577 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
5578 |
!OperatingSystem class methodsFor:'os queries'! |
616 | 5579 |
|
5580 |
getCPUDefine |
|
831 | 5581 |
"return a string which was used to identify this CPU type when STX was |
616 | 5582 |
compiled, and which should be passed down when compiling methods. |
831 | 5583 |
For example, on linux, this may be '-Di386'; on a vax, this would be '-Dvax'. |
5584 |
This is normally not of interest to 'normal' users; however, it is passed |
|
5585 |
down to the c-compiler when methods are incrementally compiled to machine code." |
|
616 | 5586 |
|
5587 |
%{ /* NOCONTEXT */ |
|
831 | 5588 |
# ifndef CPU_DEFINE |
5589 |
# define CPU_DEFINE "-DunknownCPU" |
|
5590 |
# endif |
|
5591 |
||
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5592 |
RETURN ( __MKSTRING(CPU_DEFINE)); |
616 | 5593 |
%} |
5594 |
" |
|
5595 |
OperatingSystem getCPUDefine |
|
5596 |
" |
|
5597 |
! |
|
5598 |
||
5599 |
getCPUType |
|
5600 |
"return a string giving the type of machine we're running on. |
|
831 | 5601 |
Here, the machine for which ST/X was compiled is returned |
5602 |
(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
|
5603 |
This may normally not be of any interest to you ..." |
616 | 5604 |
|
5605 |
|cpu| |
|
5606 |
||
5607 |
%{ /* NOCONTEXT */ |
|
5608 |
||
5609 |
# ifdef vax |
|
5610 |
# define CPU_STRING "vax" |
|
5611 |
# endif |
|
5612 |
# ifdef mips |
|
5613 |
# define CPU_STRING "mips" |
|
5614 |
# endif |
|
5615 |
# ifdef i386 |
|
5616 |
# define CPU_STRING "i386" |
|
5617 |
# endif |
|
5618 |
# ifdef ns32k |
|
5619 |
# define CPU_STRING "ns32k" |
|
5620 |
# endif |
|
5621 |
# ifdef mc68k |
|
5622 |
# define CPU_STRING "mc68k" |
|
5623 |
# endif |
|
5624 |
# ifdef mc88k |
|
5625 |
# define CPU_STRING "mc88k" |
|
5626 |
# endif |
|
5627 |
# ifdef sparc |
|
5628 |
# define CPU_STRING "sparc" |
|
5629 |
# endif |
|
5630 |
# ifdef hppa |
|
5631 |
# define CPU_STRING "hppa" |
|
5632 |
# endif |
|
5633 |
# ifdef rs6000 |
|
5634 |
# define CPU_STRING "rs6000" |
|
5635 |
# endif |
|
831 | 5636 |
# ifdef powerPC |
5637 |
# define CPU_STRING "powerPC" |
|
5638 |
# endif |
|
616 | 5639 |
# ifdef alpha |
5640 |
# define CPU_STRING "alpha" |
|
5641 |
# endif |
|
5642 |
# ifdef transputer |
|
5643 |
# define CPU_STRING "transputer" |
|
5644 |
# endif |
|
5645 |
# ifdef ibm370 |
|
5646 |
# define CPU_STRING "ibm370" |
|
5647 |
# endif |
|
5648 |
||
5649 |
# ifndef CPU_STRING |
|
5650 |
# define CPU_STRING "unknown" |
|
5651 |
# endif |
|
5652 |
||
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5653 |
cpu = __MKSTRING(CPU_STRING); |
616 | 5654 |
# undef CPU_STRING |
831 | 5655 |
%}. |
616 | 5656 |
^ cpu |
5657 |
||
5658 |
" |
|
5659 |
OperatingSystem getCPUType |
|
5660 |
" |
|
5661 |
||
5662 |
"examples: are we running on a ss-10/solaris ?" |
|
5663 |
" |
|
5664 |
(OperatingSystem getCPUType = 'sparc') |
|
5665 |
and:[OperatingSystem getOSType = 'solaris'] |
|
5666 |
" |
|
5667 |
||
5668 |
"or on a pc/solaris ?" |
|
5669 |
" |
|
5670 |
(OperatingSystem getCPUType = 'i386') |
|
5671 |
and:[OperatingSystem getOSType = 'solaris'] |
|
5672 |
" |
|
5673 |
! |
|
5674 |
||
5675 |
getCommandOutputFrom:aCommand |
|
5676 |
"execute a simple command (such as hostname) and |
|
5677 |
return the commands output as a string" |
|
5678 |
||
5679 |
|p result| |
|
5680 |
||
5681 |
ForkFailed ifFalse:[ |
|
5682 |
PipeStream openErrorSignal handle:[:ex | |
|
5683 |
ForkFailed := true. |
|
5684 |
'OS: cannot fork/popen' errorPrintNL. |
|
5685 |
ex return. |
|
5686 |
] do:[ |
|
5687 |
p := PipeStream readingFrom:aCommand. |
|
5688 |
p notNil ifTrue:[ |
|
5689 |
result := p nextLine. |
|
5690 |
p close |
|
5691 |
] |
|
5692 |
] |
|
5693 |
]. |
|
5694 |
^ result |
|
5695 |
! |
|
5696 |
||
5697 |
getDomainName |
|
5698 |
"return the domain this host is in. |
|
5699 |
Notice: |
|
1487 | 5700 |
not all systems support this; on some, 'unknown' is returned." |
616 | 5701 |
|
5702 |
|name| |
|
5703 |
||
5704 |
DomainName notNil ifTrue:[ |
|
1487 | 5705 |
^ DomainName |
616 | 5706 |
]. |
5707 |
||
5708 |
%{ /* STACK: 2048 */ |
|
5709 |
#if defined(HAS_GETDOMAINNAME) |
|
5710 |
char buffer[128]; |
|
5711 |
||
5712 |
if (getdomainname(buffer, sizeof(buffer)) == 0) { |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5713 |
name = __MKSTRING(buffer); |
616 | 5714 |
} |
5715 |
#else |
|
5716 |
# if defined(HAS_UNAME) && defined(HAS_UTS_DOMAINNAME) |
|
5717 |
struct utsname ubuff; |
|
5718 |
||
5719 |
if (uname(&ubuff) >= 0) { |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5720 |
name = __MKSTRING(ubuff.domainname); |
1433 | 5721 |
} |
5722 |
# else |
|
5723 |
# if defined(HAS_SYSINFO) && defined(SI_SRPC_DOMAIN) |
|
5724 |
char buffer[256]; |
|
5725 |
int ret; |
|
5726 |
||
5727 |
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
|
5728 |
name = __MKSTRING(buffer); |
1433 | 5729 |
} |
5730 |
# endif |
|
616 | 5731 |
# endif |
5732 |
#endif |
|
5733 |
%}. |
|
5734 |
name isNil ifTrue:[ |
|
1487 | 5735 |
name := self getEnvironment:'DOMAIN'. |
5736 |
name isNil ifTrue:[ |
|
5737 |
name := self getCommandOutputFrom:'domainname' |
|
5738 |
] |
|
616 | 5739 |
]. |
5740 |
name isNil ifTrue:[ |
|
1487 | 5741 |
'OS: cannot find out domainname' errorPrintNL. |
5742 |
name := 'unknown'. |
|
616 | 5743 |
]. |
5744 |
DomainName := name. |
|
5745 |
^ name |
|
5746 |
||
5747 |
" |
|
5748 |
OperatingSystem getDomainName |
|
5749 |
" |
|
1433 | 5750 |
|
5751 |
"Modified: 26.4.1996 / 10:04:54 / stefan" |
|
616 | 5752 |
! |
5753 |
||
5754 |
getEnvironment:aStringOrSymbol |
|
5755 |
"get an environment string" |
|
10 | 5756 |
|
5757 |
%{ /* NOCONTEXT */ |
|
5758 |
||
616 | 5759 |
char *env; |
5760 |
||
5761 |
if (__isString(aStringOrSymbol) || __isSymbol(aStringOrSymbol)) { |
|
1632 | 5762 |
#ifdef WIN32 |
5763 |
char buff[512]; |
|
5764 |
||
5765 |
env = NULL; |
|
5766 |
if (GetEnvironmentVariable(__stringVal(aStringOrSymbol), |
|
5767 |
buff, |
|
5768 |
sizeof(buff)-1)) { |
|
5769 |
env = buff; |
|
5770 |
} |
|
5771 |
#else |
|
1135 | 5772 |
env = (char *)getenv(__stringVal(aStringOrSymbol)); |
1632 | 5773 |
#endif |
616 | 5774 |
if (env) { |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5775 |
RETURN ( __MKSTRING(env) ); |
616 | 5776 |
} |
5777 |
} |
|
5778 |
%} |
|
5779 |
. |
|
5780 |
^ nil |
|
5781 |
||
5782 |
" |
|
5783 |
OperatingSystem getEnvironment:'LANG' |
|
5784 |
OperatingSystem getEnvironment:'LOGIN' |
|
5785 |
OperatingSystem getEnvironment:'HOME' |
|
5786 |
OperatingSystem getEnvironment:'NNTPSERVER' |
|
5787 |
OperatingSystem getEnvironment:'MAIL' |
|
5788 |
OperatingSystem getEnvironment:'PATH' |
|
5789 |
" |
|
5790 |
! |
|
5791 |
||
5792 |
getHostName |
|
5793 |
"return the hostname we are running on - if there is |
|
5794 |
a HOST environment variable, we are much faster here ... |
|
5795 |
Notice: |
|
5796 |
not all systems support this; on some, 'unknown' is returned." |
|
5797 |
||
5798 |
|name| |
|
5799 |
||
5800 |
HostName notNil ifTrue:[ |
|
5801 |
^ HostName |
|
5802 |
]. |
|
5803 |
||
5804 |
%{ /* STACK: 2048 */ |
|
5805 |
#if defined(HAS_GETHOSTNAME) |
|
5806 |
char buffer[128]; |
|
5807 |
||
5808 |
if (gethostname(buffer, sizeof(buffer)) == 0) { |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5809 |
name = __MKSTRING(buffer); |
616 | 5810 |
} |
5811 |
#else |
|
5812 |
# if defined(HAS_UNAME) |
|
5813 |
struct utsname ubuff; |
|
5814 |
||
5815 |
if (uname(&ubuff) >= 0) { |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5816 |
name = __MKSTRING(ubuff.nodename); |
616 | 5817 |
} |
831 | 5818 |
# else |
1702 | 5819 |
# if defined(HAS_SYSINFO) && defined(SI_HOSTNAME) |
5820 |
char buffer[256]; |
|
5821 |
int ret; |
|
5822 |
||
5823 |
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
|
5824 |
name = __MKSTRING(buffer); |
1702 | 5825 |
} |
5826 |
# else |
|
5827 |
# ifdef WIN32 |
|
831 | 5828 |
char buffer[128]; |
5829 |
int buffSize = sizeof(buffer); |
|
5830 |
||
5831 |
if (GetComputerName(buffer, &buffSize) == TRUE) { |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5832 |
name = __MKSTRING(buffer); |
831 | 5833 |
} |
1702 | 5834 |
# endif |
831 | 5835 |
# endif |
1 | 5836 |
# endif |
616 | 5837 |
#endif |
5838 |
%}. |
|
5839 |
name isNil ifTrue:[ |
|
5840 |
name := self getEnvironment:'HOST'. |
|
5841 |
name isNil ifTrue:[ |
|
5842 |
name := self getCommandOutputFrom:'hostname' |
|
5843 |
] |
|
5844 |
]. |
|
5845 |
name isNil ifTrue:[ |
|
5846 |
'OS: cannot find out hostname' errorPrintNL. |
|
5847 |
name := 'unknown'. |
|
5848 |
]. |
|
5849 |
HostName := name. |
|
5850 |
^ name |
|
5851 |
||
5852 |
" |
|
5853 |
OperatingSystem getHostName |
|
5854 |
" |
|
5855 |
! |
|
5856 |
||
1034 | 5857 |
getLocaleInfo |
5858 |
"return a dictionary filled with values from the locale information; |
|
5859 |
Not all fields may be present, depending on the OS's setup and capabilities. |
|
5860 |
Possible fields are: |
|
5861 |
decimalPoint <String> |
|
5862 |
||
5863 |
thousandsSep <String> |
|
5864 |
||
5865 |
internationalCurrencySymbol <String> |
|
5866 |
||
5867 |
currencySymbol <String> |
|
5868 |
||
5869 |
monetaryDecimalPoint <String> |
|
5870 |
||
5871 |
monetaryThousandsSeparator <String> |
|
5872 |
||
5873 |
positiveSign <String> |
|
5874 |
||
5875 |
negativeSign <String> |
|
5876 |
||
5877 |
internationalFractionalDigits <Integer> |
|
5878 |
||
5879 |
fractionalDigits <Integer> |
|
5880 |
||
5881 |
positiveSignPrecedesCurrencySymbol <Boolean> |
|
5882 |
||
5883 |
negativeSignPrecedesCurrencySymbol <Boolean> |
|
5884 |
||
5885 |
positiveSignSeparatedBySpaceFromCurrencySymbol <Boolean> |
|
5886 |
||
5887 |
negativeSignSeparatedBySpaceFromCurrencySymbol <Boolean> |
|
5888 |
||
5889 |
positiveSignPosition <Symbol> |
|
5890 |
one of: #parenthesesAround, |
|
5891 |
#signPrecedes, |
|
5892 |
#signSuceeds, |
|
5893 |
#signPrecedesCurrencySymbol, |
|
5894 |
#signSuceedsCurrencySymbol |
|
5895 |
||
5896 |
negativeSignPosition <like above> |
|
5897 |
||
5898 |
it is up to the application to deal with undefined values. |
|
5899 |
||
5900 |
Notice, that (for now), the system does not use this information; |
|
5901 |
it should be used by applications as required. |
|
5902 |
" |
|
5903 |
||
5904 |
|info val| |
|
5905 |
||
5906 |
LocaleInfo notNil ifTrue:[ |
|
5907 |
"/ return the internal info; useful on systems which do not |
|
5908 |
"/ support this. |
|
5909 |
^ LocaleInfo |
|
5910 |
]. |
|
5911 |
||
5912 |
info := IdentityDictionary new. |
|
5913 |
%{ |
|
5914 |
char *decimalPoint; /* something like "." (US) or "," (german) */ |
|
5915 |
char *thousandsSep; /* something like "," (US) or "." (german) */ |
|
5916 |
char *intCurrencySymbol; /* international currency symbol; something like "USD " "DM " */ |
|
5917 |
char *currencySymbol; /* local currency symbol; something like "USD " "DM " */ |
|
5918 |
char *monDecimalPoint; /* money: decimal point */ |
|
5919 |
char *monThousandsSep; /* money: thousands sep */ |
|
5920 |
char *positiveSign; |
|
5921 |
char *negativeSign; |
|
5922 |
int intFractDigits; /* money: international digits after decPoint */ |
|
5923 |
int fractDigits; /* money: local digits after decPoint */ |
|
5924 |
int csPosPrecedes; /* money: 1 if currency symbol precedes a positive value; 0 if it sceeds */ |
|
5925 |
int csNegPrecedes; /* money: 1 if currency symbol precedes a negative value; 0 if it sceeds */ |
|
5926 |
int csPosSepBySpace; /* money: 1 if currency symbol should be separated by a space from a positive value; 0 if no space */ |
|
5927 |
int csNegSepBySpace; /* money: 1 if currency symbol should be separated by a space from a negative value; 0 if no space */ |
|
5928 |
int csPosSignPosition; /* money: 0: ()'s around the value & currency symbol */ |
|
5929 |
int csNegSignPosition; /* 1: sign precedes the value & currency symbol */ |
|
5930 |
/* 2: sign succeeds the value & currency symbol */ |
|
5931 |
/* 3: sign immediately precedes the currency symbol */ |
|
5932 |
/* 4: sign immediately suceeds the currency symbol */ |
|
5933 |
||
5934 |
#if defined(HAS_LOCALECONV) |
|
5935 |
struct lconv *conf; |
|
5936 |
||
5937 |
conf = localeconv(); |
|
5938 |
if (conf) { |
|
5939 |
decimalPoint = conf->decimal_point; |
|
5940 |
thousandsSep = conf->thousands_sep; |
|
5941 |
intCurrencySymbol = conf->int_curr_symbol; |
|
5942 |
currencySymbol = conf->currency_symbol; |
|
5943 |
monDecimalPoint = conf->mon_decimal_point; |
|
5944 |
monThousandsSep = conf->mon_thousands_sep; |
|
5945 |
positiveSign = conf->positive_sign; |
|
5946 |
negativeSign = conf->negative_sign; |
|
5947 |
intFractDigits = conf->int_frac_digits; |
|
5948 |
fractDigits = conf->frac_digits; |
|
5949 |
csPosPrecedes = conf->p_cs_precedes; |
|
5950 |
csNegPrecedes = conf->n_cs_precedes; |
|
5951 |
csPosSepBySpace = conf->p_sep_by_space; |
|
5952 |
csNegSepBySpace = conf->n_sep_by_space; |
|
5953 |
csPosSignPosition = conf->p_sign_posn; |
|
5954 |
csNegSignPosition = conf->n_sign_posn; |
|
5955 |
} |
|
5956 |
#else |
|
5957 |
decimalPoint = (char *)0; |
|
5958 |
thousandsSep = (char *)0; |
|
5959 |
intCurrencySymbol = (char *)0; |
|
5960 |
currencySymbol = (char *)0; |
|
5961 |
monDecimalPoint = (char *)0; |
|
5962 |
monThousandsSep = (char *)0; |
|
5963 |
positiveSign = (char *)0; |
|
5964 |
negativeSign =(char *)0; |
|
5965 |
intFractDigits = -1; |
|
5966 |
fractDigits = -1; |
|
5967 |
csPosPrecedes = -1; |
|
5968 |
csNegPrecedes = -1; |
|
5969 |
csPosSepBySpace = -1; |
|
5970 |
csNegSepBySpace = -1; |
|
5971 |
csPosSignPosition = -1; |
|
5972 |
csNegSignPosition = -1; |
|
5973 |
#endif |
|
5974 |
if (decimalPoint) { |
|
5975 |
val = __MKSTRING(decimalPoint); |
|
5976 |
__AT_PUT_(info, @symbol(decimalPoint), val); |
|
5977 |
} |
|
5978 |
if (thousandsSep) { |
|
5979 |
val = __MKSTRING(thousandsSep); |
|
5980 |
__AT_PUT_(info, @symbol(thousandsSeparator), val); |
|
5981 |
} |
|
5982 |
if (intCurrencySymbol) { |
|
5983 |
val = __MKSTRING(intCurrencySymbol); |
|
5984 |
__AT_PUT_(info, @symbol(internationCurrencySymbol), val); |
|
5985 |
} |
|
5986 |
if (currencySymbol) { |
|
5987 |
val = __MKSTRING(currencySymbol); |
|
5988 |
__AT_PUT_(info, @symbol(currencySymbol), val); |
|
5989 |
} |
|
5990 |
if (monDecimalPoint) { |
|
5991 |
val = __MKSTRING(monDecimalPoint); |
|
5992 |
__AT_PUT_(info, @symbol(monetaryDecimalPoint), val); |
|
5993 |
} |
|
5994 |
if (monThousandsSep) { |
|
5995 |
val = __MKSTRING(monThousandsSep); |
|
5996 |
__AT_PUT_(info, @symbol(monetaryThousandsSeparator), val); |
|
5997 |
} |
|
5998 |
if (positiveSign) { |
|
5999 |
val = __MKSTRING(positiveSign); |
|
6000 |
__AT_PUT_(info, @symbol(positiveSign), val); |
|
6001 |
} |
|
6002 |
if (negativeSign) { |
|
6003 |
val = __MKSTRING(negativeSign); |
|
6004 |
__AT_PUT_(info, @symbol(negativeSign), val); |
|
6005 |
} |
|
6006 |
if (intFractDigits >= 0) { |
|
6007 |
__AT_PUT_(info, @symbol(internationalFractionalDigits), __MKSMALLINT(intFractDigits)); |
|
6008 |
} |
|
6009 |
if (fractDigits >= 0) { |
|
6010 |
__AT_PUT_(info, @symbol(fractionalDigits), __MKSMALLINT(fractDigits)); |
|
6011 |
} |
|
6012 |
if (csPosPrecedes >= 0) { |
|
6013 |
if (csPosPrecedes == 0) { |
|
6014 |
val = false; |
|
6015 |
} else { |
|
6016 |
val = true; |
|
6017 |
} |
|
6018 |
__AT_PUT_(info, @symbol(positiveSignPrecedesCurrencySymbol), val ); |
|
6019 |
} |
|
6020 |
if (csNegPrecedes >= 0) { |
|
6021 |
if (csNegPrecedes == 0) { |
|
6022 |
val = false; |
|
6023 |
} else { |
|
6024 |
val = true; |
|
6025 |
} |
|
6026 |
__AT_PUT_(info, @symbol(negativeSignPrecedesCurrencySymbol), val ); |
|
6027 |
} |
|
6028 |
if (csPosSepBySpace >= 0) { |
|
6029 |
if (csPosSepBySpace == 0) { |
|
6030 |
val = false; |
|
6031 |
} else { |
|
6032 |
val = true; |
|
6033 |
} |
|
6034 |
__AT_PUT_(info, @symbol(positiveSignSeparatedBySpaceFromCurrencySymbol), val); |
|
6035 |
} |
|
6036 |
if (csNegSepBySpace >= 0) { |
|
6037 |
if (csNegSepBySpace == 0) { |
|
6038 |
val = false; |
|
6039 |
} else { |
|
6040 |
val = true; |
|
6041 |
} |
|
6042 |
__AT_PUT_(info, @symbol(negativeSignSeparatedBySpaceFromCurrencySymbol), val); |
|
6043 |
} |
|
6044 |
switch (csPosSignPosition) { |
|
6045 |
case 0: |
|
6046 |
val = @symbol(parenthesesAround); |
|
6047 |
break; |
|
6048 |
||
6049 |
case 1: |
|
6050 |
val = @symbol(signPrecedes); |
|
6051 |
break; |
|
6052 |
||
6053 |
case 2: |
|
6054 |
val = @symbol(signSuceeds); |
|
6055 |
break; |
|
6056 |
||
6057 |
case 3: |
|
6058 |
val = @symbol(signPrecedesCurrencySymbol); |
|
6059 |
break; |
|
6060 |
||
6061 |
case 4: |
|
6062 |
val = @symbol(signSuceedsCurrencySymbol); |
|
6063 |
break; |
|
6064 |
||
6065 |
default: |
|
6066 |
val = nil; |
|
6067 |
} |
|
6068 |
if (val != nil) { |
|
6069 |
__AT_PUT_(info, @symbol(positiveSignPosition), val); |
|
6070 |
} |
|
6071 |
||
6072 |
switch (csNegSignPosition) { |
|
6073 |
case 0: |
|
6074 |
val = @symbol(parenthesesAround); |
|
6075 |
break; |
|
6076 |
||
6077 |
case 1: |
|
6078 |
val = @symbol(signPrecedes); |
|
6079 |
break; |
|
6080 |
||
6081 |
case 2: |
|
6082 |
val = @symbol(signSuceeds); |
|
6083 |
break; |
|
6084 |
||
6085 |
case 3: |
|
6086 |
val = @symbol(signPrecedesCurrencySymbol); |
|
6087 |
break; |
|
6088 |
||
6089 |
case 4: |
|
6090 |
val = @symbol(signSuceedsCurrencySymbol); |
|
6091 |
break; |
|
6092 |
||
6093 |
default: |
|
6094 |
val = nil; |
|
6095 |
} |
|
6096 |
if (val != nil) { |
|
6097 |
__AT_PUT_(info, @symbol(negativeSignPosition), val); |
|
6098 |
} |
|
6099 |
%}. |
|
6100 |
^ info |
|
6101 |
||
6102 |
" |
|
6103 |
OperatingSystem getLocaleInfo |
|
6104 |
" |
|
6105 |
||
6106 |
"Created: 23.12.1995 / 14:19:20 / cg" |
|
6107 |
! |
|
6108 |
||
616 | 6109 |
getOSDefine |
6110 |
"return a string which was used to identify this machine when stx was |
|
6111 |
compiled, and which should be passed down when compiling methods. |
|
6112 |
For example, on linux, this is '-DLINUX'." |
|
6113 |
||
6114 |
%{ /* NOCONTEXT */ |
|
831 | 6115 |
#ifdef WIN32 |
6116 |
# ifndef OS_DEFINE |
|
6117 |
# define OS_DEFINE "-DWIN32" |
|
6118 |
# endif |
|
6119 |
#endif |
|
6120 |
||
616 | 6121 |
#ifndef OS_DEFINE |
6122 |
# define OS_DEFINE "-DunknownOS" |
|
6123 |
#endif |
|
831 | 6124 |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6125 |
RETURN ( __MKSTRING(OS_DEFINE)); |
1987 | 6126 |
|
6127 |
#undef OS_DEFINE |
|
616 | 6128 |
%} |
6129 |
" |
|
6130 |
OperatingSystem getOSDefine |
|
6131 |
" |
|
6132 |
! |
|
6133 |
||
6134 |
getOSType |
|
6135 |
"return a string giving the type of OS we're running on. |
|
6136 |
This can be used to adapt programs to certain environment |
|
6137 |
differences (for example: mail-lock strategy ...)" |
|
6138 |
||
6139 |
|os| |
|
6140 |
||
6141 |
%{ /* NOCONTEXT */ |
|
6142 |
||
6143 |
# ifdef MSDOS |
|
6144 |
# define OS_STRING "msdos" |
|
6145 |
# endif |
|
6146 |
||
831 | 6147 |
# ifdef WIN32 |
1987 | 6148 |
# define OS_STRING "win32" |
831 | 6149 |
|
6150 |
# endif |
|
6151 |
||
616 | 6152 |
# ifdef MSWINDOWS |
6153 |
# define OS_STRING "mswindows" |
|
6154 |
# endif |
|
6155 |
||
6156 |
# ifdef NT |
|
6157 |
# define OS_STRING "nt" |
|
6158 |
# endif |
|
6159 |
||
6160 |
# ifdef VMS |
|
6161 |
# define OS_STRING "vms" |
|
6162 |
# endif |
|
6163 |
||
6164 |
# ifdef MVS |
|
6165 |
# define OS_STRING "mvs" |
|
6166 |
# endif |
|
6167 |
||
6168 |
# ifdef OS2 |
|
6169 |
# define OS_STRING "os2" |
|
6170 |
# endif |
|
6171 |
||
6172 |
# ifdef sinix |
|
6173 |
# define OS_STRING "sinix" |
|
6174 |
# endif |
|
6175 |
||
6176 |
# ifdef ultrix |
|
6177 |
# define OS_STRING "ultrix" |
|
6178 |
# endif |
|
6179 |
||
6180 |
# ifdef sco |
|
6181 |
# define OS_STRING "sco" |
|
6182 |
# endif |
|
6183 |
||
6184 |
# ifdef hpux |
|
6185 |
# define OS_STRING "hpux" |
|
6186 |
# endif |
|
6187 |
||
6188 |
# ifdef LINUX |
|
6189 |
# define OS_STRING "linux" |
|
6190 |
# endif |
|
6191 |
||
6192 |
# ifdef sunos |
|
6193 |
# define OS_STRING "sunos" |
|
6194 |
# endif |
|
6195 |
||
6196 |
# ifdef solaris |
|
6197 |
# define OS_STRING "solaris" |
|
6198 |
# endif |
|
6199 |
||
6200 |
# ifdef IRIS |
|
6201 |
# define OS_STRING "irix" |
|
6202 |
# endif |
|
6203 |
||
6204 |
# ifdef aix |
|
6205 |
# define OS_STRING "aix" |
|
6206 |
# endif |
|
6207 |
||
6208 |
# ifdef realIX |
|
6209 |
# define OS_STRING "realIX" |
|
6210 |
# endif |
|
6211 |
||
6212 |
/* |
|
6213 |
* no concrete info; become somewhat vague ... |
|
6214 |
*/ |
|
6215 |
# ifndef OS_STRING |
|
6216 |
# ifdef MACH |
|
6217 |
# define OS_STRING "mach" |
|
6218 |
# endif |
|
6219 |
# endif |
|
6220 |
||
6221 |
# ifndef OS_STRING |
|
6222 |
# ifdef BSD |
|
6223 |
# define OS_STRING "bsd" |
|
6224 |
# endif |
|
6225 |
||
6226 |
# ifdef SYSV |
|
6227 |
# ifdef SYSV3 |
|
6228 |
# define OS_STRING "sys5_3" |
|
6229 |
# else |
|
6230 |
# ifdef SYSV4 |
|
6231 |
# define OS_STRING "sys5_4" |
|
6232 |
# else |
|
6233 |
# define OS_STRING "sys5" |
|
6234 |
# endif |
|
6235 |
# endif |
|
6236 |
# endif |
|
6237 |
# endif |
|
6238 |
||
6239 |
/* |
|
6240 |
* become very vague ... |
|
6241 |
*/ |
|
6242 |
# ifndef OS_STRING |
|
6243 |
# ifdef POSIX |
|
6244 |
# define OS_STRING "posix" |
|
6245 |
# endif |
|
6246 |
# endif |
|
6247 |
# ifndef OS_STRING |
|
6248 |
# ifdef UNIX |
|
6249 |
# define OS_STRING "unix" |
|
6250 |
# endif |
|
6251 |
# endif |
|
6252 |
||
6253 |
# ifndef OS_STRING |
|
6254 |
# define OS_STRING "unknown" |
|
6255 |
# endif |
|
6256 |
||
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6257 |
os = __MKSTRING(OS_STRING); |
1987 | 6258 |
|
616 | 6259 |
# undef OS_STRING |
831 | 6260 |
%}. |
616 | 6261 |
^ os |
6262 |
||
6263 |
"OperatingSystem getOSType" |
|
6264 |
! |
|
6265 |
||
6266 |
getProcessId |
|
6267 |
"return the (unix-)processId" |
|
6268 |
||
6269 |
%{ /* NOCONTEXT */ |
|
6270 |
||
6271 |
int pid = 0; |
|
6272 |
#ifdef UNIX_LIKE |
|
6273 |
pid = getpid(); |
|
1632 | 6274 |
#else |
6275 |
# ifdef WIN32 |
|
6276 |
pid = GetCurrentProcessId() & 0x3FFFFFFF; |
|
6277 |
# endif |
|
616 | 6278 |
#endif |
1135 | 6279 |
RETURN ( __MKSMALLINT(pid) ); |
616 | 6280 |
%} |
6281 |
" |
|
6282 |
OperatingSystem getProcessId |
|
6283 |
" |
|
6284 |
! |
|
6285 |
||
6286 |
getSystemID |
|
6287 |
"if supported by the OS, return the systemID; |
|
6288 |
a unique per machine identification. |
|
6289 |
WARNING: |
|
6290 |
not all systems support this; on some, 'unknown' is returned." |
|
6291 |
||
6292 |
%{ /* NO_CONTEXT */ |
|
6293 |
#if defined(IRIX5) && !defined(HAS_GETHOSTID) |
|
6294 |
char idBuffer[MAXSYSIDSIZE]; |
|
6295 |
int retVal; |
|
6296 |
OBJ arr; |
|
6297 |
||
6298 |
if ((retVal = syssgi(SGI_SYSID, idBuffer)) == 0) { |
|
6299 |
arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(MAXSYSIDSIZE); |
|
6300 |
bcopy(idBuffer, __ByteArrayInstPtr(arr)->ba_element, MAXSYSIDSIZE); |
|
6301 |
RETURN (arr); |
|
6302 |
} |
|
6303 |
#endif |
|
6304 |
#if defined(HAS_GETHOSTID) |
|
6305 |
int runningId; |
|
6306 |
OBJ arr; |
|
6307 |
||
6308 |
runningId = gethostid(); |
|
6309 |
arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(4); |
|
6310 |
*(int *)(__ByteArrayInstPtr(arr)->ba_element) = runningId; |
|
6311 |
RETURN (arr); |
|
6312 |
#endif |
|
6313 |
%}. |
|
6314 |
^ 'unknown' |
|
6315 |
||
6316 |
" |
|
6317 |
OperatingSystem getSystemID |
|
6318 |
" |
|
6319 |
! |
|
6320 |
||
6321 |
getSystemInfo |
|
831 | 6322 |
"return info on the system weare running on. |
6323 |
If the system supports the uname system call, that info is returned; |
|
616 | 6324 |
otherwise, some simulated info is returned. |
831 | 6325 |
|
616 | 6326 |
WARNING: |
831 | 6327 |
Do not depend on the amount and contents of the returned information, some |
6328 |
systems may return more/less than others. Also, the contents depends on the |
|
6329 |
OS, for example, linux returns 'ix86', while WIN32 returns 'x86'. |
|
6330 |
||
6331 |
This method is mainly provided to augment error reports with some system |
|
6332 |
information. |
|
6333 |
(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
|
6334 |
may be based upon this info) |
616 | 6335 |
|
6336 |
The returned info may (or may not) contain: |
|
831 | 6337 |
#system -> some operating system identification (irix, Linux, nt, win32s ...) |
6338 |
#version -> OS version (some os version identification) |
|
6339 |
#release -> OS release (3.5, 1.2.1 ...) |
|
6340 |
#node -> some host identification (hostname) |
|
6341 |
#domain -> domain name (hosts domain) |
|
6342 |
#machine -> type of machine (i586, mips ...) |
|
616 | 6343 |
" |
6344 |
||
6345 |
|sys node rel ver mach dom mtyp brel info| |
|
6346 |
||
1060
119d45f975e1
increased getSystemInfos stack - just to make certain
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
6347 |
%{ /* STACK: 4096 */ |
616 | 6348 |
#if defined(HAS_UNAME) |
6349 |
struct utsname ubuff; |
|
6350 |
||
6351 |
if (uname(&ubuff) >= 0) { |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6352 |
sys = __MKSTRING(ubuff.sysname); |
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6353 |
node = __MKSTRING(ubuff.nodename); |
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6354 |
rel = __MKSTRING(ubuff.release); |
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6355 |
ver = __MKSTRING(ubuff.version); |
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6356 |
mach = __MKSTRING(ubuff.machine); |
616 | 6357 |
# ifdef HAS_UTS_DOMAINNAME |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6358 |
dom = __MKSTRING(ubuff.domainname); |
1675 | 6359 |
# else |
6360 |
# if defined(HAS_GETDOMAINNAME) |
|
6361 |
{ |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
6362 |
char buffer[128]; |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
6363 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
6364 |
if (getdomainname(buffer, sizeof(buffer)) == 0) { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
6365 |
dom = __MKSTRING(buffer); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
6366 |
} |
1675 | 6367 |
} |
6368 |
# endif |
|
616 | 6369 |
# endif |
6370 |
} |
|
831 | 6371 |
#else /* no uname */ |
6372 |
# ifdef WIN32 |
|
6373 |
||
6374 |
char vsnBuffer[32]; |
|
6375 |
char *s; |
|
6376 |
int winVer; |
|
6377 |
DWORD vsn; |
|
6378 |
SYSTEM_INFO sysInfo; |
|
6379 |
||
6380 |
vsn = GetVersion(); |
|
6381 |
||
6382 |
if (HIWORD(vsn) & 0x8000) { |
|
6383 |
s = "win32s"; |
|
6384 |
} else { |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6385 |
s = "nt"; |
831 | 6386 |
} |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6387 |
sys = __MKSTRING(s); |
831 | 6388 |
winVer = LOWORD(vsn); |
6389 |
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
|
6390 |
rel = __MKSTRING(vsnBuffer); |
831 | 6391 |
|
6392 |
GetSystemInfo(&sysInfo); |
|
6393 |
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
|
6394 |
sprintf(vsnBuffer, "%d", sysInfo.dwProcessorType); |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6395 |
mach = __MKSTRING(vsnBuffer); |
831 | 6396 |
} |
6397 |
||
6398 |
# endif /* WIN32 */ |
|
6399 |
#endif /* no uname */ |
|
616 | 6400 |
%}. |
6401 |
sys isNil ifTrue:[ |
|
6402 |
sys := self getSystemType. |
|
6403 |
]. |
|
6404 |
node isNil ifTrue:[ |
|
6405 |
node := self getHostName |
|
6406 |
]. |
|
6407 |
dom isNil ifTrue:[ |
|
6408 |
dom := self getDomainName |
|
6409 |
]. |
|
831 | 6410 |
mach isNil ifTrue:[ |
6411 |
mach := self getCPUType |
|
6412 |
]. |
|
616 | 6413 |
|
6414 |
info := IdentityDictionary new. |
|
6415 |
info at:#system put:sys. |
|
6416 |
info at:#node put:node. |
|
6417 |
rel notNil ifTrue:[info at:#release put:rel]. |
|
6418 |
ver notNil ifTrue:[info at:#version put:ver]. |
|
6419 |
mach notNil ifTrue:[info at:#machine put:mach]. |
|
6420 |
dom notNil ifTrue:[info at:#domain put:dom]. |
|
6421 |
^ info |
|
6422 |
||
6423 |
" |
|
6424 |
OperatingSystem getSystemInfo |
|
6425 |
" |
|
6426 |
! |
|
6427 |
||
6428 |
getSystemType |
|
6429 |
"return a string giving the type of system we're running on. |
|
6430 |
This is almost the same as getOSType, but the returned string |
|
6431 |
is slightly different for some systems (i.e. iris vs. irix). |
|
6432 |
Dont depend on this - use getOSType. I dont really see a point |
|
831 | 6433 |
here ... |
6434 |
(except for slight differences between next/mach and other machs)" |
|
616 | 6435 |
|
6436 |
|sys| |
|
6437 |
||
6438 |
%{ |
|
6439 |
# ifdef NEXT |
|
6440 |
# define SYS_STRING "next" |
|
6441 |
# endif |
|
6442 |
||
6443 |
# ifdef IRIS |
|
6444 |
# define SYS_STRING "iris" |
|
6445 |
# endif |
|
6446 |
||
831 | 6447 |
# ifdef WIN32 |
6448 |
# define SYS_STRING "win32" |
|
6449 |
# endif |
|
6450 |
||
616 | 6451 |
# ifdef SYS_STRING |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6452 |
sys = __MKSTRING(SYS_STRING); |
616 | 6453 |
# undef SYS_STRING |
6454 |
# endif |
|
831 | 6455 |
%}. |
616 | 6456 |
sys isNil ifTrue:[ |
6457 |
^ self getOSType |
|
6458 |
]. |
|
6459 |
^ sys |
|
6460 |
||
6461 |
" |
|
6462 |
OperatingSystem getSystemType |
|
6463 |
" |
|
6464 |
! |
|
6465 |
||
6466 |
isBSDlike |
|
6467 |
"return true, if the OS we're running on is a 'real' unix." |
|
6468 |
||
6469 |
%{ /* NOCONTEXT */ |
|
6470 |
||
6471 |
#if defined(BSD) || defined(MACH) || defined(SYSV4) |
|
6472 |
RETURN ( true ); |
|
13 | 6473 |
#endif |
831 | 6474 |
%}. |
13 | 6475 |
^ false |
10 | 6476 |
! |
6477 |
||
616 | 6478 |
isMSDOSlike |
6479 |
"return true, if the OS we're running on is dos like |
|
6480 |
(in contrast to unix-like)." |
|
6481 |
||
6482 |
%{ /* NOCONTEXT */ |
|
6483 |
||
6484 |
#if defined(MSDOS_LIKE) |
|
6485 |
RETURN ( true ); |
|
6486 |
#endif |
|
831 | 6487 |
%}. |
616 | 6488 |
^ false |
6489 |
! |
|
6490 |
||
831 | 6491 |
isMSWINDOWSlike |
6492 |
"return true, if the OS we're running on is MS-Windows like." |
|
6493 |
||
6494 |
%{ /* NOCONTEXT */ |
|
6495 |
||
6496 |
#if defined(WIN32) |
|
6497 |
RETURN ( true ); |
|
6498 |
#endif |
|
6499 |
||
6500 |
%}. |
|
6501 |
^ false |
|
6502 |
! |
|
6503 |
||
6504 |
isOS2like |
|
6505 |
"return true, if the OS we're running on is OS2 like" |
|
6506 |
||
6507 |
%{ /* NOCONTEXT */ |
|
6508 |
||
6509 |
#if defined(OS2) |
|
6510 |
RETURN (true); |
|
6511 |
#endif |
|
6512 |
||
6513 |
%}. |
|
6514 |
^ false |
|
6515 |
! |
|
6516 |
||
1034 | 6517 |
isUNIXlike |
6518 |
"return true, if the OS we're running on is a unix like." |
|
6519 |
||
6520 |
%{ /* NOCONTEXT */ |
|
6521 |
||
6522 |
#if !defined(UNIX_LIKE) |
|
6523 |
RETURN ( false ); |
|
6524 |
#endif |
|
6525 |
%}. |
|
6526 |
^ true |
|
6527 |
! |
|
6528 |
||
616 | 6529 |
maxFileNameLength |
6530 |
"return the max number of characters in a filename. |
|
831 | 6531 |
CAVEAT: |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6532 |
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
|
6533 |
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
|
6534 |
We return a somewhat conservative number here." |
10 | 6535 |
|
6536 |
%{ /* NOCONTEXT */ |
|
616 | 6537 |
|
6538 |
/* |
|
6539 |
* XXX: newer systems provide a query function for this ... use it |
|
6540 |
*/ |
|
6541 |
# if defined(BSD) || defined(SYSV4) || defined(LONGFILENAMES) |
|
831 | 6542 |
RETURN ( __MKSMALLINT(255) ); |
616 | 6543 |
# endif |
6544 |
||
6545 |
# ifdef realIX |
|
831 | 6546 |
RETURN ( __MKSMALLINT(127) ); |
616 | 6547 |
# endif |
6548 |
||
6549 |
# ifdef SYSV |
|
831 | 6550 |
RETURN ( __MKSMALLINT(14) ); |
616 | 6551 |
# endif |
6552 |
||
6553 |
# ifdef MSDOS |
|
831 | 6554 |
RETURN ( __MKSMALLINT(9) ); |
616 | 6555 |
# endif |
6556 |
||
831 | 6557 |
# ifdef WIN32 |
616 | 6558 |
/* |
6559 |
* mhmh - depends on the filesystem type |
|
6560 |
*/ |
|
831 | 6561 |
RETURN ( __MKSMALLINT(9) ); |
616 | 6562 |
# endif |
6563 |
%}. |
|
6564 |
"unix default" |
|
831 | 6565 |
|
616 | 6566 |
^ 14 |
6567 |
! |
|
6568 |
||
1034 | 6569 |
setLocaleInfo:anInfoDictionary |
6570 |
"set the locale information; if set, this oerrides the OS's settings. |
|
6571 |
(internal in ST/X only - the OS's settings remain unaffected) |
|
6572 |
See description of fields in #getLocaleInfo. |
|
6573 |
||
6574 |
Notice, that (for now), the system does not use this information; |
|
6575 |
it should be used by applications as required." |
|
6576 |
||
6577 |
LocaleInfo := anInfoDictionary |
|
6578 |
||
6579 |
" |
|
6580 |
|d| |
|
6581 |
||
6582 |
d := IdentityDictionary new. |
|
6583 |
d at:#decimalPoint put:'.' . |
|
6584 |
d at:#thousandsSeparator put:',' . |
|
6585 |
d at:#currencySymbol put:'USD' . |
|
6586 |
d at:#monetaryDecimalPoint put:'.' . |
|
6587 |
d at:#monetaryThousandsSeparator put:'.' . |
|
6588 |
d at:#fractionalDigits put:2 . |
|
6589 |
d at:#positiveSign put:'+' . |
|
6590 |
d at:#negativeSign put:'-' . |
|
6591 |
d at:#positiveSignPrecedesCurrencySymbol put:true . |
|
6592 |
d at:#negativeSignPrecedesCurrencySymbol put:false . |
|
6593 |
OperatingSystem setLocaleInfo:d |
|
6594 |
" |
|
6595 |
! |
|
6596 |
||
616 | 6597 |
supportsIOInterrupts |
6598 |
"return true, if the OS supports IO availability interrupts |
|
6599 |
(i.e. SIGPOLL/SIGIO). |
|
6600 |
||
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6601 |
Currently, this mechanism does work for SYSV4 only ..." |
616 | 6602 |
|
6603 |
%{ /* NOCONTEXT */ |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
6604 |
#if defined(SYSV4) && defined(USE_SIGIO) && 0 |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6605 |
|
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6606 |
# if defined(SIGPOLL) || defined(SIGIO) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6607 |
# 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
|
6608 |
/* |
765
93bdb4f0e095
no, SIGIO does not work on SGI ...
Claus Gittinger <cg@exept.de>
parents:
764
diff
changeset
|
6609 |
* 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
|
6610 |
* (not even on SGI ...) |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6611 |
*/ |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6612 |
# if !defined(NEXT) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6613 |
RETURN (true); |
616 | 6614 |
# endif |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6615 |
# endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6616 |
# endif |
616 | 6617 |
|
10 | 6618 |
#endif |
831 | 6619 |
%}. |
13 | 6620 |
^ false |
123 | 6621 |
! |
6622 |
||
616 | 6623 |
supportsNonBlockingIO |
6624 |
"return true, if the OS supports nonblocking IO." |
|
6625 |
||
6626 |
%{ /* NOCONTEXT */ |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6627 |
#if defined(F_GETFL) && defined(F_SETFL) && defined(FNDELAY) |
616 | 6628 |
RETURN (true); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6629 |
#endif |
831 | 6630 |
%}. |
616 | 6631 |
^ false |
123 | 6632 |
! |
6633 |
||
616 | 6634 |
supportsSelect |
6635 |
"return true, if the OS supports selecting on multiple |
|
6636 |
filedescriptors via select." |
|
6637 |
||
6638 |
%{ /* NOCONTEXT */ |
|
831 | 6639 |
#if defined(WIN32) |
6640 |
RETURN (false); |
|
6641 |
#endif |
|
616 | 6642 |
#if defined(sco) |
6643 |
/* |
|
831 | 6644 |
* sco has a select, but its broken: always waiting 1 second |
616 | 6645 |
*/ |
6646 |
RETURN(false); |
|
6647 |
#endif |
|
6648 |
%} |
|
6649 |
. |
|
6650 |
^ true |
|
6651 |
! ! |
|
6652 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
6653 |
!OperatingSystem class methodsFor:'shared memory access'! |
616 | 6654 |
|
6655 |
shmAttach:id address:addr flags:flags |
|
1247 | 6656 |
"low level entry to shmat()-system call. |
6657 |
Not supported on all operatingSystems" |
|
6658 |
||
616 | 6659 |
%{ /* NOCONTEXT */ |
6660 |
#ifdef WANT_SHM |
|
6661 |
void *address, *shmaddr; |
|
6662 |
int shmflg, shmid; |
|
6663 |
||
6664 |
if (__isSmallInteger(addr) |
|
6665 |
&& __bothSmallInteger(flags, id)) { |
|
1487 | 6666 |
shmaddr = (void *) __intVal(addr); |
6667 |
shmflg = __intVal(flags); |
|
6668 |
shmid = __intVal(id); |
|
6669 |
||
6670 |
address = shmat(shmid, shmaddr, shmflg); |
|
6671 |
if (address != (void *)-1) { |
|
6672 |
RETURN (__MKEXTERNALBYTES(addr)); |
|
6673 |
} |
|
6674 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
|
6675 |
RETURN (nil); |
|
616 | 6676 |
} |
6677 |
#endif |
|
6678 |
%}. |
|
792 | 6679 |
^ self primitiveFailed |
1247 | 6680 |
|
6681 |
"Modified: 22.4.1996 / 13:15:12 / cg" |
|
370 | 6682 |
! |
6683 |
||
616 | 6684 |
shmDetach:addr |
1247 | 6685 |
"low level entry to shmdt()-system call. |
6686 |
Not supported on all operatingSystems" |
|
6687 |
||
616 | 6688 |
%{ /* NOCONTEXT */ |
6689 |
#ifdef WANT_SHM |
|
6690 |
void *shmaddr; |
|
6691 |
int rslt; |
|
6692 |
||
6693 |
if (__isSmallInteger(addr)) { |
|
1487 | 6694 |
shmaddr = (void *) __intVal(addr); |
6695 |
||
6696 |
rslt = shmdt(shmaddr); |
|
6697 |
if (rslt != -1) { |
|
6698 |
RETURN (true); |
|
6699 |
} |
|
6700 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
|
6701 |
RETURN (false); |
|
370 | 6702 |
} |
616 | 6703 |
#endif |
6704 |
%}. |
|
792 | 6705 |
^ self primitiveFailed |
1247 | 6706 |
|
6707 |
"Modified: 22.4.1996 / 13:15:03 / cg" |
|
616 | 6708 |
! |
6709 |
||
6710 |
shmGet:key size:size flags:flags |
|
1247 | 6711 |
"low level entry to shmget()-system call. |
6712 |
This is not for public use and not supported with all operatingSystems. |
|
616 | 6713 |
- use the provided wrapper class SharedExternalBytes instead." |
6714 |
||
6715 |
%{ /* NOCONTEXT */ |
|
6716 |
#ifdef WANT_SHM |
|
6717 |
if (__bothSmallInteger(key, size) |
|
6718 |
&& __isSmallInteger(flags)) { |
|
1487 | 6719 |
int rslt; |
6720 |
||
6721 |
rslt = shmget(__intVal(key), __intVal(size), __intVal(flags)); |
|
6722 |
if (rslt != -1) { |
|
6723 |
RETURN (__MKSMALLINT(rslt)); |
|
6724 |
} |
|
6725 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
|
6726 |
RETURN (nil); |
|
616 | 6727 |
} |
6728 |
#endif |
|
370 | 6729 |
%}. |
792 | 6730 |
^ self primitiveFailed |
1247 | 6731 |
|
6732 |
"Modified: 22.4.1996 / 13:14:46 / cg" |
|
1 | 6733 |
! ! |
6734 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
6735 |
!OperatingSystem class methodsFor:'time and date'! |
1 | 6736 |
|
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6737 |
computeDatePartsOf:osTime for:aBlock |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6738 |
"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
|
6739 |
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
|
6740 |
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
|
6741 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6742 |
|year month day osSeconds| |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6743 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6744 |
osSeconds := osTime // 1000. |
1 | 6745 |
%{ |
6746 |
struct tm *tmPtr; |
|
6747 |
long t; |
|
6748 |
||
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6749 |
t = __longIntVal(osSeconds); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6750 |
|
1 | 6751 |
tmPtr = localtime(&t); |
1135 | 6752 |
year = __MKSMALLINT(tmPtr->tm_year + 1900); |
6753 |
month = __MKSMALLINT(tmPtr->tm_mon + 1); |
|
6754 |
day = __MKSMALLINT(tmPtr->tm_mday); |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6755 |
%}. |
1 | 6756 |
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
|
6757 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6758 |
" |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6759 |
OperatingSystem computeDatePartsOf:0 for:[:y :m :d | |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
6760 |
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
|
6761 |
] |
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 |
! |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6764 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6765 |
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
|
6766 |
"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
|
6767 |
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
|
6768 |
any daylight saving adjustings." |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6769 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6770 |
|osSeconds| |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6771 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6772 |
%{ |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6773 |
struct tm tm; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6774 |
long t; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6775 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6776 |
if (__bothSmallInteger(y, m) |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6777 |
&& __bothSmallInteger(d, h) |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6778 |
&& __bothSmallInteger(min, s)) { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6779 |
tm.tm_hour = __intVal(h); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6780 |
tm.tm_min = __intVal(min); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6781 |
tm.tm_sec = __intVal(s); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6782 |
|
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6783 |
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
|
6784 |
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
|
6785 |
tm.tm_mday = __intVal(d); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6786 |
tm.tm_isdst = -1; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6787 |
|
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6788 |
t = mktime(&tm); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6789 |
osSeconds = __MKUINT(t); |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6790 |
} |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6791 |
%}. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6792 |
osSeconds notNil ifTrue:[ |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6793 |
^ osSeconds * 1000 + millis |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6794 |
]. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6795 |
^ self primitiveFailed |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6796 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6797 |
" |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6798 |
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
|
6799 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6800 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6801 |
! |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6802 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6803 |
computeTimeAndDateFrom:osTime |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6804 |
"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
|
6805 |
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
|
6806 |
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
|
6807 |
dayInYear (1..) and dayInWeek (1..). |
616 | 6808 |
Conversion is to localtime including any daylight saving adjustments." |
6809 |
||
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6810 |
|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
|
6811 |
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
|
6812 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6813 |
millis := osTime \\ 1000. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6814 |
osSeconds := osTime // 1000. |
63 | 6815 |
%{ |
6816 |
struct tm *tmPtr; |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6817 |
struct tm *gmTmPtr; |
63 | 6818 |
long t; |
6819 |
||
2073 | 6820 |
#if defined(HAS_NO_TIMEZONE) |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6821 |
# define TIMEZONE tmPtr->tm_gmtoff |
811 | 6822 |
#else |
831 | 6823 |
# ifdef MSDOS_LIKE |
1487 | 6824 |
# define TIMEZONE 0 |
831 | 6825 |
# else |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6826 |
# define TIMEZONE timezone |
831 | 6827 |
# endif |
811 | 6828 |
#endif |
6829 |
||
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6830 |
t = __longIntVal(osSeconds); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6831 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6832 |
tmPtr = localtime(&t); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6833 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6834 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6835 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6836 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6837 |
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
|
6838 |
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
|
6839 |
day = __MKSMALLINT(tmPtr->tm_mday); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6840 |
|
1511
823fcfbbb741
weekDay/yearDay start with0 in tm_ struct, but
Claus Gittinger <cg@exept.de>
parents:
1510
diff
changeset
|
6841 |
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
|
6842 |
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
|
6843 |
|
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6844 |
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
|
6845 |
dst = false; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6846 |
utcOffset = __MKSMALLINT(TIMEZONE); |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6847 |
} else { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6848 |
dst = true; |
800
067094efdaed
use HAS_ALTZONE / HAS_DAYLIGHT
Claus Gittinger <cg@exept.de>
parents:
798
diff
changeset
|
6849 |
#ifdef HAS_ALTZONE |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6850 |
utcOffset = __MKSMALLINT(altzone); |
800
067094efdaed
use HAS_ALTZONE / HAS_DAYLIGHT
Claus Gittinger <cg@exept.de>
parents:
798
diff
changeset
|
6851 |
#else |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6852 |
utcOffset = __MKSMALLINT(TIMEZONE) + 3600; |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6853 |
#endif |
63 | 6854 |
} |
241 | 6855 |
%}. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6856 |
"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
|
6857 |
ret := Array new:11. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6858 |
ret at:1 put:year. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6859 |
ret at:2 put:month. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6860 |
ret at:3 put:day. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6861 |
ret at:4 put:hours. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6862 |
ret at:5 put:minutes. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6863 |
ret at:6 put:seconds. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6864 |
ret at:7 put:utcOffset. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6865 |
ret at:8 put:dst. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6866 |
ret at:9 put:millis. |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6867 |
ret at:10 put:yDay. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6868 |
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
|
6869 |
^ ret |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6870 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6871 |
" |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6872 |
OperatingSystem computeTimeAndDateFrom:0 |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6873 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6874 |
! |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6875 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6876 |
computeTimePartsOf:osTime for:aBlock |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6877 |
"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
|
6878 |
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
|
6879 |
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
|
6880 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6881 |
|hours minutes seconds millis osSeconds| |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6882 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6883 |
osSeconds := osTime // 1000. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6884 |
millis := osTime \\ 1000. |
616 | 6885 |
%{ |
6886 |
struct tm *tmPtr; |
|
6887 |
long t; |
|
6888 |
||
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6889 |
t = __longIntVal(osSeconds); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6890 |
|
616 | 6891 |
tmPtr = localtime(&t); |
1135 | 6892 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
6893 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
|
6894 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6895 |
%}. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6896 |
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
|
6897 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6898 |
" |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6899 |
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
|
6900 |
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
|
6901 |
] |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6902 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6903 |
! |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6904 |
|
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6905 |
computeUTCTimeAndDateFrom:osTime |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6906 |
"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
|
6907 |
containing year, month, day, hour, minute and seconds, |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6908 |
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
|
6909 |
dayInYear (1..) and dayInWeek (1..). |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6910 |
Conversion is to UTC." |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6911 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6912 |
|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
|
6913 |
dst yDay wDay osSeconds ret| |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6914 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6915 |
millis := osTime \\ 1000. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6916 |
osSeconds := osTime // 1000. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6917 |
%{ |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6918 |
struct tm *tmPtr; |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6919 |
struct tm *gmTmPtr; |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6920 |
long t; |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6921 |
|
2073 | 6922 |
#if defined(HAS_NO_TIMEZONE) |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6923 |
# define TIMEZONE tmPtr->tm_gmtoff |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6924 |
#else |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6925 |
# ifdef MSDOS_LIKE |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6926 |
# define TIMEZONE 0 |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6927 |
# else |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6928 |
# define TIMEZONE timezone |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6929 |
# endif |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6930 |
#endif |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6931 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6932 |
t = __longIntVal(osSeconds); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6933 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6934 |
tmPtr = gmtime(&t); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6935 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6936 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6937 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6938 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6939 |
year = __MKSMALLINT(tmPtr->tm_year + 1900); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6940 |
month = __MKSMALLINT(tmPtr->tm_mon + 1); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6941 |
day = __MKSMALLINT(tmPtr->tm_mday); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6942 |
|
1511
823fcfbbb741
weekDay/yearDay start with0 in tm_ struct, but
Claus Gittinger <cg@exept.de>
parents:
1510
diff
changeset
|
6943 |
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
|
6944 |
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
|
6945 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6946 |
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
|
6947 |
dst = false; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6948 |
utcOffset = __MKSMALLINT(TIMEZONE); |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6949 |
} else { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6950 |
dst = true; |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6951 |
#ifdef HAS_ALTZONE |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6952 |
utcOffset = __MKSMALLINT(altzone); |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6953 |
#else |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6954 |
utcOffset = __MKSMALLINT(TIMEZONE) + 3600; |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6955 |
#endif |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6956 |
} |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6957 |
%}. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6958 |
"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
|
6959 |
ret := Array new:11. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6960 |
ret at:1 put:year. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6961 |
ret at:2 put:month. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6962 |
ret at:3 put:day. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6963 |
ret at:4 put:hours. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6964 |
ret at:5 put:minutes. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6965 |
ret at:6 put:seconds. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6966 |
ret at:7 put:utcOffset. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6967 |
ret at:8 put:dst. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6968 |
ret at:9 put:millis. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6969 |
ret at:10 put:yDay. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6970 |
ret at:11 put:wDay. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6971 |
^ ret |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6972 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6973 |
" |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6974 |
OperatingSystem computeUTCTimeAndDateFrom:0 |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6975 |
" |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6976 |
! |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6977 |
|
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6978 |
computeUTCTimePartsOf:osTime for:aBlock |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6979 |
"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
|
6980 |
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
|
6981 |
Conversion is to UTC." |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6982 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6983 |
|hours minutes seconds millis osSeconds| |
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 |
osSeconds := osTime // 1000. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6986 |
millis := osTime \\ 1000. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6987 |
%{ |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6988 |
struct tm *tmPtr; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6989 |
long t; |
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 |
t = __longIntVal(osSeconds); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6992 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6993 |
tmPtr = gmtime(&t); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6994 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6995 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6996 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6997 |
%}. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6998 |
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
|
6999 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7000 |
" |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
7001 |
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
|
7002 |
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
|
7003 |
] |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7004 |
" |
275 | 7005 |
! |
7006 |
||
1 | 7007 |
getMillisecondTime |
185 | 7008 |
"This returns the millisecond timers value. |
7009 |
The range is limited to 0..1fffffff (i.e. the SmallInteger range) to avoid |
|
7010 |
LargeInteger arithmetic when doing timeouts and delays. |
|
792 | 7011 |
Since this value is wrapping around in regular intervals, this can only be used for |
185 | 7012 |
short relative time deltas. |
7013 |
Use the millisecondTimeXXX:-methods to compare and add time deltas - these know about the wrap. |
|
7014 |
||
7015 |
BAD DESIGN: |
|
7016 |
This should be changed to return some instance of RelativeTime, |
|
7017 |
and these computations moved there. |
|
95 | 7018 |
|
7019 |
Dont use this method in application code since it is an internal (private) |
|
7020 |
interface. For compatibility with ST-80, use Time millisecondClockValue. |
|
7021 |
" |
|
1 | 7022 |
|
7023 |
%{ /* NOCONTEXT */ |
|
7024 |
||
7025 |
long t; |
|
185 | 7026 |
#if !defined(HAS_GETTIMEOFDAY) && defined(SYSV) && defined(HZ) |
7027 |
/* |
|
7028 |
* sys5 time |
|
7029 |
*/ |
|
1 | 7030 |
long ticks; |
7031 |
struct tms tb; |
|
7032 |
||
7033 |
ticks = times(&tb); |
|
7034 |
t = (ticks * 1000) / HZ; |
|
792 | 7035 |
#else |
1632 | 7036 |
# ifdef WIN32 |
7037 |
t = GetTickCount(); |
|
7038 |
# else |
|
7039 |
# ifdef MSDOS_LIKE |
|
792 | 7040 |
struct _timeb timebuffer; |
7041 |
||
7042 |
_ftime(&timebuffer); |
|
7043 |
t = (timebuffer.time * 1000) + timebuffer.millitm; |
|
1632 | 7044 |
# else /* assume HAS_GETTIMEOFDAY */ |
185 | 7045 |
/* |
7046 |
* bsd time |
|
7047 |
*/ |
|
1 | 7048 |
struct timeval tb; |
7049 |
struct timezone tzb; |
|
7050 |
||
7051 |
gettimeofday(&tb, &tzb); |
|
7052 |
t = tb.tv_sec*1000 + tb.tv_usec/1000; |
|
1632 | 7053 |
# endif |
792 | 7054 |
# endif |
68 | 7055 |
#endif |
1135 | 7056 |
RETURN ( __MKSMALLINT(t & 0x1FFFFFFF) ); |
1 | 7057 |
%} |
7058 |
! |
|
7059 |
||
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7060 |
getOSTime |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7061 |
"This returns the millisecond OS time. |
2000 | 7062 |
The base of the returned value is not consistent across |
7063 |
different OS's - some return the number of millis since jan, 1st 1970; |
|
7064 |
others since 1900. The Time classes are prepared for this, and |
|
7065 |
convert as appropriate. |
|
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7066 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7067 |
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
|
7068 |
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
|
7069 |
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
|
7070 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7071 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7072 |
|seconds millis| |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7073 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7074 |
%{ |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7075 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7076 |
long t; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7077 |
#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
|
7078 |
/* |
2000 | 7079 |
* sys5 time; we have to fake the information |
7080 |
* 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
|
7081 |
*/ |
616 | 7082 |
int now; |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7083 |
long ticks; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7084 |
struct tms tb; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7085 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7086 |
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
|
7087 |
seconds = __MKUINT(now); |
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 |
ticks = times(&tb); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7090 |
t = (ticks * 1000) / HZ; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7091 |
t = t % 1000; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7092 |
millis = __MKSMALLINT(t); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7093 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7094 |
#else |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7095 |
# ifdef MSDOS_LIKE |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7096 |
struct _timeb timebuffer; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7097 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7098 |
_ftime(&timebuffer); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7099 |
seconds = __MKUINT(timebuffer.time); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7100 |
millis = __MKSMALLINT(timebuffer.millitm); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7101 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7102 |
# else /* assume HAS_GETTIMEOFDAY */ |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7103 |
/* |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7104 |
* bsd time |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7105 |
*/ |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7106 |
struct timeval tb; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7107 |
struct timezone tzb; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7108 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7109 |
gettimeofday(&tb, &tzb); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7110 |
seconds = __MKUINT(tb.tv_sec); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7111 |
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
|
7112 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7113 |
# endif |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7114 |
#endif |
831 | 7115 |
%}. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7116 |
^ (seconds * 1000) + millis |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7117 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7118 |
" |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
7119 |
OperatingSystem getOSTime printCR. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7120 |
Delay waitForSeconds:0.2. |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
7121 |
OperatingSystem getOSTime printCR. |
831 | 7122 |
" |
616 | 7123 |
! |
7124 |
||
7125 |
maximumMillisecondTimeDelta |
|
7126 |
"this returns the maximum delta supported by millisecondCounter |
|
7127 |
based methods. The returned value is half the value at which the |
|
7128 |
timer wraps." |
|
7129 |
||
7130 |
%{ /* NOCONTEXT */ |
|
1135 | 7131 |
RETURN ( __MKSMALLINT(0x0FFFFFFF) ); |
616 | 7132 |
%} |
7133 |
! |
|
7134 |
||
7135 |
millisecondDelay:millis |
|
7136 |
"delay execution for millis milliseconds or until the next event |
|
7137 |
arrives. |
|
7138 |
All lower priority threads will also sleep for the duration, |
|
7139 |
interrupts (and therefore, higher prio processes) are |
|
7140 |
still handled. |
|
7141 |
Better use a Delay, to only delay the calling thread. |
|
7142 |
(however, a delay cannot be used in the event handler or scheduler)" |
|
7143 |
||
7144 |
|now then delta| |
|
7145 |
||
831 | 7146 |
%{ /* NOCONTEXT */ |
7147 |
#ifdef WIN32 |
|
7148 |
int t = __intVal(millis); |
|
7149 |
||
7150 |
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
|
7151 |
Sleep(t); |
831 | 7152 |
} |
7153 |
RETURN (self); |
|
7154 |
#endif |
|
7155 |
%}. |
|
7156 |
||
616 | 7157 |
now := OperatingSystem getMillisecondTime. |
7158 |
then := OperatingSystem millisecondTimeAdd:now and:millis. |
|
7159 |
||
7160 |
[OperatingSystem millisecondTime:then isAfter:now] whileTrue:[ |
|
7161 |
delta := OperatingSystem millisecondTimeDeltaBetween:then and:now. |
|
7162 |
self selectOnAnyReadable:nil writable:nil exception:nil withTimeOut:delta. |
|
7163 |
now := OperatingSystem getMillisecondTime. |
|
7164 |
] |
|
7165 |
||
7166 |
" |
|
7167 |
OperatingSystem millisecondDelay:2000 |
|
7168 |
" |
|
7169 |
! |
|
7170 |
||
7171 |
millisecondTime:msTime1 isAfter:msTime2 |
|
7172 |
"return true if msTime1 is after msTime2, false if not. |
|
7173 |
The two arguments are supposed to be millisecond times |
|
7174 |
(such as returned getMillisecondTime) which wrap at 16r1FFFFFFF. |
|
7175 |
||
7176 |
This should really be moved to some RelativeTime class." |
|
7177 |
||
7178 |
(msTime1 > msTime2) ifTrue:[ |
|
7179 |
((msTime1 - msTime2) >= 16r10000000) ifTrue:[ |
|
7180 |
^ false |
|
7181 |
]. |
|
7182 |
^ true |
|
7183 |
]. |
|
7184 |
((msTime2 - msTime1) > 16r10000000) ifTrue:[ |
|
7185 |
^ true |
|
7186 |
]. |
|
7187 |
^ false |
|
7188 |
! |
|
7189 |
||
7190 |
millisecondTimeAdd:msTime1 and:msTime2 |
|
7191 |
"Add two millisecond times (such as returned getMillisecondTime). |
|
7192 |
The returned value is msTime1 + msTime2 where a wrap occurs at:16r1FFFFFFF. |
|
7193 |
||
7194 |
This should really be moved to some RelativeTime class." |
|
7195 |
||
7196 |
|sum| |
|
7197 |
||
7198 |
sum := msTime1 + msTime2. |
|
7199 |
(sum > 16r1FFFFFFF) ifTrue:[^ sum - 16r20000000]. |
|
7200 |
(sum < 0) ifTrue:[^ sum + 16r20000000]. |
|
7201 |
^ sum |
|
7202 |
! |
|
7203 |
||
1 | 7204 |
millisecondTimeDeltaBetween:msTime1 and:msTime2 |
95 | 7205 |
"subtract two millisecond times (such as returned getMillisecondTime) |
185 | 7206 |
and return the difference. Since milli-times wrap (at 16r01FFFFFFF), |
95 | 7207 |
some special handling is built-in here. |
185 | 7208 |
The returned value is msTime1 - msTime2. The returned value is invalid |
7209 |
if the delta is >= 0x10000000. |
|
63 | 7210 |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
7211 |
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
|
7212 |
better yet: create a subclass of Integer named LimitedRangeInteger." |
1 | 7213 |
|
7214 |
(msTime1 > msTime2) ifTrue:[ |
|
185 | 7215 |
^ msTime1 - msTime2 |
1 | 7216 |
]. |
7217 |
^ msTime1 + 16r10000000 - msTime2 |
|
95 | 7218 |
|
7219 |
" |
|
7220 |
OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:1 |
|
7221 |
OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:(16 / 3) |
|
7222 |
OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:1000 |
|
7223 |
||
7224 |
OperatingSystem millisecondTimeDeltaBetween:0 and:16r0FFFFFFF |
|
7225 |
OperatingSystem millisecondTimeDeltaBetween:(13/3) and:16r0FFFFFFF |
|
7226 |
OperatingSystem millisecondTimeDeltaBetween:999 and:16r0FFFFFFF |
|
7227 |
||
7228 |
OperatingSystem millisecondTime:0 isAfter:16r0FFFFFFF |
|
7229 |
OperatingSystem millisecondTime:(13/3) isAfter:16r0FFFFFFF |
|
7230 |
OperatingSystem millisecondTime:999 isAfter:16r0FFFFFFF |
|
7231 |
||
7232 |
OperatingSystem millisecondTime:0 isAfter:0 |
|
7233 |
OperatingSystem millisecondTime:(13/3) isAfter:0 |
|
7234 |
OperatingSystem millisecondTime:999 isAfter:0 |
|
7235 |
||
7236 |
OperatingSystem millisecondTime:1 isAfter:0 |
|
7237 |
OperatingSystem millisecondTime:(13/3) isAfter:2 |
|
7238 |
OperatingSystem millisecondTime:999 isAfter:900 |
|
7239 |
||
7240 |
|t1 t2| |
|
7241 |
||
7242 |
t1 := Time millisecondClockValue. |
|
7243 |
(Delay forMilliseconds:1) wait. |
|
7244 |
t2 := Time millisecondClockValue. |
|
7245 |
OperatingSystem millisecondTimeDeltaBetween:t2 and:t1 |
|
7246 |
" |
|
1 | 7247 |
! |
7248 |
||
7249 |
sleep:numberOfSeconds |
|
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7250 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7251 |
|
308 | 7252 |
"cease ANY action for some time. This suspends the whole smalltalk |
7253 |
(unix-) process for some time. |
|
1 | 7254 |
Not really useful since not even low-prio processes and interrupt |
95 | 7255 |
handling will run during the sleep. |
7256 |
Use either OperatingSystem>>millisecondDelay: (which makes all |
|
7257 |
threads sleep, but handles interrupts) or use a Delay (which makes |
|
7258 |
only the calling thread sleep)." |
|
1 | 7259 |
|
7260 |
%{ /* NOCONTEXT */ |
|
7261 |
||
252 | 7262 |
if (__isSmallInteger(numberOfSeconds)) { |
1135 | 7263 |
sleep(__intVal(numberOfSeconds)); |
185 | 7264 |
RETURN ( self ); |
1 | 7265 |
} |
68 | 7266 |
%}. |
7267 |
" |
|
7268 |
argument not integer |
|
7269 |
" |
|
792 | 7270 |
^ self primitiveFailed |
95 | 7271 |
|
7272 |
" |
|
7273 |
OperatingSystem sleep:2 |
|
7274 |
" |
|
10 | 7275 |
! ! |
7276 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
7277 |
!OperatingSystem class methodsFor:'users & groups'! |
616 | 7278 |
|
7279 |
getEffectiveGroupID |
|
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7280 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7281 |
|
616 | 7282 |
"return the current users (thats you) effective numeric group id. |
7283 |
This is only different from getGroupID, if you have ST/X running |
|
7284 |
as a setuid program (of which you should think about twice)." |
|
7285 |
||
7286 |
%{ /* NOCONTEXT */ |
|
7287 |
||
7288 |
#ifdef UNIX_LIKE |
|
7289 |
int uid; |
|
7290 |
||
7291 |
uid = getegid(); |
|
7292 |
RETURN ( __MKSMALLINT(uid) ); |
|
7293 |
#endif |
|
7294 |
/* --- return same as getGroupID --- */ |
|
7295 |
%}. |
|
7296 |
^ self getGroupID |
|
7297 |
||
7298 |
" |
|
7299 |
OperatingSystem getEffectiveGroupID |
|
7300 |
" |
|
7301 |
! |
|
7302 |
||
7303 |
getEffectiveUserID |
|
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7304 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7305 |
|
616 | 7306 |
"return the current users (thats you) effective numeric user id. |
7307 |
This is only different from getUserID, if you have ST/X running |
|
7308 |
as a setuid program (of which you should think about twice)." |
|
10 | 7309 |
|
7310 |
%{ /* NOCONTEXT */ |
|
7311 |
||
616 | 7312 |
#ifdef UNIX_LIKE |
7313 |
int uid; |
|
7314 |
||
7315 |
uid = geteuid(); |
|
7316 |
RETURN ( __MKSMALLINT(uid) ); |
|
7317 |
#endif |
|
7318 |
/* --- return same as getUserID --- */ |
|
7319 |
%}. |
|
7320 |
^ self getUserID |
|
7321 |
||
7322 |
" |
|
7323 |
OperatingSystem getEffectiveUserID |
|
7324 |
" |
|
7325 |
! |
|
7326 |
||
1549
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7327 |
getFullUserNameFromID:userID |
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7328 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7329 |
|
1549
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7330 |
"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
|
7331 |
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
|
7332 |
|
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7333 |
|info gecos| |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7334 |
|
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7335 |
info := self userInfoOf:userID. |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7336 |
(info notNil |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7337 |
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
|
7338 |
gecos := info at:#gecos. |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7339 |
(gecos includes:$,) ifTrue:[ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7340 |
^ gecos copyTo:(gecos indexOf:$,) - 1 |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7341 |
]. |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7342 |
^ gecos |
1549
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7343 |
]. |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7344 |
^ self getUserNameFromID:userID |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7345 |
|
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7346 |
" |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7347 |
OperatingSystem getFullUserNameFromID:0 |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7348 |
OperatingSystem getFullUserNameFromID:(OperatingSystem getUserID) |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7349 |
|
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7350 |
OperatingSystem getUserNameFromID:(OperatingSystem getUserID) |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7351 |
" |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7352 |
|
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7353 |
"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
|
7354 |
! |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7355 |
|
616 | 7356 |
getGroupID |
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7357 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7358 |
|
616 | 7359 |
"return the current users (thats you) numeric group id" |
7360 |
||
7361 |
%{ /* NOCONTEXT */ |
|
7362 |
||
7363 |
#ifdef UNIX_LIKE |
|
7364 |
int uid; |
|
7365 |
||
7366 |
uid = getgid(); |
|
7367 |
RETURN ( __MKSMALLINT(uid) ); |
|
7368 |
#else |
|
7369 |
# ifdef SYSTEM_HAS_GROUPS |
|
7370 |
/* ... */ |
|
10 | 7371 |
# endif |
7372 |
#endif |
|
68 | 7373 |
%}. |
616 | 7374 |
^ 1 "just a dummy for systems which do not have userIDs" |
7375 |
||
68 | 7376 |
" |
616 | 7377 |
OperatingSystem getGroupID |
7378 |
" |
|
7379 |
! |
|
7380 |
||
7381 |
getGroupNameFromID:aNumber |
|
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7382 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7383 |
|
616 | 7384 |
"return the group-name-string for a given numeric group-id" |
7385 |
||
7386 |
%{ /* NOCONTEXT */ |
|
7387 |
||
7388 |
#ifdef UNIX_LIKE |
|
7389 |
struct group *g; |
|
7390 |
||
7391 |
if (__isSmallInteger(aNumber)) { |
|
1135 | 7392 |
g = getgrgid(__intVal(aNumber)); |
616 | 7393 |
if (g) { |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7394 |
RETURN ( __MKSTRING(g->gr_name) ); |
616 | 7395 |
} |
7396 |
} |
|
7397 |
#endif |
|
7398 |
%}. |
|
7399 |
^ '???' |
|
7400 |
||
7401 |
" |
|
7402 |
OperatingSystem getGroupNameFromID:0 |
|
7403 |
OperatingSystem getGroupNameFromID:10 |
|
7404 |
" |
|
7405 |
! |
|
7406 |
||
7407 |
getHomeDirectory |
|
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7408 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7409 |
|
616 | 7410 |
"return the name of the users home directory" |
7411 |
||
7412 |
^ OperatingSystem getEnvironment:'HOME' |
|
7413 |
||
7414 |
" |
|
7415 |
OperatingSystem getHomeDirectory |
|
7416 |
" |
|
7417 |
! |
|
7418 |
||
7419 |
getLoginName |
|
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7420 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7421 |
|
1549
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7422 |
"return a string with the users login name" |
616 | 7423 |
|
7424 |
%{ /* NOCONTEXT */ |
|
7425 |
static char cachedName[64]; |
|
7426 |
static firstCall = 1; |
|
7427 |
||
831 | 7428 |
char *name = (char *)0; |
616 | 7429 |
#ifdef UNIX_LIKE |
7430 |
if (firstCall) { |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7431 |
name = (char *)getlogin(); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7432 |
if (! name || (name[0] == 0)) { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7433 |
name = (char *)getenv("LOGNAME"); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7434 |
} |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7435 |
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
|
7436 |
strcpy(cachedName, name); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7437 |
firstCall = 0; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7438 |
} |
616 | 7439 |
} else { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7440 |
name = cachedName; |
616 | 7441 |
} |
831 | 7442 |
#else |
1632 | 7443 |
# ifdef WIN32 |
831 | 7444 |
if (firstCall) { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7445 |
int nameSize = sizeof(cachedName); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7446 |
|
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7447 |
if (GetUserName(cachedName, &nameSize) == TRUE) { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7448 |
name = cachedName; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7449 |
firstCall = 0; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7450 |
} |
831 | 7451 |
} else { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7452 |
name = cachedName; |
831 | 7453 |
} |
7454 |
# endif |
|
7455 |
#endif |
|
7456 |
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
|
7457 |
name = (char *)getenv("LOGNAME"); |
831 | 7458 |
} |
7459 |
if (! name || (name[0] == 0) ) { |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7460 |
name = "you"; |
831 | 7461 |
} |
7462 |
||
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7463 |
RETURN ( __MKSTRING(name) ); |
831 | 7464 |
%}. |
616 | 7465 |
" |
7466 |
OperatingSystem getLoginName |
|
7467 |
" |
|
7468 |
! |
|
7469 |
||
7470 |
getUserID |
|
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7471 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7472 |
|
616 | 7473 |
"return the current users (thats you) numeric user id" |
7474 |
||
7475 |
%{ /* NOCONTEXT */ |
|
7476 |
||
7477 |
#ifdef UNIX_LIKE |
|
7478 |
int uid; |
|
7479 |
||
7480 |
uid = getuid(); |
|
7481 |
RETURN ( __MKSMALLINT(uid) ); |
|
7482 |
#else |
|
7483 |
# ifdef SYSTEM_HAS_USERS |
|
7484 |
/* ... */ |
|
7485 |
# endif |
|
7486 |
#endif |
|
7487 |
%}. |
|
7488 |
^ 1 "just a dummy for systems which do not have userIDs" |
|
7489 |
||
7490 |
" |
|
7491 |
OperatingSystem getUserID |
|
68 | 7492 |
" |
616 | 7493 |
! |
7494 |
||
7495 |
getUserNameFromID:aNumber |
|
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7496 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7497 |
|
1549
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7498 |
"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
|
7499 |
This is the login name, not the fullName." |
616 | 7500 |
|
7501 |
%{ /* NOCONTEXT */ |
|
7502 |
||
7503 |
#ifdef UNIX_LIKE |
|
7504 |
struct passwd *p; |
|
7505 |
||
7506 |
if (__isSmallInteger(aNumber)) { |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7507 |
p = getpwuid(__intVal(aNumber)); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7508 |
if (p) { |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7509 |
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
|
7510 |
} |
616 | 7511 |
} |
7512 |
#endif |
|
7513 |
%}. |
|
7514 |
^ '? (' , aNumber printString , ')' |
|
7515 |
||
7516 |
" |
|
7517 |
OperatingSystem getUserNameFromID:0 |
|
7518 |
OperatingSystem getUserNameFromID:100 |
|
7519 |
OperatingSystem getUserNameFromID:9991 |
|
7520 |
" |
|
1 | 7521 |
! |
7522 |
||
616 | 7523 |
userInfoOf:aNameOrID |
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7524 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7525 |
|
616 | 7526 |
"return a dictionary filled with userinfo. The argument can be either |
7527 |
a string with the users name or its numeric id. |
|
7528 |
Notice, that not all systems provide (all of) this info; |
|
7529 |
DOS systems return nothing; |
|
7530 |
non-SYSV4 systems have no age/comment. |
|
7531 |
Portable applications may want to check the systemType and NOT depend |
|
7532 |
on all keys to be present in the returned dictionary. |
|
7533 |
Another notice: on some systems (SYSV4), the gecos field includes multiple |
|
7534 |
entries (i.e. not just the name), separated by commas. You may want to |
|
7535 |
extract any substring, up to the first comma to get the real life name." |
|
7536 |
||
7537 |
|info name passw uid gid age comment |
|
7538 |
gecos dir shell| |
|
7539 |
||
7540 |
%{ |
|
7541 |
#ifdef UNIX_LIKE |
|
7542 |
struct passwd *buf; |
|
7543 |
int ret; |
|
7544 |
||
7545 |
if (__isString(aNameOrID)) { |
|
7546 |
buf = getpwnam(__stringVal(aNameOrID)); |
|
7547 |
} else if (__isSmallInteger(aNameOrID)) { |
|
7548 |
buf = getpwuid(__intVal(aNameOrID)); |
|
7549 |
} else { |
|
7550 |
buf = (struct passwd *)0; |
|
7551 |
} |
|
7552 |
if (buf) { |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7553 |
name = __MKSTRING(buf->pw_name); |
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7554 |
passw = __MKSTRING(buf->pw_passwd); |
616 | 7555 |
# ifdef SYSV4 |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7556 |
age = __MKSTRING(buf->pw_age); |
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7557 |
comment = __MKSTRING(buf->pw_comment); |
616 | 7558 |
# endif |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7559 |
dir = __MKSTRING(buf->pw_dir); |
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7560 |
gecos = __MKSTRING(buf->pw_gecos); |
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7561 |
shell = __MKSTRING(buf->pw_shell); |
616 | 7562 |
|
1135 | 7563 |
uid = __MKSMALLINT(buf->pw_uid); |
7564 |
gid = __MKSMALLINT(buf->pw_gid); |
|
616 | 7565 |
} |
7566 |
#endif |
|
7567 |
%}. |
|
7568 |
info := IdentityDictionary new. |
|
7569 |
name notNil ifTrue:[ |
|
7570 |
info at:#name put:name. |
|
7571 |
] ifFalse:[ |
|
7572 |
info at:#name put:'unknown' |
|
7573 |
]. |
|
7574 |
passw notNil ifTrue:[info at:#passwd put:passw]. |
|
7575 |
age notNil ifTrue:[info at:#age put:age]. |
|
7576 |
comment notNil ifTrue:[info at:#comment put:comment]. |
|
7577 |
gecos notNil ifTrue:[info at:#gecos put:gecos]. |
|
7578 |
shell notNil ifTrue:[info at:#shell put:shell]. |
|
7579 |
dir notNil ifTrue:[info at:#dir put:dir]. |
|
7580 |
uid notNil ifTrue:[info at:#uid put:uid]. |
|
7581 |
gid notNil ifTrue:[info at:#gid put:gid]. |
|
7582 |
^ info |
|
7583 |
||
7584 |
" |
|
7585 |
OperatingSystem userInfoOf:'root' |
|
7586 |
OperatingSystem userInfoOf:1 |
|
7587 |
OperatingSystem userInfoOf:'claus' |
|
7588 |
OperatingSystem userInfoOf:'fooBar' |
|
7589 |
OperatingSystem userInfoOf:(OperatingSystem getUserID) |
|
7590 |
" |
|
7591 |
! ! |
|
7592 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
7593 |
!OperatingSystem class methodsFor:'waiting for events'! |
616 | 7594 |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7595 |
blockingChildProcessWait |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7596 |
"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
|
7597 |
%{ /*NOCONTEXT*/ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7598 |
#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
|
7599 |
RETURN(false); |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7600 |
#else |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7601 |
RETURN(true); |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7602 |
#endif |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7603 |
%} |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7604 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7605 |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7606 |
childProcessWait:blocking |
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7607 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7608 |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7609 |
"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
|
7610 |
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
|
7611 |
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
|
7612 |
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
|
7613 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7614 |
|pid status code core| |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7615 |
%{ |
1597 | 7616 |
#ifdef UNIX_LIKE |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7617 |
int p; |
1653 | 7618 |
|
1597 | 7619 |
# if defined(HAS_WAITPID) |
1653 | 7620 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7621 |
int s; |
1653 | 7622 |
# define __WAIT waitpid(-1, &s, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED) |
7623 |
||
1597 | 7624 |
# else |
7625 |
# if defined(HAS_WAIT3) |
|
1653 | 7626 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7627 |
union wait s; |
1653 | 7628 |
# define __WAIT wait3(&s, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED, 0) |
7629 |
||
7630 |
# else /* neithe waitpid, nor wait3; use wait, which is blocking */ |
|
7631 |
||
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7632 |
int s; |
1653 | 7633 |
# define __WAIT wait(&s) |
7634 |
# define __BLOCKING_WAIT__ 1 |
|
1597 | 7635 |
|
1654 | 7636 |
if (blocking != true) { |
7637 |
/* |
|
7638 |
* We do not support nonBlocking waits, so signal an error |
|
7639 |
* Sorry about the goto, but with all these ifdefs ... |
|
7640 |
*/ |
|
7641 |
goto done; |
|
7642 |
} |
|
7643 |
# endif /*!HAS_WAIT3*/ |
|
7644 |
# endif /*!HAS_WAITPID*/ |
|
7645 |
||
2098
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7646 |
# if !defined(WIFEXITED) |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7647 |
# define WIFEXITED(stat) (((int)((stat)&0377))==0) |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7648 |
# 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
|
7649 |
# 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
|
7650 |
|
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7651 |
# define WEXITSTATUS(stat) ((int)(((stat)>>8)&0377)) |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7652 |
# define WTERMSIG(stat) (((int)((stat)&0377))&0177) |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7653 |
# define WSTOPSIG(stat) ((int)(((stat)>>8)&0377)) |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7654 |
# endif /*!WIFEXITED*/ |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7655 |
|
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7656 |
# if !defined(WCOREDUMP) |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7657 |
# define WCOREDUMP(stat) ((int)(((stat)>>8)&0200)) |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7658 |
# endif /*!WCOREDUMP*/ |
1597 | 7659 |
|
7660 |
# if __BLOCKING_WAIT__ |
|
1433 | 7661 |
__BEGIN_INTERRUPTABLE__ |
1597 | 7662 |
# endif |
1433 | 7663 |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7664 |
do { |
1487 | 7665 |
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
|
7666 |
} 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
|
7667 |
|
1597 | 7668 |
# if __BLOCKING_WAIT__ |
1433 | 7669 |
__END_INTERRUPTABLE__ |
1654 | 7670 |
# undef __BLOCKING_WAIT__ |
1597 | 7671 |
# endif |
7672 |
||
7673 |
# undef __WAIT |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7674 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7675 |
if (p == 0) |
1487 | 7676 |
RETURN(nil) |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7677 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7678 |
if (p == -1) { |
1487 | 7679 |
if (errno == ECHILD) |
7680 |
RETURN(nil); |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7681 |
} else { |
1487 | 7682 |
pid = __MKSMALLINT(p); |
7683 |
if (WIFEXITED(s)) { |
|
7684 |
status = @symbol(exit); |
|
7685 |
code = __MKSMALLINT(WEXITSTATUS(s)); |
|
7686 |
core = WCOREDUMP(s) ? true : false; |
|
7687 |
} else if (WIFSIGNALED(s)) { |
|
7688 |
status = @symbol(signal); |
|
7689 |
code = __MKSMALLINT(WTERMSIG(s)); |
|
7690 |
} else if (WIFSTOPPED(s)) { |
|
7691 |
status = @symbol(stop); |
|
7692 |
code = __MKSMALLINT(WSTOPSIG(s)); |
|
7693 |
} |
|
1597 | 7694 |
# if defined(WIFCONTINUED) |
1487 | 7695 |
else if (WIFCONTINUED(s)) { |
7696 |
status = @symbol(continue); |
|
7697 |
} |
|
1597 | 7698 |
# endif |
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 |
done: ; |
1597 | 7701 |
#endif /* UNIX_LIKE */ |
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 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7704 |
pid isNil ifTrue:[ |
1487 | 7705 |
^ self primitiveFailed |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7706 |
]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7707 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7708 |
^ 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
|
7709 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7710 |
" |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7711 |
OperatingSystem childProcessWait:false |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7712 |
" |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7713 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7714 |
"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
|
7715 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7716 |
|
10 | 7717 |
readCheck:fd |
95 | 7718 |
"return true, if data is available on a filedescriptor (i.e. read |
7719 |
is possible without blocking)" |
|
10 | 7720 |
|
7721 |
(self selectOnAnyReadable:(Array with:fd) |
|
185 | 7722 |
writable:nil |
7723 |
exception:nil |
|
7724 |
withTimeOut:0) == fd |
|
7725 |
ifTrue:[^ true]. |
|
10 | 7726 |
^ false |
7727 |
! |
|
7728 |
||
616 | 7729 |
selectOn:fd1 and:fd2 withTimeOut:millis |
7730 |
"wait for any fd to become ready; timeout after t milliseconds. |
|
7731 |
A zero timeout-time will immediately return (i.e. poll). |
|
7732 |
Return fd if i/o ok, nil if timed-out or interrupted. |
|
7733 |
Obsolete: |
|
7734 |
This is a leftover method and will vanish." |
|
7735 |
||
7736 |
^ self selectOnAnyReadable:(Array with:fd1 with:fd2) |
|
7737 |
writable:(Array with:fd1 with:fd2) |
|
7738 |
exception:nil |
|
7739 |
withTimeOut:millis |
|
10 | 7740 |
! |
7741 |
||
7742 |
selectOn:fd withTimeOut:millis |
|
7743 |
"wait for aFileDesriptor to become ready; timeout after t milliseconds. |
|
1 | 7744 |
Return true, if i/o ok, false if timed-out or interrupted. |
7745 |
With 0 as timeout argument, this can be used to check for availability |
|
7746 |
of read-data. |
|
7747 |
Experimental." |
|
7748 |
||
3 | 7749 |
^ self selectOnAnyReadable:(Array with:fd) |
185 | 7750 |
writable:(Array with:fd) |
7751 |
exception:nil |
|
7752 |
withTimeOut:millis |
|
1 | 7753 |
! |
7754 |
||
616 | 7755 |
selectOnAny:fdArray withTimeOut:millis |
7756 |
"wait for any fd in fdArray (an Array of integers) to become ready; |
|
7757 |
timeout after t milliseconds. An empty set will always wait. |
|
7758 |
Return first ready fd if i/o ok, nil if timed-out or interrupted. |
|
7759 |
Experimental." |
|
7760 |
||
7761 |
^ self selectOnAnyReadable:fdArray |
|
7762 |
writable:fdArray |
|
185 | 7763 |
exception:nil |
7764 |
withTimeOut:millis |
|
1 | 7765 |
! |
7766 |
||
10 | 7767 |
selectOnAnyReadable:fdArray withTimeOut:millis |
95 | 7768 |
"wait for any fd in fdArray (an Array of integers) to become ready for |
7769 |
reading. Timeout after t milliseconds. An empty set will always wait. |
|
7770 |
A zero timeout-time will immediately return (i.e. poll). |
|
3 | 7771 |
Return first ready fd if i/o ok, nil if timed-out or interrupted. |
7772 |
Experimental." |
|
7773 |
||
7774 |
^ self selectOnAnyReadable:fdArray |
|
185 | 7775 |
writable:nil |
7776 |
exception:nil |
|
7777 |
withTimeOut:millis |
|
3 | 7778 |
! |
7779 |
||
95 | 7780 |
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray withTimeOut:millis |
7781 |
"wait for any fd in readFdArray (an Array of integers) to become ready for |
|
7782 |
reading, writeFdArray to become ready for writing, or exceptFdArray to |
|
7783 |
arrive exceptional data (i.e. out-of-band data). |
|
7784 |
Timeout after t milliseconds or, if the timeout time is 0, immediately.. |
|
7785 |
Empty fd-sets will always wait. Zero time can be used to poll file- |
|
7786 |
descriptors (i.e. to check if I/O possible without blocking). |
|
7787 |
Return first ready fd if I/O ok, nil if timed-out or interrupted." |
|
3 | 7788 |
|
1 | 7789 |
%{ |
831 | 7790 |
#ifdef MSDOS_LIKE |
7791 |
/* |
|
7792 |
* support a delay-wait only |
|
7793 |
* (i.e. fail if any filedescriptor is selected upon) |
|
7794 |
*/ |
|
7795 |
int count; |
|
7796 |
int i; |
|
7797 |
int t; |
|
7798 |
OBJ fd; |
|
7799 |
||
7800 |
if (! __isSmallInteger(millis)) { |
|
7801 |
goto fail; |
|
7802 |
} |
|
7803 |
||
7804 |
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
|
7805 |
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
|
7806 |
goto fail; |
831 | 7807 |
} |
7808 |
count = __arraySize(readFdArray); |
|
7809 |
for (i=0; i<count;i++) { |
|
1135 | 7810 |
fd = __ArrayInstPtr(readFdArray)->a_element[i]; |
831 | 7811 |
if (fd != nil) { |
7812 |
goto fail; |
|
7813 |
} |
|
7814 |
} |
|
7815 |
} |
|
7816 |
if (writeFdArray != nil) { |
|
7817 |
if (! __isArray(writeFdArray)) { |
|
7818 |
goto fail; |
|
7819 |
} |
|
7820 |
count = __arraySize(writeFdArray); |
|
7821 |
for (i=0; i<count;i++) { |
|
1135 | 7822 |
fd = __ArrayInstPtr(writeFdArray)->a_element[i]; |
831 | 7823 |
if (fd != nil) { |
7824 |
goto fail; |
|
7825 |
} |
|
7826 |
} |
|
7827 |
} |
|
7828 |
if (exceptFdArray != nil) { |
|
7829 |
if (! __isArray(exceptFdArray)) { |
|
7830 |
goto fail; |
|
7831 |
} |
|
7832 |
count = __arraySize(exceptFdArray); |
|
7833 |
for (i=0; i<count;i++) { |
|
1135 | 7834 |
fd = __ArrayInstPtr(exceptFdArray)->a_element[i]; |
831 | 7835 |
if (fd != nil) { |
7836 |
goto fail; |
|
7837 |
} |
|
7838 |
} |
|
7839 |
} |
|
1135 | 7840 |
t = __intVal(millis); |
831 | 7841 |
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
|
7842 |
/* |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
7843 |
* delay only |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
7844 |
*/ |
831 | 7845 |
Sleep(t); |
7846 |
} |
|
7847 |
RETURN (nil); |
|
7848 |
||
7849 |
#else /* not MSDOS_LIKE */ |
|
1 | 7850 |
fd_set rset, wset, eset; |
831 | 7851 |
struct timeval wt, et; |
1 | 7852 |
int t, f, maxF, i, lX, bX; |
7853 |
OBJ fd, retFd; |
|
95 | 7854 |
int ret; |
300 | 7855 |
int count; |
1 | 7856 |
|
252 | 7857 |
if (__isSmallInteger(millis)) { |
185 | 7858 |
FD_ZERO(&rset); |
7859 |
FD_ZERO(&wset); |
|
7860 |
FD_ZERO(&eset); |
|
7861 |
||
7862 |
maxF = -1; |
|
308 | 7863 |
if (readFdArray != nil) { |
300 | 7864 |
if (! __isArray(readFdArray)) { |
7865 |
goto fail; |
|
7866 |
} |
|
7867 |
count = __arraySize(readFdArray); |
|
308 | 7868 |
|
7869 |
for (i=0; i<count;i++) { |
|
1135 | 7870 |
fd = __ArrayInstPtr(readFdArray)->a_element[i]; |
308 | 7871 |
if (fd != nil) { |
1135 | 7872 |
f = __intVal(fd); |
308 | 7873 |
if ((f >= 0) && (f < FD_SETSIZE)) { |
7874 |
FD_SET(f, &rset); |
|
7875 |
if (f > maxF) maxF = f; |
|
7876 |
} |
|
185 | 7877 |
} |
7878 |
} |
|
7879 |
} |
|
300 | 7880 |
|
308 | 7881 |
if (writeFdArray != nil) { |
300 | 7882 |
if (! __isArray(writeFdArray)) { |
7883 |
goto fail; |
|
7884 |
} |
|
7885 |
count = __arraySize(writeFdArray); |
|
308 | 7886 |
for (i=0; i<count;i++) { |
1135 | 7887 |
fd = __ArrayInstPtr(writeFdArray)->a_element[i]; |
308 | 7888 |
if (fd != nil) { |
1135 | 7889 |
f = __intVal(fd); |
308 | 7890 |
if ((f >= 0) && (f < FD_SETSIZE)) { |
7891 |
FD_SET(f, &wset); |
|
7892 |
if (f > maxF) maxF = f; |
|
7893 |
} |
|
185 | 7894 |
} |
7895 |
} |
|
7896 |
} |
|
300 | 7897 |
|
308 | 7898 |
if (exceptFdArray != nil) { |
300 | 7899 |
if (! __isArray(exceptFdArray)) { |
7900 |
goto fail; |
|
7901 |
} |
|
7902 |
count = __arraySize(exceptFdArray); |
|
308 | 7903 |
for (i=0; i<count;i++) { |
1135 | 7904 |
fd = __ArrayInstPtr(exceptFdArray)->a_element[i]; |
308 | 7905 |
if (fd != nil) { |
1135 | 7906 |
f = __intVal(fd); |
308 | 7907 |
if ((f >= 0) && (f < FD_SETSIZE)) { |
7908 |
FD_SET(f, &eset); |
|
7909 |
if (f > maxF) maxF = f; |
|
7910 |
} |
|
185 | 7911 |
} |
7912 |
} |
|
7913 |
} |
|
308 | 7914 |
|
1135 | 7915 |
t = __intVal(millis); |
774
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7916 |
if (t) { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7917 |
wt.tv_sec = t / 1000; |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7918 |
wt.tv_usec = (t % 1000) * 1000; |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7919 |
} else { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7920 |
wt.tv_sec = wt.tv_usec = 0; |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7921 |
} |
185 | 7922 |
|
7923 |
/* |
|
7924 |
* make certain, that interrupt gets us out of the select |
|
7925 |
*/ |
|
362 | 7926 |
__BEGIN_INTERRUPTABLE__ |
185 | 7927 |
errno = 0; |
774
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7928 |
|
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7929 |
if (t == 0) { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7930 |
/* |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7931 |
* 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
|
7932 |
* interruptable. |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7933 |
*/ |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7934 |
do { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7935 |
ret = select(maxF+1, &rset, &wset, &eset, &wt); |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7936 |
} while ((ret < 0) && (errno == EINTR)); |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7937 |
} else { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7938 |
do { |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7939 |
ret = select(maxF+1, &rset, &wset, &eset, &wt); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7940 |
/* |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7941 |
* 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
|
7942 |
* could otherwise stay in this loop forever ... |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7943 |
* 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
|
7944 |
* 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
|
7945 |
*/ |
774
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7946 |
} while (0 /* (ret < 0) && (errno == EINTR) */ ); |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7947 |
} |
362 | 7948 |
__END_INTERRUPTABLE__ |
95 | 7949 |
|
185 | 7950 |
if (ret > 0) { |
7951 |
for (i=0; i <= maxF; i++) { |
|
7952 |
if (FD_ISSET(i, &rset) |
|
7953 |
|| FD_ISSET(i, &wset) |
|
7954 |
|| FD_ISSET(i, &eset)) { |
|
1135 | 7955 |
RETURN ( __MKSMALLINT(i) ); |
185 | 7956 |
} |
7957 |
} |
|
855
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
7958 |
} else { |
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
7959 |
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
|
7960 |
if (errno != EINTR) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
7961 |
fprintf(stderr, "OS: select errno = %d\n", errno); |
1135 | 7962 |
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
|
7963 |
} |
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
7964 |
} |
185 | 7965 |
} |
308 | 7966 |
|
185 | 7967 |
/* |
2117
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
7968 |
* return nil (means time expired or interrupted) |
185 | 7969 |
*/ |
7970 |
RETURN ( nil ); |
|
1 | 7971 |
} |
831 | 7972 |
#endif /* not MSDOS_LIKE */ |
7973 |
||
300 | 7974 |
fail: ; |
68 | 7975 |
%}. |
7976 |
" |
|
300 | 7977 |
timeout argument not integer, |
7978 |
or any fd-array nonNil and not an array |
|
792 | 7979 |
or not supported by OS |
68 | 7980 |
" |
792 | 7981 |
^ self primitiveFailed |
1 | 7982 |
! |
7983 |
||
616 | 7984 |
setBlocking:aBoolean on:fd |
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7985 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7986 |
|
616 | 7987 |
"set/clear the blocking attribute - if set (which is the default) |
7988 |
a read on the fileDescriptor will block until data is available. |
|
7989 |
If cleared, a read operation will immediately return with a value of |
|
7990 |
nil." |
|
10 | 7991 |
|
7992 |
%{ /* NOCONTEXT */ |
|
7993 |
||
616 | 7994 |
int ret, flags; |
7995 |
int savInt; |
|
7996 |
||
7997 |
#if defined(F_GETFL) && defined(F_SETFL) |
|
7998 |
# if defined(FNDELAY) |
|
7999 |
if (__isSmallInteger(fd)) { |
|
1135 | 8000 |
int f = __intVal(fd); |
8001 |
||
8002 |
flags = fcntl(f, F_GETFL, 0); |
|
616 | 8003 |
if (aBoolean == true) { |
1135 | 8004 |
ret = fcntl(f, F_SETFL, flags & ~FNDELAY); |
616 | 8005 |
} else { |
1135 | 8006 |
ret = fcntl(f, F_SETFL, flags | FNDELAY); |
185 | 8007 |
} |
616 | 8008 |
if (ret >= 0) ret = flags; |
1135 | 8009 |
RETURN ( __MKSMALLINT(ret) ); |
77 | 8010 |
} |
616 | 8011 |
# endif |
77 | 8012 |
#endif |
308 | 8013 |
%}. |
77 | 8014 |
" |
616 | 8015 |
fd argument not integer |
185 | 8016 |
" |
792 | 8017 |
^ self primitiveFailed |
1 | 8018 |
! |
8019 |
||
616 | 8020 |
writeCheck:fd |
8021 |
"return true, if filedescriptor can be written without blocking" |
|
8022 |
||
8023 |
(self selectOnAnyReadable:nil |
|
8024 |
writable:(Array with:fd) |
|
8025 |
exception:nil |
|
8026 |
withTimeOut:0) == fd |
|
8027 |
ifTrue:[^ true]. |
|
8028 |
^ false |
|
1 | 8029 |
! ! |
434 | 8030 |
|
1966
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8031 |
!OperatingSystem::OSProcessStatus class methodsFor:'documentation'! |
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 |
documentation |
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 |
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
|
8036 |
operating system processes (these are no smalltalk processes!!). |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8037 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8038 |
[Instance variables:] |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8039 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8040 |
pid <Integer> OS-Process identifier |
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 |
status <Symbol> either #exit #signal #stop #continue |
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 |
code <Integer> either exitcode or signalnumber |
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 |
core <Boolean> true if core has been dumped |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8047 |
|
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 |
[author:] |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8050 |
Stefan Vogel |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8051 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8052 |
[see also:] |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8053 |
OperatingSystem |
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 |
! ! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8056 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8057 |
!OperatingSystem::OSProcessStatus class methodsFor:'instance creation'! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8058 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8059 |
pid:pid status:status code:code core:core |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8060 |
"private interface for OperatingSystem" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8061 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8062 |
^ 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
|
8063 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8064 |
"Created: 28.12.1995 / 14:16:14 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8065 |
"Modified: 30.4.1996 / 18:25:00 / cg" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8066 |
! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8067 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8068 |
processCreationFailure |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8069 |
"private interface for OperatingSystem" |
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 |
^ 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
|
8072 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8073 |
"Created: 28.12.1995 / 14:35:29 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8074 |
"Modified: 30.4.1996 / 18:25:05 / cg" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8075 |
! ! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8076 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8077 |
!OperatingSystem::OSProcessStatus methodsFor:'accessing'! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8078 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8079 |
code |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8080 |
"return the exitcode / signalNumber" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8081 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8082 |
^ code |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8083 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8084 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8085 |
"Modified: 30.4.1996 / 18:26:23 / cg" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8086 |
! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8087 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8088 |
core |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8089 |
"return true if core has been dumped, false otherwise" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8090 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8091 |
^ core == true |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8092 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8093 |
"Modified: 28.12.1995 / 14:14:38 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8094 |
! |
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 |
pid |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8097 |
"return the pid" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8098 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8099 |
^ pid |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8100 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8101 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8102 |
"Modified: 30.4.1996 / 18:26:30 / cg" |
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 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8105 |
status |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8106 |
"return status as a Symbol; |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8107 |
one of #exit #signal #stop #continue" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8108 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8109 |
^ status |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8110 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8111 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8112 |
"Modified: 30.4.1996 / 18:26:54 / cg" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8113 |
! ! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8114 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8115 |
!OperatingSystem::OSProcessStatus methodsFor:'initialization'! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8116 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8117 |
pid:newPid status:newStatus code:newCode core:newCore |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8118 |
pid := newPid. |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8119 |
status := newStatus. |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8120 |
code := newCode. |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8121 |
core := newCore. |
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 |
"Created: 28.12.1995 / 14:18:22 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8124 |
! ! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8125 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8126 |
!OperatingSystem::OSProcessStatus methodsFor:'private-OS interface'! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8127 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8128 |
code:something |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8129 |
"set the exitCode" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8130 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8131 |
code := something. |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8132 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8133 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8134 |
"Modified: 30.4.1996 / 18:25:18 / cg" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8135 |
! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8136 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8137 |
core:something |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8138 |
"set core" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8139 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8140 |
core := something. |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8141 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8142 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8143 |
! |
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 |
pid:something |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8146 |
"set pid" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8147 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8148 |
pid := something. |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8149 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8150 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8151 |
! |
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:something |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8154 |
"set status" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8155 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8156 |
status := something. |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8157 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8158 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8159 |
! ! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8160 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8161 |
!OperatingSystem::OSProcessStatus methodsFor:'queries'! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8162 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8163 |
couldNotExecute |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8164 |
"return true when a command could not be executed" |
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 |
^ status == #exit and:[code = 127]. |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8167 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8168 |
"Created: 28.12.1995 / 15:43:17 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8169 |
"Modified: 30.4.1996 / 18:27:03 / cg" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8170 |
! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8171 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8172 |
stillAlive |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8173 |
"true if process is still alive" |
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 |
^ status == #stop or:[status == #continue] |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8176 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8177 |
"Created: 28.12.1995 / 14:27:26 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8178 |
! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8179 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8180 |
success |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8181 |
"true if process terminated successfully" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8182 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8183 |
^ status == #exit and:[code = 0] |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8184 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8185 |
"Created: 28.12.1995 / 14:13:05 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8186 |
"Modified: 28.12.1995 / 14:13:41 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8187 |
! ! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8188 |
|
2080
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8189 |
!OperatingSystem::FileStatusInfo class methodsFor:'instance creation'! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8190 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8191 |
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
|
8192 |
^ self basicNew |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8193 |
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
|
8194 |
! ! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8195 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8196 |
!OperatingSystem::FileStatusInfo methodsFor:'accessing'! |
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 |
accessed |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8199 |
"return accessed" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8200 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8201 |
^ accessed! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8202 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8203 |
gid |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8204 |
"return gid" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8205 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8206 |
^ gid! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8207 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8208 |
id |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8209 |
"return id" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8210 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8211 |
^ id! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8212 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8213 |
mode |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8214 |
"return mode" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8215 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8216 |
^ mode! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8217 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8218 |
modified |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8219 |
"return modified" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8220 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8221 |
^ modified! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8222 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8223 |
path |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8224 |
"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
|
8225 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8226 |
^ path |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8227 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8228 |
! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8229 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8230 |
size |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8231 |
"return size" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8232 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8233 |
^ size! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8234 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8235 |
statusChanged |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8236 |
"return statusChanged" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8237 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8238 |
^ statusChanged! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8239 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8240 |
type |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8241 |
"return type" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8242 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8243 |
^ type! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8244 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8245 |
uid |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8246 |
"return uid" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8247 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8248 |
^ uid! ! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8249 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8250 |
!OperatingSystem::FileStatusInfo methodsFor:'backward compatibility'! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8251 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8252 |
at:key |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8253 |
"backward compatibility access: in previous releases, IdentityDictionaries |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8254 |
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
|
8255 |
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
|
8256 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8257 |
^ self perform:key |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8258 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8259 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8260 |
! ! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8261 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8262 |
!OperatingSystem::FileStatusInfo methodsFor:'private accessing'! |
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 |
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
|
8265 |
type := t. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8266 |
mode := m. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8267 |
uid := u. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8268 |
gid := g. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8269 |
size := s. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8270 |
id := i. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8271 |
accessed := aT. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8272 |
modified := mT. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8273 |
statusChanged := sT. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8274 |
path := lP |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8275 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8276 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8277 |
! ! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8278 |
|
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
8279 |
!OperatingSystem class methodsFor:'documentation'! |
630 | 8280 |
|
8281 |
version |
|
2117
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
8282 |
^ '$Header: /cvs/stx/stx/libbasic/Attic/Unix.st,v 1.187 1997-01-10 11:20:24 cg Exp $' |
630 | 8283 |
! ! |
616 | 8284 |
OperatingSystem initialize! |