author | Claus Gittinger <cg@exept.de> |
Fri, 10 Jan 1997 16:23:40 +0100 | |
changeset 2126 | d3da2956f380 |
parent 2117 | 460b14a6db96 |
child 2131 | 1eeb310e109a |
permissions | -rw-r--r-- |
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 |
|
2126 | 444 |
#ifdef NEXT |
445 |
# define NO_WAITPID |
|
446 |
#endif |
|
1441 | 447 |
|
437 | 448 |
%} |
449 |
! ! |
|
450 |
||
451 |
!OperatingSystem primitiveFunctions! |
|
452 |
%{ |
|
453 |
||
454 |
/* |
|
455 |
* some systems' system() is broken in that it does not correctly |
|
456 |
* handle EINTR and returns failure even though it actually succeeded. |
|
457 |
* (LINUX is one of them) |
|
458 |
* Here is a fixed version. If you encounter EINTR returns from |
|
459 |
* OperatingSystem>>executeCommand, you ought to define WANT_SYSTEM |
|
460 |
* in the xxxIntern.h file to get this fixed version. |
|
461 |
* |
|
462 |
* As an added BONUS, this system() enables interrupts while waiting |
|
463 |
* for the child which enables other threads to continue. |
|
507
a7780fc27ee9
mad system interuptable (needs WANT_SYSTEM to be defined in xxxIntern.h)
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
464 |
* (i.e. it is RT safe) |
437 | 465 |
*/ |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
466 |
|
433 | 467 |
#if defined(WANT_SYSTEM) |
468 |
||
434 | 469 |
/* # define DPRINTF(x) printf x */ |
470 |
# define DPRINTF(x) /* nothing */ |
|
433 | 471 |
|
437 | 472 |
# ifndef _STDDEF_H_INCLUDED_ |
473 |
# include <stddef.h> |
|
474 |
# define _STDDEF_H_INCLUDED_ |
|
475 |
# endif |
|
476 |
||
477 |
# ifndef _STDLIB_H_INCLUDED_ |
|
478 |
# include <stdlib.h> |
|
479 |
# define _STDLIB_H_INCLUDED_ |
|
480 |
# endif |
|
481 |
||
482 |
# ifndef _UNISTD_H_INCLUDED_ |
|
483 |
# include <unistd.h> |
|
484 |
# define _UNISTD_H_INCLUDED_ |
|
485 |
# endif |
|
486 |
||
487 |
# ifndef _SYS_WAIT_H_INCLUDED |
|
488 |
# include <sys/wait.h> |
|
489 |
# define _SYS_WAIT_H_INCLUDED |
|
490 |
# endif |
|
491 |
||
492 |
# ifndef _SIGNAL_H_INCLUDED_ |
|
493 |
# include <signal.h> |
|
494 |
# define _SIGNAL_H_INCLUDED_ |
|
495 |
# endif |
|
496 |
||
497 |
# ifndef _SYS_TYPES_H_INCLUDED_ |
|
498 |
# include <sys/types.h> |
|
499 |
# define _SYS_TYPES_H_INCLUDED_ |
|
500 |
# endif |
|
433 | 501 |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
502 |
# if (!defined(HAVE_GNU_LD) && !defined (__ELF__)) || !defined(LINUX) |
433 | 503 |
# define __environ environ |
512 | 504 |
# if !defined(LINUX) |
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
505 |
# define __sigemptyset sigemptyset |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
506 |
# define __sigaction sigaction |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
507 |
# define __sigaddset sigaddset |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
508 |
# define __sigprocmask sigprocmask |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
509 |
# define __execve execve |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
510 |
# define __wait wait |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
511 |
# define __waitpid waitpid |
674 | 512 |
# if defined(HAS_VFORK) |
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
513 |
# define FORK vfork |
514
81fa80a953e2
system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents:
513
diff
changeset
|
514 |
# else |
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
515 |
# define FORK fork |
514
81fa80a953e2
system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents:
513
diff
changeset
|
516 |
# endif |
512 | 517 |
# endif /* ! LINUX */ |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
518 |
extern char **environ; |
433 | 519 |
# endif |
520 |
||
521 |
# define SHELL_PATH "/bin/sh" /* Path of the shell. */ |
|
522 |
# define SHELL_NAME "sh" /* Name to give it. */ |
|
523 |
||
524 |
# ifndef FORK |
|
525 |
# define FORK __fork |
|
526 |
# endif |
|
527 |
||
528 |
# ifndef CONST |
|
529 |
# ifdef __GNUC__ |
|
530 |
# define CONST const |
|
531 |
# else |
|
532 |
# define CONST /* nothing */ |
|
533 |
# endif |
|
534 |
# endif |
|
535 |
||
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
536 |
static int |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
537 |
mySystem(line) |
433 | 538 |
register CONST char *line; |
539 |
{ |
|
540 |
int status, save; |
|
541 |
pid_t pid; |
|
542 |
struct sigaction sa, intr, quit; |
|
543 |
sigset_t block, omask; |
|
544 |
||
545 |
if (line == NULL) |
|
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
546 |
return -1; |
433 | 547 |
|
548 |
sa.sa_handler = SIG_IGN; |
|
549 |
sa.sa_flags = 0; |
|
550 |
__sigemptyset (&sa.sa_mask); |
|
551 |
||
552 |
if (__sigaction (SIGINT, &sa, &intr) < 0) { |
|
553 |
DPRINTF(("1: errno=%d\n", errno)); |
|
554 |
return -1; |
|
555 |
} |
|
556 |
if (__sigaction (SIGQUIT, &sa, &quit) < 0) { |
|
557 |
save = errno; |
|
558 |
(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL); |
|
559 |
errno = save; |
|
560 |
DPRINTF(("2: errno=%d\n", errno)); |
|
561 |
return -1; |
|
562 |
} |
|
563 |
||
564 |
__sigemptyset (&block); |
|
565 |
__sigaddset (&block, SIGCHLD); |
|
566 |
save = errno; |
|
567 |
if (__sigprocmask(SIG_BLOCK, &block, &omask) < 0) { |
|
568 |
if (errno == ENOSYS) |
|
569 |
errno = save; |
|
570 |
else { |
|
571 |
save = errno; |
|
572 |
(void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL); |
|
573 |
(void) __sigaction(SIGQUIT, &quit, (struct sigaction *) NULL); |
|
574 |
errno = save; |
|
575 |
DPRINTF(("3: errno=%d\n", errno)); |
|
576 |
return -1; |
|
577 |
} |
|
578 |
} |
|
579 |
||
580 |
pid = FORK (); |
|
581 |
if (pid == (pid_t) 0) { |
|
582 |
/* Child side. */ |
|
583 |
CONST char *new_argv[4]; |
|
584 |
new_argv[0] = SHELL_NAME; |
|
585 |
new_argv[1] = "-c"; |
|
586 |
new_argv[2] = line; |
|
587 |
new_argv[3] = NULL; |
|
588 |
||
589 |
/* Restore the signals. */ |
|
590 |
(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL); |
|
591 |
(void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL); |
|
592 |
(void) __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL); |
|
593 |
||
594 |
/* Exec the shell. */ |
|
595 |
(void) __execve (SHELL_PATH, (char *CONST *) new_argv, __environ); |
|
596 |
_exit (127); |
|
597 |
} else { |
|
598 |
if (pid < (pid_t) 0) { |
|
599 |
/* The fork failed. */ |
|
600 |
DPRINTF(("4: errno=%d\n", errno)); |
|
601 |
status = -1; |
|
602 |
} else { |
|
603 |
/* Parent side. */ |
|
604 |
#ifdef NO_WAITPID |
|
605 |
pid_t child; |
|
606 |
||
607 |
do { |
|
805 | 608 |
__BEGIN_INTERRUPTABLE__ |
433 | 609 |
child = __wait (&status); |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
610 |
__END_INTERRUPTABLE__ |
805 | 611 |
if (child < 0 && errno != EINTR) { |
433 | 612 |
DPRINTF(("5: errno=%d\n", errno)); |
613 |
status = -1; |
|
614 |
break; |
|
615 |
} |
|
616 |
} while (child != pid); |
|
617 |
#else |
|
618 |
pid_t child; |
|
619 |
||
620 |
/* claus: the original did not care for EINTR here ... */ |
|
621 |
do { |
|
805 | 622 |
__BEGIN_INTERRUPTABLE__ |
433 | 623 |
child = __waitpid (pid, &status, 0); |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
624 |
__END_INTERRUPTABLE__ |
433 | 625 |
} while ((child != pid) && (errno == EINTR)); |
626 |
if (child != pid) { |
|
627 |
DPRINTF(("6: errno=%d\n", errno)); |
|
628 |
status = -1; |
|
629 |
} |
|
630 |
#endif /* NO_WAITPID */ |
|
631 |
} |
|
632 |
} |
|
633 |
save = errno; |
|
634 |
if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL) |
|
635 |
| __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL) |
|
636 |
| __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)) != 0) { |
|
637 |
if (errno == ENOSYS) { |
|
638 |
errno = save; |
|
639 |
} else { |
|
640 |
status = -1; |
|
641 |
DPRINTF(("7: errno=%d\n", errno)); |
|
642 |
} |
|
643 |
} |
|
644 |
||
645 |
return status; |
|
646 |
} |
|
1441 | 647 |
#else |
1487 | 648 |
# define __wait wait |
433 | 649 |
#endif /* WANT_SYSTEM */ |
650 |
||
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
651 |
|
433 | 652 |
/* |
653 |
* some systems do not have realpath(); |
|
654 |
* the alternative of reading from a 'pwp'-pipe |
|
655 |
* is way too slow. Here is a realpath for the rest of us. |
|
440 | 656 |
* define WANT_REALPATH in the xxxIntern-file to get it. |
433 | 657 |
*/ |
443 | 658 |
|
440 | 659 |
#if defined(HAS_REALPATH) |
660 |
# undef WANT_REALPATH |
|
661 |
#endif |
|
662 |
#if !defined(HAS_GETWD) && !defined(HAS_GETCWD) |
|
663 |
# undef WANT_REALPATH |
|
664 |
#endif |
|
665 |
||
666 |
#if defined(WANT_REALPATH) |
|
406 | 667 |
|
668 |
# ifndef NULL |
|
669 |
# define NULL (char *)0 |
|
670 |
# endif |
|
671 |
||
439 | 672 |
# define MAX_READLINKS 32 |
673 |
||
674 |
# ifndef MAXPATHLEN |
|
675 |
# define MAXPATHLEN 1024 |
|
676 |
# endif |
|
406 | 677 |
|
678 |
static |
|
679 |
char *realpath(path, resolved_path) |
|
680 |
char *path; |
|
681 |
char resolved_path []; |
|
682 |
{ |
|
683 |
char copy_path[MAXPATHLEN]; |
|
684 |
char link_path[MAXPATHLEN]; |
|
685 |
char *new_path = resolved_path; |
|
686 |
char *max_path; |
|
687 |
int readlinks = 0; |
|
688 |
int n; |
|
689 |
||
690 |
/* Make a copy of the source path since we may need to modify it. */ |
|
691 |
strcpy(copy_path, path); |
|
692 |
path = copy_path; |
|
693 |
max_path = copy_path + MAXPATHLEN - 2; |
|
694 |
/* If it's a relative pathname use getwd for starters. */ |
|
695 |
if (*path != '/') { |
|
696 |
#ifdef HAS_GETCWD |
|
697 |
getcwd(new_path, MAXPATHLEN - 1); |
|
698 |
#else |
|
699 |
getwd(new_path); |
|
700 |
#endif |
|
701 |
new_path += strlen(new_path); |
|
702 |
if (new_path[-1] != '/') |
|
703 |
*new_path++ = '/'; |
|
704 |
} |
|
705 |
else { |
|
706 |
*new_path++ = '/'; |
|
707 |
path++; |
|
708 |
} |
|
709 |
/* Expand each slash-separated pathname component. */ |
|
710 |
while (*path != '\0') { |
|
711 |
/* Ignore stray "/". */ |
|
712 |
if (*path == '/') { |
|
713 |
path++; |
|
714 |
continue; |
|
715 |
} |
|
716 |
if (*path == '.') { |
|
717 |
/* Ignore ".". */ |
|
718 |
if (path[1] == '\0' || path[1] == '/') { |
|
719 |
path++; |
|
720 |
continue; |
|
721 |
} |
|
722 |
if (path[1] == '.') { |
|
723 |
if (path[2] == '\0' || path[2] == '/') { |
|
724 |
path += 2; |
|
725 |
/* Ignore ".." at root. */ |
|
726 |
if (new_path == resolved_path + 1) |
|
727 |
continue; |
|
728 |
/* Handle ".." by backing up. */ |
|
729 |
while ((--new_path)[-1] != '/') |
|
730 |
; |
|
731 |
continue; |
|
732 |
} |
|
733 |
} |
|
734 |
} |
|
735 |
/* Safely copy the next pathname component. */ |
|
736 |
while (*path != '\0' && *path != '/') { |
|
737 |
if (path > max_path) { |
|
738 |
errno = ENAMETOOLONG; |
|
739 |
return NULL; |
|
740 |
} |
|
741 |
*new_path++ = *path++; |
|
742 |
} |
|
743 |
#ifdef S_IFLNK |
|
744 |
/* Protect against infinite loops. */ |
|
745 |
if (readlinks++ > MAX_READLINKS) { |
|
746 |
errno = ELOOP; |
|
747 |
return NULL; |
|
748 |
} |
|
749 |
/* See if latest pathname component is a symlink. */ |
|
750 |
*new_path = '\0'; |
|
751 |
n = readlink(resolved_path, link_path, MAXPATHLEN - 1); |
|
752 |
if (n < 0) { |
|
753 |
/* EINVAL means the file exists but isn't a symlink. */ |
|
754 |
if (errno != EINVAL) |
|
755 |
return NULL; |
|
756 |
} |
|
757 |
else { |
|
758 |
/* Note: readlink doesn't add the null byte. */ |
|
759 |
link_path[n] = '\0'; |
|
760 |
if (*link_path == '/') |
|
761 |
/* Start over for an absolute symlink. */ |
|
762 |
new_path = resolved_path; |
|
763 |
else |
|
764 |
/* Otherwise back up over this component. */ |
|
765 |
while (*(--new_path) != '/') |
|
766 |
; |
|
767 |
/* Safe sex check. */ |
|
768 |
if (strlen(path) + n >= MAXPATHLEN) { |
|
769 |
errno = ENAMETOOLONG; |
|
770 |
return NULL; |
|
771 |
} |
|
772 |
/* Insert symlink contents into path. */ |
|
773 |
strcat(link_path, path); |
|
774 |
strcpy(copy_path, link_path); |
|
775 |
path = copy_path; |
|
776 |
} |
|
777 |
#endif /* S_IFLNK */ |
|
778 |
*new_path++ = '/'; |
|
779 |
} |
|
780 |
/* Delete trailing slash but don't whomp a lone slash. */ |
|
781 |
if (new_path != resolved_path + 1 && new_path[-1] == '/') |
|
782 |
new_path--; |
|
783 |
/* Make sure it's null terminated. */ |
|
784 |
*new_path = '\0'; |
|
785 |
return resolved_path; |
|
786 |
} |
|
787 |
# define HAS_REALPATH |
|
788 |
#endif /* WANT_REALPATH && not HAS_REALPATH */ |
|
789 |
%} |
|
790 |
! ! |
|
791 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
792 |
!OperatingSystem class methodsFor:'documentation'! |
2 | 793 |
|
88 | 794 |
copyright |
795 |
" |
|
796 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
185 | 797 |
All Rights Reserved |
88 | 798 |
|
799 |
This software is furnished under a license and may be used |
|
800 |
only in accordance with the terms of that license and with the |
|
801 |
inclusion of the above copyright notice. This software may not |
|
802 |
be provided or otherwise made available to, or used by, any |
|
803 |
other person. No title to or ownership of the software is |
|
804 |
hereby transferred. |
|
805 |
" |
|
806 |
! |
|
807 |
||
2 | 808 |
documentation |
809 |
" |
|
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
810 |
this class realizes access to most (all ?) required operating system services; |
68 | 811 |
some of it is very specific for unix, so do not depend on |
1619 | 812 |
things available here in your applications |
813 |
- some may not be found in other OS's or be slightly different ... |
|
68 | 814 |
|
815 |
(On the other hand: I do not want to hide all features |
|
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
756
diff
changeset
|
816 |
from you - in some situations it MAY be interesting to be |
792 | 817 |
able to get down to a select or fork system call easily (at least on Unix systems). |
68 | 818 |
You decide - portability vs. functionality) |
819 |
||
1286 | 820 |
[Class variables:] |
821 |
||
1487 | 822 |
HostName <String> remembered hostname |
823 |
||
824 |
DomainName <String> remembered domainname |
|
825 |
||
826 |
LastErrorNumber <Integer> the last value of errno |
|
827 |
||
828 |
OSSignals <Array> Array of signals to be raised for corresponding |
|
829 |
OperatingSystem signals. |
|
830 |
||
831 |
ForkFailed <Boolean> set if a fork (or popen) has failed; |
|
832 |
ST/X will avoid doing more forks/popens |
|
833 |
if this flag is set, for a slightly |
|
834 |
smoother operation. |
|
835 |
||
836 |
SlowFork <Boolean> if set, fork and popen are avoided; |
|
837 |
(more or less obsolete now) |
|
838 |
||
839 |
||
840 |
ErrorSignal <Signal> Parentsignal of all OS error signals. |
|
841 |
not directly raised. |
|
842 |
||
843 |
AccessDeniedErrorSignal |
|
844 |
||
845 |
FileNotFoundErrorSignal |
|
846 |
||
847 |
LocaleInfo <Dictionary> if non nil, that is taken instead of the operating |
|
848 |
systems locale definitions (allows for overwriting |
|
849 |
these, or provide a compatible info on systems which do |
|
850 |
not support locales) |
|
1286 | 851 |
|
852 |
[author:] |
|
1487 | 853 |
Claus Gittinger |
1286 | 854 |
|
855 |
[see also:] |
|
1487 | 856 |
OSProcessStatus |
857 |
Filename Date Time |
|
858 |
ExternalStream FileStream PipeStream Socket |
|
2 | 859 |
" |
1619 | 860 |
! |
861 |
||
862 |
examples |
|
863 |
" |
|
1622 | 864 |
various queries |
1632 | 865 |
[exBegin] |
1622 | 866 |
Transcript |
1632 | 867 |
showCR:'hello ' , (OperatingSystem getLoginName) |
868 |
[exEnd] |
|
869 |
||
870 |
[exBegin] |
|
1622 | 871 |
OperatingSystem isUNIXlike ifTrue:[ |
1632 | 872 |
Transcript showCR:'this is some UNIX-like OS' |
1622 | 873 |
] ifFalse:[ |
1632 | 874 |
Transcript showCR:'this OS is not UNIX-like' |
1622 | 875 |
] |
1632 | 876 |
[exEnd] |
877 |
||
878 |
[exBegin] |
|
1622 | 879 |
Transcript |
1632 | 880 |
showCR:'this machine is called ' , OperatingSystem getHostName |
881 |
[exEnd] |
|
882 |
||
883 |
[exBegin] |
|
1622 | 884 |
Transcript |
1632 | 885 |
showCR:('this machine is in the ' |
886 |
, OperatingSystem getDomainName |
|
887 |
, ' domain') |
|
888 |
[exEnd] |
|
889 |
||
890 |
[exBegin] |
|
1622 | 891 |
Transcript |
1632 | 892 |
showCR:('this machine''s CPU is a ' |
893 |
, OperatingSystem getCPUType |
|
894 |
) |
|
895 |
[exEnd] |
|
896 |
||
897 |
[exBegin] |
|
1622 | 898 |
Transcript showCR:'executing ls command ...'. |
899 |
OperatingSystem executeCommand:'ls'. |
|
900 |
Transcript showCR:'... done.'. |
|
1632 | 901 |
[exEnd] |
1622 | 902 |
|
1621 | 903 |
locking a file |
904 |
(should be executed on two running smalltalks - not in two threads): |
|
1632 | 905 |
[exBegin] |
1621 | 906 |
|f| |
907 |
||
908 |
f := 'testFile' asFilename readWriteStream. |
|
909 |
||
910 |
10 timesRepeat:[ |
|
1632 | 911 |
'about to lock ...' printCR. |
912 |
[ |
|
913 |
OperatingSystem |
|
914 |
lockFD:(f fileDescriptor) |
|
915 |
shared:false |
|
916 |
blocking:false |
|
917 |
] whileFalse:[ |
|
918 |
'process ' print. OperatingSystem getProcessId print. ' is waiting' printCR. |
|
919 |
Delay waitForSeconds:1 |
|
920 |
]. |
|
921 |
'LOCKED ...' printCR. |
|
922 |
Delay waitForSeconds:10. |
|
923 |
'unlock ...' printCR. |
|
924 |
(OperatingSystem |
|
925 |
unlockFD:(f fileDescriptor)) printCR. |
|
926 |
Delay waitForSeconds:3. |
|
1621 | 927 |
] |
1632 | 928 |
[exBegin] |
1619 | 929 |
" |
2 | 930 |
! ! |
931 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
932 |
!OperatingSystem class methodsFor:'initialization'! |
95 | 933 |
|
934 |
initialize |
|
185 | 935 |
"initialize the class" |
936 |
||
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
937 |
ObjectMemory addDependent:self. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
938 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
939 |
ErrorSignal isNil ifTrue:[ |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
940 |
ErrorSignal := Object errorSignal newSignalMayProceed:true.. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
941 |
ErrorSignal nameClass:self message:#errorSignal. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
942 |
ErrorSignal notifierString:'OS error encountered'. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
943 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
944 |
AccessDeniedErrorSignal := ErrorSignal newSignalMayProceed:true. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
945 |
AccessDeniedErrorSignal nameClass:self message:#accessDeniedError. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
946 |
AccessDeniedErrorSignal notifierString:'OS access denied'. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
947 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
948 |
FileNotFoundErrorSignal := ErrorSignal newSignalMayProceed:true. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
949 |
FileNotFoundErrorSignal nameClass:self message:#fileNotFoundErrorSignal. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
950 |
FileNotFoundErrorSignal notifierString:'OS file not found'. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
951 |
] |
95 | 952 |
! |
953 |
||
1470 | 954 |
update:something with:aParameter from:changedObject |
1247 | 955 |
"catch image restart and flush some cached data" |
956 |
||
95 | 957 |
something == #earlyRestart ifTrue:[ |
1487 | 958 |
" |
959 |
flush cached data |
|
960 |
" |
|
961 |
HostName := nil. |
|
962 |
DomainName := nil. |
|
963 |
LastErrorNumber := nil. |
|
95 | 964 |
] |
1247 | 965 |
|
966 |
"Modified: 22.4.1996 / 13:10:43 / cg" |
|
1470 | 967 |
"Created: 15.6.1996 / 15:22:37 / cg" |
2080
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
968 |
"Modified: 7.1.1997 / 19:36:11 / stefan" |
95 | 969 |
! ! |
970 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
971 |
!OperatingSystem class methodsFor:'OS signal constants'! |
616 | 972 |
|
973 |
sigABRT |
|
974 |
"return the signal number for SIGABRT - 0 if not supported by OS |
|
975 |
(the numeric value is not the same across unix-systems)" |
|
976 |
||
977 |
%{ /* NOCONTEXT */ |
|
978 |
#ifdef SIGABRT |
|
1135 | 979 |
RETURN ( __MKSMALLINT(SIGABRT) ); |
616 | 980 |
#else |
1135 | 981 |
RETURN ( __MKSMALLINT(0) ); |
616 | 982 |
#endif |
983 |
%} |
|
984 |
! |
|
985 |
||
986 |
sigALRM |
|
987 |
"return the signal number for SIGALRM - 0 if not supported |
|
988 |
(the numeric value is not the same across unix-systems)" |
|
989 |
||
990 |
%{ /* NOCONTEXT */ |
|
991 |
#ifdef SIGALRM |
|
1135 | 992 |
RETURN ( __MKSMALLINT(SIGALRM) ); |
616 | 993 |
#else |
1135 | 994 |
RETURN ( __MKSMALLINT(0) ); |
616 | 995 |
#endif |
996 |
%} |
|
997 |
! |
|
998 |
||
831 | 999 |
sigBREAK |
1000 |
"return the signal number for SIGBREAK - 0 if not supported. |
|
1001 |
This is an MSDOS specific signal" |
|
1002 |
||
1003 |
%{ /* NOCONTEXT */ |
|
1004 |
#ifdef SIGBREAK |
|
1135 | 1005 |
RETURN ( __MKSMALLINT(SIGBREAK) ); |
831 | 1006 |
#else |
1135 | 1007 |
RETURN ( __MKSMALLINT(0) ); |
831 | 1008 |
#endif |
1009 |
%} |
|
1010 |
! |
|
1011 |
||
616 | 1012 |
sigBUS |
1013 |
"return the signal number for SIGBUS - 0 if not supported |
|
1014 |
(the numeric value is not the same across unix-systems)" |
|
1015 |
||
1016 |
%{ /* NOCONTEXT */ |
|
1017 |
#ifdef SIGBUS |
|
1135 | 1018 |
RETURN ( __MKSMALLINT(SIGBUS) ); |
616 | 1019 |
#else |
1135 | 1020 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1021 |
#endif |
1022 |
%} |
|
1023 |
! |
|
1024 |
||
1025 |
sigCHLD |
|
1026 |
"return the signal number for SIGCHLD - 0 if not supported |
|
1027 |
(the numeric value is not the same across unix-systems)" |
|
1028 |
||
1029 |
%{ /* NOCONTEXT */ |
|
1030 |
#if defined(SIGCHLD) |
|
1135 | 1031 |
RETURN ( __MKSMALLINT(SIGCHLD) ); |
616 | 1032 |
#else |
1033 |
# if defined(SIGCLD) |
|
1135 | 1034 |
RETURN ( __MKSMALLINT(SIGCLD) ); |
616 | 1035 |
# else |
1135 | 1036 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1037 |
# endif |
1038 |
#endif |
|
1039 |
%} |
|
1040 |
! |
|
1041 |
||
1042 |
sigCONT |
|
1043 |
"return the signal number for SIGCONT - 0 if not supported |
|
1044 |
(the numeric value is not the same across unix-systems)" |
|
1045 |
||
1046 |
%{ /* NOCONTEXT */ |
|
1047 |
#if defined(SIGCONT) |
|
1135 | 1048 |
RETURN ( __MKSMALLINT(SIGCONT) ); |
616 | 1049 |
#else |
1135 | 1050 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1051 |
#endif |
1052 |
%} |
|
1053 |
! |
|
1054 |
||
1055 |
sigDANGER |
|
1056 |
"return the signal number for SIGDANGER - 0 if not supported |
|
1057 |
(seems to be an AIX special)" |
|
1058 |
||
1059 |
%{ /* NOCONTEXT */ |
|
710 | 1060 |
#if defined(SIGDANGER) |
1135 | 1061 |
RETURN ( __MKSMALLINT(SIGDANGER) ); |
616 | 1062 |
#else |
1135 | 1063 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1064 |
#endif |
1065 |
%} |
|
1066 |
! |
|
1067 |
||
1068 |
sigEMT |
|
1069 |
"return the signal number for SIGEMT - 0 if not supported by OS |
|
1070 |
(the numeric value is not the same across unix-systems)" |
|
1071 |
||
1072 |
%{ /* NOCONTEXT */ |
|
1073 |
#ifdef SIGEMT |
|
1135 | 1074 |
RETURN ( __MKSMALLINT(SIGEMT) ); |
616 | 1075 |
#else |
1135 | 1076 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1077 |
#endif |
1078 |
%} |
|
1079 |
! |
|
1080 |
||
1081 |
sigFP |
|
1082 |
"return the signal number for SIGFP - 0 if not supported by OS |
|
1083 |
(the numeric value is not the same across unix-systems)" |
|
1084 |
||
1085 |
%{ /* NOCONTEXT */ |
|
1086 |
#ifdef SIGFPE |
|
1135 | 1087 |
RETURN ( __MKSMALLINT(SIGFPE) ); |
616 | 1088 |
#else |
1135 | 1089 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1090 |
#endif |
1091 |
%} |
|
1092 |
! |
|
1093 |
||
1094 |
sigGRANT |
|
1095 |
"return the signal number for SIGGRANT - 0 if not supported |
|
1096 |
(seems to be an AIX special)" |
|
1097 |
||
1098 |
%{ /* NOCONTEXT */ |
|
1099 |
#if defined(SIGGRANT) |
|
1135 | 1100 |
RETURN ( __MKSMALLINT(SIGGRANT) ); |
616 | 1101 |
#else |
1135 | 1102 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1103 |
#endif |
1104 |
%} |
|
1105 |
! |
|
1106 |
||
1107 |
sigHUP |
|
1108 |
"return the signal number for SIGHUP |
|
1109 |
(the numeric value is not the same across unix-systems)" |
|
1110 |
||
1111 |
%{ /* NOCONTEXT */ |
|
1112 |
#ifdef SIGHUP |
|
1135 | 1113 |
RETURN ( __MKSMALLINT(SIGHUP) ); |
616 | 1114 |
#else |
1135 | 1115 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1116 |
#endif |
1117 |
%} |
|
1118 |
! |
|
1119 |
||
1120 |
sigILL |
|
1121 |
"return the signal number for SIGILL - 0 if not supported by OS |
|
1122 |
(the numeric value is not the same across unix-systems)" |
|
1123 |
||
1124 |
%{ /* NOCONTEXT */ |
|
1125 |
#ifdef SIGILL |
|
1135 | 1126 |
RETURN ( __MKSMALLINT(SIGILL) ); |
616 | 1127 |
#else |
1135 | 1128 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1129 |
#endif |
1130 |
%} |
|
1131 |
! |
|
1132 |
||
1133 |
sigINT |
|
1134 |
"return the signal number for SIGINT |
|
1135 |
(the numeric value is not the same across unix-systems)" |
|
1136 |
||
1137 |
%{ /* NOCONTEXT */ |
|
1138 |
#ifdef SIGINT |
|
1135 | 1139 |
RETURN ( __MKSMALLINT(SIGINT) ); |
616 | 1140 |
#else |
1135 | 1141 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1142 |
#endif |
1143 |
%} |
|
1144 |
! |
|
1145 |
||
1146 |
sigIO |
|
1147 |
"return the signal number for SIGIO - 0 if not supported |
|
1148 |
(the numeric value is not the same across unix-systems)" |
|
1149 |
||
1150 |
%{ /* NOCONTEXT */ |
|
1151 |
#if defined(SIGIO) |
|
1135 | 1152 |
RETURN ( __MKSMALLINT(SIGIO) ); |
616 | 1153 |
#else |
1135 | 1154 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1155 |
#endif |
1156 |
%} |
|
1157 |
! |
|
1158 |
||
1159 |
sigIOT |
|
1160 |
"return the signal number for SIGIOT - 0 if not supported by OS |
|
1161 |
(the numeric value is not the same across unix-systems)" |
|
1162 |
||
1163 |
%{ /* NOCONTEXT */ |
|
1164 |
#ifdef SIGIOT |
|
1135 | 1165 |
RETURN ( __MKSMALLINT(SIGIOT) ); |
616 | 1166 |
#else |
1135 | 1167 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1168 |
#endif |
1169 |
%} |
|
1170 |
! |
|
1171 |
||
1172 |
sigKILL |
|
1173 |
"return the signal number for SIGKILL |
|
1174 |
(the numeric value is not the same across unix-systems)" |
|
1175 |
||
1176 |
%{ /* NOCONTEXT */ |
|
1177 |
#ifdef SIGKILL |
|
1135 | 1178 |
RETURN ( __MKSMALLINT(SIGKILL) ); |
616 | 1179 |
#else |
1135 | 1180 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1181 |
#endif |
1182 |
%} |
|
1183 |
! |
|
1184 |
||
1185 |
sigLOST |
|
1186 |
"return the signal number for SIGLOST - 0 if not supported |
|
1187 |
(the numeric value is not the same across unix-systems)" |
|
1188 |
||
1189 |
%{ /* NOCONTEXT */ |
|
1190 |
#if defined(SIGLOST) |
|
1135 | 1191 |
RETURN ( __MKSMALLINT(SIGLOST) ); |
616 | 1192 |
#else |
1135 | 1193 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1194 |
#endif |
1195 |
%} |
|
1196 |
! |
|
1197 |
||
1198 |
sigMIGRATE |
|
1199 |
"return the signal number for SIGMIGRATE - 0 if not supported |
|
1200 |
(seems to be an AIX special)" |
|
1201 |
||
1202 |
%{ /* NOCONTEXT */ |
|
1203 |
#if defined(SIGMIGRATE) |
|
1135 | 1204 |
RETURN ( __MKSMALLINT(SIGMIGRATE) ); |
616 | 1205 |
#else |
1135 | 1206 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1207 |
#endif |
1208 |
%} |
|
1209 |
! |
|
1210 |
||
1211 |
sigMSG |
|
1212 |
"return the signal number for SIGMSG - 0 if not supported |
|
1213 |
(seems to be an AIX special)" |
|
1214 |
||
1215 |
%{ /* NOCONTEXT */ |
|
1216 |
#if defined(SIGMSG) |
|
1135 | 1217 |
RETURN ( __MKSMALLINT(SIGMSG) ); |
616 | 1218 |
#else |
1135 | 1219 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1220 |
#endif |
1221 |
%} |
|
1222 |
! |
|
1223 |
||
1224 |
sigPIPE |
|
1225 |
"return the signal number for SIGPIPE - 0 if not supported |
|
1226 |
(the numeric value is not the same across unix-systems)" |
|
1227 |
||
1228 |
%{ /* NOCONTEXT */ |
|
1229 |
#ifdef SIGPIPE |
|
1135 | 1230 |
RETURN ( __MKSMALLINT(SIGPIPE) ); |
616 | 1231 |
#else |
1135 | 1232 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1233 |
#endif |
1234 |
%} |
|
1235 |
! |
|
1236 |
||
1237 |
sigPOLL |
|
1238 |
"return the signal number for SIGPOLL - 0 if not supported |
|
1239 |
(the numeric value is not the same across unix-systems)" |
|
1240 |
||
1241 |
%{ /* NOCONTEXT */ |
|
1242 |
#if defined(SIGPOLL) |
|
1135 | 1243 |
RETURN ( __MKSMALLINT(SIGPOLL) ); |
616 | 1244 |
#else |
1135 | 1245 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1246 |
#endif |
1247 |
%} |
|
1248 |
! |
|
1249 |
||
1250 |
sigPRE |
|
1251 |
"return the signal number for SIGPRE - 0 if not supported |
|
1252 |
(seems to be an AIX special)" |
|
1253 |
||
1254 |
%{ /* NOCONTEXT */ |
|
1255 |
#if defined(SIGPRE) |
|
1135 | 1256 |
RETURN ( __MKSMALLINT(SIGPRE) ); |
616 | 1257 |
#else |
1135 | 1258 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1259 |
#endif |
1260 |
%} |
|
1261 |
! |
|
1262 |
||
1263 |
sigPROF |
|
1264 |
"return the signal number for SIGPROF - 0 if not supported |
|
1265 |
(the numeric value is not the same across unix-systems)" |
|
1266 |
||
1267 |
%{ /* NOCONTEXT */ |
|
1268 |
#if defined(SIGPROF) |
|
1135 | 1269 |
RETURN ( __MKSMALLINT(SIGPROF) ); |
616 | 1270 |
#else |
1135 | 1271 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1272 |
#endif |
1273 |
%} |
|
1274 |
! |
|
1275 |
||
1276 |
sigPWR |
|
1277 |
"return the signal number for SIGPWR - 0 if not supported |
|
1278 |
(not available on all systems)" |
|
1279 |
||
1280 |
%{ /* NOCONTEXT */ |
|
1281 |
#if defined(SIGPWR) |
|
1135 | 1282 |
RETURN ( __MKSMALLINT(SIGPWR) ); |
616 | 1283 |
#else |
1135 | 1284 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1285 |
#endif |
1286 |
%} |
|
1287 |
! |
|
1288 |
||
1289 |
sigQUIT |
|
1290 |
"return the signal number for SIGQUIT |
|
1291 |
(the numeric value is not the same across unix-systems)" |
|
1292 |
||
1293 |
%{ /* NOCONTEXT */ |
|
1294 |
#ifdef SIGQUIT |
|
1135 | 1295 |
RETURN ( __MKSMALLINT(SIGQUIT) ); |
616 | 1296 |
#else |
1135 | 1297 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1298 |
#endif |
1299 |
%} |
|
1300 |
! |
|
1301 |
||
1302 |
sigRETRACT |
|
1303 |
"return the signal number for SIGRETRACT - 0 if not supported |
|
1304 |
(seems to be an AIX special)" |
|
1305 |
||
1306 |
%{ /* NOCONTEXT */ |
|
1307 |
#if defined(SIGRETRACT) |
|
1135 | 1308 |
RETURN ( __MKSMALLINT(SIGRETRACT) ); |
616 | 1309 |
#else |
1135 | 1310 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1311 |
#endif |
1312 |
%} |
|
1313 |
! |
|
1314 |
||
1315 |
sigSAK |
|
1316 |
"return the signal number for SIGSAK - 0 if not supported |
|
1317 |
(seems to be an AIX special)" |
|
1318 |
||
1319 |
%{ /* NOCONTEXT */ |
|
1320 |
#if defined(SIGSAK) |
|
1135 | 1321 |
RETURN ( __MKSMALLINT(SIGSAK) ); |
616 | 1322 |
#else |
1135 | 1323 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1324 |
#endif |
1325 |
%} |
|
1326 |
! |
|
1327 |
||
1328 |
sigSEGV |
|
1329 |
"return the signal number for SIGSEGV - 0 if not supported |
|
1330 |
(the numeric value is not the same across unix-systems)" |
|
1331 |
||
1332 |
%{ /* NOCONTEXT */ |
|
1333 |
#ifdef SIGSEGV |
|
1135 | 1334 |
RETURN ( __MKSMALLINT(SIGSEGV) ); |
616 | 1335 |
#else |
1135 | 1336 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1337 |
#endif |
1338 |
%} |
|
1339 |
! |
|
1340 |
||
1341 |
sigSOUND |
|
1342 |
"return the signal number for SIGSOUND - 0 if not supported |
|
1343 |
(seems to be an AIX special)" |
|
1344 |
||
1345 |
%{ /* NOCONTEXT */ |
|
1346 |
#if defined(SIGSOUND) |
|
1135 | 1347 |
RETURN ( __MKSMALLINT(SIGSOUND) ); |
616 | 1348 |
#else |
1135 | 1349 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1350 |
#endif |
1351 |
%} |
|
1352 |
! |
|
1353 |
||
1354 |
sigSTOP |
|
1355 |
"return the signal number for SIGSTOP - 0 if not supported |
|
1356 |
(the numeric value is not the same across unix-systems)" |
|
1357 |
||
1358 |
%{ /* NOCONTEXT */ |
|
1359 |
#if defined(SIGSTOP) |
|
1135 | 1360 |
RETURN ( __MKSMALLINT(SIGSTOP) ); |
616 | 1361 |
#else |
1135 | 1362 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1363 |
#endif |
1364 |
%} |
|
1365 |
! |
|
1366 |
||
1367 |
sigSYS |
|
1368 |
"return the signal number for SIGSYS - 0 if not supported |
|
1369 |
(the numeric value is not the same across unix-systems)" |
|
1370 |
||
1371 |
%{ /* NOCONTEXT */ |
|
1372 |
#ifdef SIGSYS |
|
1135 | 1373 |
RETURN ( __MKSMALLINT(SIGSYS) ); |
616 | 1374 |
#else |
1135 | 1375 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1376 |
#endif |
1377 |
%} |
|
1378 |
! |
|
1379 |
||
1380 |
sigTERM |
|
1381 |
"return the signal number for SIGTERM - 0 if not supported |
|
1382 |
(the numeric value is not the same across unix-systems)" |
|
1383 |
||
1384 |
%{ /* NOCONTEXT */ |
|
1385 |
#ifdef SIGTERM |
|
1135 | 1386 |
RETURN ( __MKSMALLINT(SIGTERM) ); |
616 | 1387 |
#else |
1135 | 1388 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1389 |
#endif |
1390 |
%} |
|
1391 |
! |
|
1392 |
||
1393 |
sigTRAP |
|
1394 |
"return the signal number for SIGTRAP - 0 if not supported by OS |
|
1395 |
(the numeric value is not the same across unix-systems)" |
|
1396 |
||
1397 |
%{ /* NOCONTEXT */ |
|
1398 |
#ifdef SIGTRAP |
|
1135 | 1399 |
RETURN ( __MKSMALLINT(SIGTRAP) ); |
616 | 1400 |
#else |
1135 | 1401 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1402 |
#endif |
1403 |
%} |
|
1404 |
! |
|
1405 |
||
1406 |
sigTSTP |
|
1407 |
"return the signal number for SIGTSTP - 0 if not supported |
|
1408 |
(the numeric value is not the same across unix-systems)" |
|
1409 |
||
1410 |
%{ /* NOCONTEXT */ |
|
1411 |
#if defined(SIGTSTP) |
|
1135 | 1412 |
RETURN ( __MKSMALLINT(SIGTSTP) ); |
616 | 1413 |
#else |
1135 | 1414 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1415 |
#endif |
1416 |
%} |
|
1417 |
! |
|
1418 |
||
1419 |
sigTTIN |
|
1420 |
"return the signal number for SIGTTIN - 0 if not supported |
|
1421 |
(the numeric value is not the same across unix-systems)" |
|
1422 |
||
1423 |
%{ /* NOCONTEXT */ |
|
1424 |
#if defined(SIGTTIN) |
|
1135 | 1425 |
RETURN ( __MKSMALLINT(SIGTTIN) ); |
616 | 1426 |
#else |
1135 | 1427 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1428 |
#endif |
1429 |
%} |
|
1430 |
! |
|
1431 |
||
1432 |
sigTTOU |
|
1433 |
"return the signal number for SIGTTOU - 0 if not supported |
|
1434 |
(the numeric value is not the same across unix-systems)" |
|
1435 |
||
1436 |
%{ /* NOCONTEXT */ |
|
1437 |
#if defined(SIGTTOU) |
|
1135 | 1438 |
RETURN ( __MKSMALLINT(SIGTTOU) ); |
616 | 1439 |
#else |
1135 | 1440 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1441 |
#endif |
1442 |
%} |
|
1443 |
! |
|
1444 |
||
1445 |
sigURG |
|
1446 |
"return the signal number for SIGURG - 0 if not supported |
|
1447 |
(the numeric value is not the same across unix-systems)" |
|
1448 |
||
1449 |
%{ /* NOCONTEXT */ |
|
1450 |
#if defined(SIGURG) |
|
1135 | 1451 |
RETURN ( __MKSMALLINT(SIGURG) ); |
616 | 1452 |
#else |
1135 | 1453 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1454 |
#endif |
1455 |
%} |
|
1456 |
! |
|
1457 |
||
1458 |
sigUSR1 |
|
1459 |
"return the signal number for SIGUSR1 - 0 if not supported |
|
1460 |
(the numeric value is not the same across unix-systems)" |
|
1461 |
||
1462 |
%{ /* NOCONTEXT */ |
|
1463 |
#if defined(SIGUSR1) |
|
1135 | 1464 |
RETURN ( __MKSMALLINT(SIGUSR1) ); |
616 | 1465 |
#else |
1135 | 1466 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1467 |
#endif |
1468 |
%} |
|
1469 |
! |
|
1470 |
||
1471 |
sigUSR2 |
|
1472 |
"return the signal number for SIGUSR2 - 0 if not supported |
|
1473 |
(the numeric value is not the same across unix-systems)" |
|
1474 |
||
1475 |
%{ /* NOCONTEXT */ |
|
1476 |
#if defined(SIGUSR2) |
|
1135 | 1477 |
RETURN ( __MKSMALLINT(SIGUSR2) ); |
616 | 1478 |
#else |
1135 | 1479 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1480 |
#endif |
1481 |
%} |
|
1482 |
! |
|
1483 |
||
1484 |
sigVTALRM |
|
1485 |
"return the signal number for SIGVTALRM - 0 if not supported |
|
1486 |
(the numeric value is not the same across unix-systems)" |
|
1487 |
||
1488 |
%{ /* NOCONTEXT */ |
|
1489 |
#if defined(SIGVTALRM) |
|
1135 | 1490 |
RETURN ( __MKSMALLINT(SIGVTALRM) ); |
616 | 1491 |
#else |
1135 | 1492 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1493 |
#endif |
1494 |
%} |
|
1495 |
! |
|
1496 |
||
1497 |
sigWINCH |
|
1498 |
"return the signal number for SIGWINCH - 0 if not supported |
|
1499 |
(the numeric value is not the same across unix-systems)" |
|
1500 |
||
1501 |
%{ /* NOCONTEXT */ |
|
1502 |
#if defined(SIGWINCH) |
|
1135 | 1503 |
RETURN ( __MKSMALLINT(SIGWINCH) ); |
616 | 1504 |
#else |
1135 | 1505 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1506 |
#endif |
1507 |
%} |
|
1508 |
! |
|
1509 |
||
1510 |
sigXCPU |
|
1511 |
"return the signal number for SIGXCPU - 0 if not supported |
|
1512 |
(the numeric value is not the same across unix-systems)" |
|
1513 |
||
1514 |
%{ /* NOCONTEXT */ |
|
1515 |
#if defined(SIGXCPU) |
|
1135 | 1516 |
RETURN ( __MKSMALLINT(SIGXCPU) ); |
616 | 1517 |
#else |
1135 | 1518 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1519 |
#endif |
1520 |
%} |
|
1521 |
! |
|
1522 |
||
1523 |
sigXFSZ |
|
1524 |
"return the signal number for SIGXFSZ - 0 if not supported |
|
1525 |
(the numeric value is not the same across unix-systems)" |
|
1526 |
||
1527 |
%{ /* NOCONTEXT */ |
|
1528 |
#if defined(SIGXFSZ) |
|
1135 | 1529 |
RETURN ( __MKSMALLINT(SIGXFSZ) ); |
616 | 1530 |
#else |
1135 | 1531 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1532 |
#endif |
1533 |
%} |
|
1534 |
! ! |
|
1535 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
1536 |
!OperatingSystem class methodsFor:'Signal constants'! |
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1537 |
|
616 | 1538 |
accessDeniedErrorSignal |
1539 |
"return the signal raised when a (file-) access is denied." |
|
1540 |
||
1541 |
^ AccessDeniedErrorSignal |
|
1542 |
! |
|
1543 |
||
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1544 |
errorSignal |
1247 | 1545 |
"return the parent signal of all OS signals." |
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1546 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1547 |
^ ErrorSignal |
1247 | 1548 |
|
1549 |
"Modified: 22.4.1996 / 13:11:31 / cg" |
|
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1550 |
! |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1551 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1552 |
fileNotFoundErrorSignal |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1553 |
"return the signal raised when a file was not found." |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1554 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1555 |
^ FileNotFoundErrorSignal |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1556 |
! ! |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1557 |
|
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
1558 |
!OperatingSystem class methodsFor:'error messages'! |
1 | 1559 |
|
1153
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1560 |
clearLastErrorNumber |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1561 |
"return the last errors number. |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1562 |
See also: #lastErrorSymbol and #lastErrorString. |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1563 |
Notice: having a single error number is a bad idea in a multithreaded |
1487 | 1564 |
environment - this interface will change." |
1153
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1565 |
|
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1566 |
LastErrorNumber := nil. |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1567 |
|
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1568 |
" |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1569 |
OperatingSystem clearLastErrorNumber |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1570 |
" |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1571 |
|
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1572 |
"Created: 12.4.1996 / 09:28:58 / stefan" |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1573 |
"Modified: 12.4.1996 / 09:38:51 / stefan" |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1574 |
! |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1575 |
|
85 | 1576 |
currentErrorNumber |
68 | 1577 |
"returns the OS's last error nr (i.e. the value of errno). |
1578 |
Notice, that the value of this flag is only valid immediately |
|
1579 |
after the error occurred - it gets updated with every other |
|
85 | 1580 |
request to the OS. |
1581 |
Use lastErrorNumber - currentErrorNumber is invalidated by |
|
1582 |
many, many internal calls." |
|
68 | 1583 |
|
1584 |
%{ /* NOCONTEXT */ |
|
1585 |
||
1135 | 1586 |
RETURN ( __MKSMALLINT(errno) ); |
68 | 1587 |
%} |
1588 |
" |
|
85 | 1589 |
OperatingSystem currentErrorNumber |
1590 |
" |
|
1591 |
! |
|
1592 |
||
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1593 |
errorNumberFor:aSymbol |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1594 |
"given a symbolic error, return the numeric; |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1595 |
(i.e. errorNumberFor:#EBADF returns EBADF's value). |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1596 |
Use this, since error numbers are really not standard across unix systems." |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1597 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1598 |
%{ /* NOCONTEXT */ |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1599 |
OBJ sym = aSymbol; |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1600 |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1601 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1602 |
* POSIX errnos - these should be defined |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1603 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1604 |
#ifdef EPERM |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1605 |
if (sym == @symbol(EPERM)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1606 |
RETURN ( __MKSMALLINT(EPERM) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1607 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1608 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1609 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1610 |
#ifdef ENOENT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1611 |
if (sym == @symbol(ENOENT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1612 |
RETURN ( __MKSMALLINT(ENOENT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1613 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1614 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1615 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1616 |
#ifdef ESRCH |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1617 |
if (sym == @symbol(ESRCH)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1618 |
RETURN ( __MKSMALLINT(ESRCH) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1619 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1620 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1621 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1622 |
#ifdef EINTR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1623 |
if (sym == @symbol(EINTR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1624 |
RETURN ( __MKSMALLINT(EINTR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1625 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1626 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1627 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1628 |
#ifdef EIO |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1629 |
if (sym == @symbol(EIO)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1630 |
RETURN ( __MKSMALLINT(EIO) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1631 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1632 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1633 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1634 |
#ifdef ENXIO |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1635 |
if (sym == @symbol(ENXIO)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1636 |
RETURN ( __MKSMALLINT(ENXIO) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1637 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1638 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1639 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1640 |
#ifdef E2BIG |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1641 |
if (sym == @symbol(E2BIG)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1642 |
RETURN ( __MKSMALLINT(E2BIG) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1643 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1644 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1645 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1646 |
#ifdef ENOEXEC |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1647 |
if (sym == @symbol(ENOEXEC)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1648 |
RETURN ( __MKSMALLINT(ENOEXEC) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1649 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1650 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1651 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1652 |
#ifdef EBADF |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1653 |
if (sym == @symbol(EBADF)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1654 |
RETURN ( __MKSMALLINT(EBADF) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1655 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1656 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1657 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1658 |
#ifdef ECHILD |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1659 |
if (sym == @symbol(ECHILD)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1660 |
RETURN ( __MKSMALLINT(ECHILD) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1661 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1662 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1663 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1664 |
#if defined(EAGAIN) |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1665 |
if (sym == @symbol(EAGAIN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1666 |
RETURN ( __MKSMALLINT(EAGAIN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1667 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1668 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1669 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1670 |
#ifdef ENOMEM |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1671 |
if (sym == @symbol(ENOMEM)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1672 |
RETURN ( __MKSMALLINT(ENOMEM) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1673 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1674 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1675 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1676 |
#ifdef EACCES |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1677 |
if (sym == @symbol(EACCES)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1678 |
RETURN ( __MKSMALLINT(EACCES) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1679 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1680 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1681 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1682 |
#ifdef EFAULT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1683 |
if (sym == @symbol(EFAULT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1684 |
RETURN ( __MKSMALLINT(EFAULT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1685 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1686 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1687 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1688 |
#ifdef EBUSY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1689 |
if (sym == @symbol(EBUSY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1690 |
RETURN ( __MKSMALLINT(EBUSY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1691 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1692 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1693 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1694 |
#ifdef EXDEV |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1695 |
if (sym == @symbol(EXDEV)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1696 |
RETURN ( __MKSMALLINT(EXDEV) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1697 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1698 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1699 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1700 |
#ifdef ENODEV |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1701 |
if (sym == @symbol(ENODEV)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1702 |
RETURN ( __MKSMALLINT(ENODEV) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1703 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1704 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1705 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1706 |
#ifdef ENOTDIR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1707 |
if (sym == @symbol(ENOTDIR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1708 |
RETURN ( __MKSMALLINT(ENOTDIR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1709 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1710 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1711 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1712 |
#ifdef EISDIR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1713 |
if (sym == @symbol(EISDIR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1714 |
RETURN ( __MKSMALLINT(EISDIR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1715 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1716 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1717 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1718 |
#ifdef EINVAL |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1719 |
if (sym == @symbol(EINVAL)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1720 |
RETURN ( __MKSMALLINT(EINVAL) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1721 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1722 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1723 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1724 |
#ifdef ENFILE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1725 |
if (sym == @symbol(ENFILE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1726 |
RETURN ( __MKSMALLINT(ENFILE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1727 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1728 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1729 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1730 |
#ifdef EMFILE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1731 |
if (sym == @symbol(EMFILE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1732 |
RETURN ( __MKSMALLINT(EMFILE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1733 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1734 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1735 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1736 |
#ifdef ENOTTY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1737 |
if (sym == @symbol(ENOTTY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1738 |
RETURN ( __MKSMALLINT(ENOTTY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1739 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1740 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1741 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1742 |
#ifdef EFBIG |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1743 |
if (sym == @symbol(EFBIG)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1744 |
RETURN ( __MKSMALLINT(EFBIG) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1745 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1746 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1747 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1748 |
#ifdef ENOSPC |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1749 |
if (sym == @symbol(ENOSPC)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1750 |
RETURN ( __MKSMALLINT(ENOSPC) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1751 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1752 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1753 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1754 |
#ifdef ESPIPE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1755 |
if (sym == @symbol(ESPIPE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1756 |
RETURN ( __MKSMALLINT(ESPIPE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1757 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1758 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1759 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1760 |
#ifdef EROFS |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1761 |
if (sym == @symbol(EROFS)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1762 |
RETURN ( __MKSMALLINT(EROFS) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1763 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1764 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1765 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1766 |
#ifdef EMLINK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1767 |
if (sym == @symbol(EMLINK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1768 |
RETURN ( __MKSMALLINT(EMLINK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1769 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1770 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1771 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1772 |
#ifdef EPIPE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1773 |
if (sym == @symbol(EPIPE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1774 |
RETURN ( __MKSMALLINT(EPIPE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1775 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1776 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1777 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1778 |
#ifdef EDOM |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1779 |
if (sym == @symbol(EDOM)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1780 |
RETURN ( __MKSMALLINT(EDOM) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1781 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1782 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1783 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1784 |
#ifdef ERANGE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1785 |
if (sym == @symbol(ERANGE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1786 |
RETURN ( __MKSMALLINT(ERANGE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1787 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1788 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1789 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1790 |
#ifdef EDEADLK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1791 |
if (sym == @symbol(EDEADLK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1792 |
RETURN ( __MKSMALLINT(EDEADLK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1793 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1794 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1795 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1796 |
#ifdef ENAMETOOLONG |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1797 |
if (sym == @symbol(ENAMETOOLONG)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1798 |
RETURN ( __MKSMALLINT(ENAMETOOLONG) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1799 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1800 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1801 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1802 |
#ifdef ENOLCK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1803 |
if (sym == @symbol(ENOLCK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1804 |
RETURN ( __MKSMALLINT(ENOLCK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1805 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1806 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1807 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1808 |
#ifdef ENOSYS |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1809 |
if (sym == @symbol(ENOSYS)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1810 |
RETURN ( __MKSMALLINT(ENOSYS) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1811 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1812 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1813 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1814 |
#ifdef ENOTEMPTY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1815 |
if (sym == @symbol(ENOTEMPTY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1816 |
RETURN ( __MKSMALLINT(ENOTEMPTY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1817 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1818 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1819 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1820 |
#ifdef EEXIST |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1821 |
if (sym == @symbol(EEXIST)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1822 |
RETURN ( __MKSMALLINT(EEXIST) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1823 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1824 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1825 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1826 |
#ifdef EILSEQ |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1827 |
if (sym == @symbol(EILSEQ)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1828 |
RETURN ( __MKSMALLINT(EILSEQ) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1829 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1830 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1831 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1832 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1833 |
* XPG3 errnos - defined on most systems |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1834 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1835 |
#ifdef ENOTBLK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1836 |
if (sym == @symbol(ENOTBLK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1837 |
RETURN ( __MKSMALLINT(ENOTBLK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1838 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1839 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1840 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1841 |
#ifdef ETXTBSY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1842 |
if (sym == @symbol(ETXTBSY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1843 |
RETURN ( __MKSMALLINT(ETXTBSY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1844 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1845 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1846 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1847 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1848 |
* some others |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1849 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1850 |
#ifdef EWOULDBLOCK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1851 |
if (sym == @symbol(EWOULDBLOCK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1852 |
RETURN ( __MKSMALLINT(EWOULDBLOCK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1853 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1854 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1855 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1856 |
#ifdef ENOMSG |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1857 |
if (sym == @symbol(ENOMSG)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1858 |
RETURN ( __MKSMALLINT(ENOMSG) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1859 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1860 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1861 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1862 |
#ifdef ELOOP |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1863 |
if (sym == @symbol(ELOOP)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1864 |
RETURN ( __MKSMALLINT(ELOOP) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1865 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1866 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1867 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1868 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1869 |
* some stream errors |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1870 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1871 |
#ifdef ETIME |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1872 |
if (sym == @symbol(ETIME)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1873 |
RETURN ( __MKSMALLINT(ETIME) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1874 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1875 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1876 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1877 |
#ifdef ENOSR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1878 |
if (sym == @symbol(ENOSR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1879 |
RETURN ( __MKSMALLINT(ENOSR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1880 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1881 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1882 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1883 |
#ifdef ENOSTR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1884 |
if (sym == @symbol(ENOSTR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1885 |
RETURN ( __MKSMALLINT(ENOSTR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1886 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1887 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1888 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1889 |
#ifdef ECOMM |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1890 |
if (sym == @symbol(ECOMM)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1891 |
RETURN ( __MKSMALLINT(ECOMM) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1892 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1893 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1894 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1895 |
#ifdef EPROTO |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1896 |
if (sym == @symbol(EPROTO)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1897 |
RETURN ( __MKSMALLINT(EPROTO) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1898 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1899 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1900 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1901 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1902 |
* nfs errors |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1903 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1904 |
#ifdef ESTALE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1905 |
if (sym == @symbol(ESTALE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1906 |
RETURN ( __MKSMALLINT(ESTALE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1907 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1908 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1909 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1910 |
#ifdef EREMOTE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1911 |
if (sym == @symbol(EREMOTE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1912 |
RETURN ( __MKSMALLINT(EREMOTE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1913 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1914 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1915 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1916 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1917 |
* some networking errors |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1918 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1919 |
#ifdef EINPROGRESS |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1920 |
if (sym == @symbol(EINPROGRESS)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1921 |
RETURN ( __MKSMALLINT(EINPROGRESS) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1922 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1923 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1924 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1925 |
#ifdef EALREADY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1926 |
if (sym == @symbol(EALREADY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1927 |
RETURN ( __MKSMALLINT(EALREADY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1928 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1929 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1930 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1931 |
#ifdef ENOTSOCK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1932 |
if (sym == @symbol(ENOTSOCK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1933 |
RETURN ( __MKSMALLINT(ENOTSOCK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1934 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1935 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1936 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1937 |
#ifdef EDESTADDRREQ |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1938 |
if (sym == @symbol(EDESTADDRREQ)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1939 |
RETURN ( __MKSMALLINT(EDESTADDRREQ) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1940 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1941 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1942 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1943 |
#ifdef EMSGSIZE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1944 |
if (sym == @symbol(EMSGSIZE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1945 |
RETURN ( __MKSMALLINT(EMSGSIZE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1946 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1947 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1948 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1949 |
#ifdef EPROTOTYPE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1950 |
if (sym == @symbol(EPROTOTYPE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1951 |
RETURN ( __MKSMALLINT(EPROTOTYPE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1952 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1953 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1954 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1955 |
#ifdef ENOPROTOOPT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1956 |
if (sym == @symbol(ENOPROTOOPT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1957 |
RETURN ( __MKSMALLINT(ENOPROTOOPT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1958 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1959 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1960 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1961 |
#ifdef EPROTONOSUPPORT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1962 |
if (sym == @symbol(EPROTONOSUPPORT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1963 |
RETURN ( __MKSMALLINT(EPROTONOSUPPORT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1964 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1965 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1966 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1967 |
#ifdef ESOCKTNOSUPPORT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1968 |
if (sym == @symbol(ESOCKTNOSUPPORT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1969 |
RETURN ( __MKSMALLINT(ESOCKTNOSUPPORT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1970 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1971 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1972 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1973 |
#ifdef EOPNOTSUPP |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1974 |
if (sym == @symbol(EOPNOTSUPP)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1975 |
RETURN ( __MKSMALLINT(EOPNOTSUPP) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1976 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1977 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1978 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1979 |
#ifdef EPFNOSUPPORT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1980 |
if (sym == @symbol(EPFNOSUPPORT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1981 |
RETURN ( __MKSMALLINT(EPFNOSUPPORT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1982 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1983 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1984 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1985 |
#ifdef EAFNOSUPPORT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1986 |
if (sym == @symbol(EAFNOSUPPORT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1987 |
RETURN ( __MKSMALLINT(EAFNOSUPPORT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1988 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1989 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1990 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1991 |
#ifdef EADDRINUSE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1992 |
if (sym == @symbol(EADDRINUSE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1993 |
RETURN ( __MKSMALLINT(EADDRINUSE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1994 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1995 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1996 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1997 |
#ifdef EADDRNOTAVAIL |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1998 |
if (sym == @symbol(EADDRNOTAVAIL)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1999 |
RETURN ( __MKSMALLINT(EADDRNOTAVAIL) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2000 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2001 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2002 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2003 |
#ifdef ETIMEDOUT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2004 |
if (sym == @symbol(ETIMEDOUT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2005 |
RETURN ( __MKSMALLINT(ETIMEDOUT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2006 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2007 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2008 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2009 |
#ifdef ECONNREFUSED |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2010 |
if (sym == @symbol(ECONNREFUSED)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2011 |
RETURN ( __MKSMALLINT(ECONNREFUSED) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2012 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2013 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2014 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2015 |
#ifdef ENETDOWN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2016 |
if (sym == @symbol(ENETDOWN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2017 |
RETURN ( __MKSMALLINT(ENETDOWN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2018 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2019 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2020 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2021 |
#ifdef ENETUNREACH |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2022 |
if (sym == @symbol(ENETUNREACH)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2023 |
RETURN ( __MKSMALLINT(ENETUNREACH) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2024 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2025 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2026 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2027 |
#ifdef ENETRESET |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2028 |
if (sym == @symbol(ENETRESET)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2029 |
RETURN ( __MKSMALLINT(ENETRESET) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2030 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2031 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2032 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2033 |
#ifdef ECONNABORTED |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2034 |
if (sym == @symbol(ECONNABORTED)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2035 |
RETURN ( __MKSMALLINT(ECONNABORTED) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2036 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2037 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2038 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2039 |
#ifdef ECONNRESET |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2040 |
if (sym == @symbol(ECONNRESET)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2041 |
RETURN ( __MKSMALLINT(ECONNRESET) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2042 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2043 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2044 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2045 |
#ifdef EISCONN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2046 |
if (sym == @symbol(EISCONN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2047 |
RETURN ( __MKSMALLINT(EISCONN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2048 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2049 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2050 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2051 |
#ifdef ENOTCONN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2052 |
if (sym == @symbol(ENOTCONN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2053 |
RETURN ( __MKSMALLINT(ENOTCONN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2054 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2055 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2056 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2057 |
#ifdef ESHUTDOWN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2058 |
if (sym == @symbol(ESHUTDOWN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2059 |
RETURN ( __MKSMALLINT(ESHUTDOWN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2060 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2061 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2062 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2063 |
#ifdef EHOSTDOWN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2064 |
if (sym == @symbol(EHOSTDOWN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2065 |
RETURN ( __MKSMALLINT(EHOSTDOWN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2066 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2067 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2068 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2069 |
#ifdef EHOSTUNREACH |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2070 |
if (sym == @symbol(EHOSTUNREACH)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2071 |
RETURN ( __MKSMALLINT(EHOSTUNREACH) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2072 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2073 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2074 |
%}. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2075 |
^ -1 |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2076 |
! |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2077 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2078 |
errorSymbolAndTextForNumber:errNr |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2079 |
"return an array consisting of symbol & message string from a unix errorNumber |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2080 |
(as returned by a system call). |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2081 |
The returned message is in english (as found in /usr/include/errno.h) |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2082 |
and should be replaced by a resource lookup before being presented to the user." |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2083 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2084 |
|sym text| |
1 | 2085 |
|
77 | 2086 |
%{ |
2087 |
/* claus: |
|
2088 |
* I made this some primitive code, since errnos are not |
|
2089 |
* standard across unixes |
|
2090 |
*/ |
|
2091 |
char *msg = "unknown error"; |
|
2092 |
char buffer[50]; |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2093 |
OBJ eno = errNr; |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2094 |
|
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
2095 |
if (__isSmallInteger(eno)) { |
1135 | 2096 |
switch (__intVal(eno)) { |
185 | 2097 |
/* |
2098 |
* POSIX errnos - these should be defined |
|
2099 |
*/ |
|
443 | 2100 |
#ifdef EPERM |
185 | 2101 |
case EPERM: |
2102 |
msg = "Operation not permitted"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2103 |
sym = @symbol(EPERM); |
185 | 2104 |
break; |
443 | 2105 |
#endif |
2106 |
#ifdef ENOENT |
|
185 | 2107 |
case ENOENT: |
2108 |
msg = "No such file or directory"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2109 |
sym = @symbol(ENOENT); |
185 | 2110 |
break; |
443 | 2111 |
#endif |
2112 |
#ifdef ESRCH |
|
185 | 2113 |
case ESRCH: |
2114 |
msg = "No such process"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2115 |
sym = @symbol(ESRCH); |
185 | 2116 |
break; |
443 | 2117 |
#endif |
2118 |
#ifdef EINTR |
|
185 | 2119 |
case EINTR: |
2120 |
msg = "Interrupted system call"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2121 |
sym = @symbol(EINTR); |
185 | 2122 |
break; |
443 | 2123 |
#endif |
2124 |
#ifdef EIO |
|
185 | 2125 |
case EIO: |
2126 |
msg = "I/O error"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2127 |
sym = @symbol(EIO); |
185 | 2128 |
break; |
443 | 2129 |
#endif |
2130 |
#ifdef ENXIO |
|
185 | 2131 |
case ENXIO: |
2132 |
msg = "No such device or address"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2133 |
sym = @symbol(ENXIO); |
185 | 2134 |
break; |
443 | 2135 |
#endif |
2136 |
#ifdef E2BIG |
|
185 | 2137 |
case E2BIG: |
2138 |
msg = "Arg list too long"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2139 |
sym = @symbol(E2BIG); |
185 | 2140 |
break; |
443 | 2141 |
#endif |
2142 |
#ifdef ENOEXEC |
|
185 | 2143 |
case ENOEXEC: |
2144 |
msg = "Exec format error"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2145 |
sym = @symbol(ENOEXEC); |
185 | 2146 |
break; |
443 | 2147 |
#endif |
2148 |
#ifdef EBADF |
|
185 | 2149 |
case EBADF: |
2150 |
msg = "Bad file number"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2151 |
sym = @symbol(EBADF); |
185 | 2152 |
break; |
443 | 2153 |
#endif |
2154 |
#ifdef ECHILD |
|
185 | 2155 |
case ECHILD: |
2156 |
msg = "No child processes"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2157 |
sym = @symbol(ECHILD); |
185 | 2158 |
break; |
443 | 2159 |
#endif |
77 | 2160 |
#if !defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN) |
185 | 2161 |
case EAGAIN: |
2162 |
msg = "Try again"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2163 |
sym = @symbol(EAGAIN); |
185 | 2164 |
break; |
77 | 2165 |
#endif |
443 | 2166 |
#ifdef ENOMEM |
185 | 2167 |
case ENOMEM: |
2168 |
msg = "Out of memory"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2169 |
sym = @symbol(ENOMEM); |
185 | 2170 |
break; |
443 | 2171 |
#endif |
2172 |
#ifdef EACCES |
|
185 | 2173 |
case EACCES: |
2174 |
msg = "Permission denied"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2175 |
sym = @symbol(EACCES); |
185 | 2176 |
break; |
443 | 2177 |
#endif |
2178 |
#ifdef EFAULT |
|
185 | 2179 |
case EFAULT: |
2180 |
msg = "Bad address"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2181 |
sym = @symbol(EFAULT); |
185 | 2182 |
break; |
443 | 2183 |
#endif |
2184 |
#ifdef EBUSY |
|
185 | 2185 |
case EBUSY: |
2186 |
msg = "Device or resource busy"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2187 |
sym = @symbol(EBUSY); |
185 | 2188 |
break; |
443 | 2189 |
#endif |
2190 |
#ifdef EEXIST |
|
185 | 2191 |
case EEXIST: |
2192 |
msg = "File exists"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2193 |
sym = @symbol(EEXIST); |
185 | 2194 |
break; |
443 | 2195 |
#endif |
2196 |
#ifdef EXDEV |
|
185 | 2197 |
case EXDEV: |
2198 |
msg = "Cross-device link"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2199 |
sym = @symbol(EXDEV); |
185 | 2200 |
break; |
443 | 2201 |
#endif |
2202 |
#ifdef ENODEV |
|
185 | 2203 |
case ENODEV: |
2204 |
msg = "No such device"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2205 |
sym = @symbol(ENODEV); |
185 | 2206 |
break; |
443 | 2207 |
#endif |
2208 |
#ifdef ENOTDIR |
|
185 | 2209 |
case ENOTDIR: |
2210 |
msg = "Not a directory"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2211 |
sym = @symbol(ENOTDIR); |
185 | 2212 |
break; |
443 | 2213 |
#endif |
2214 |
#ifdef EISDIR |
|
185 | 2215 |
case EISDIR: |
2216 |
msg = "Is a directory"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2217 |
sym = @symbol(EISDIR); |
185 | 2218 |
break; |
443 | 2219 |
#endif |
2220 |
#ifdef EINVAL |
|
185 | 2221 |
case EINVAL: |
2222 |
msg = "Invalid argument"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2223 |
sym = @symbol(EINVAL); |
185 | 2224 |
break; |
443 | 2225 |
#endif |
2226 |
#ifdef ENFILE |
|
185 | 2227 |
case ENFILE: |
2228 |
msg = "File table overflow"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2229 |
sym = @symbol(ENFILE); |
185 | 2230 |
break; |
443 | 2231 |
#endif |
2232 |
#ifdef EMFILE |
|
185 | 2233 |
case EMFILE: |
2234 |
msg = "Too many open files"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2235 |
sym = @symbol(EMFILE); |
185 | 2236 |
break; |
443 | 2237 |
#endif |
2238 |
#ifdef ENOTTY |
|
185 | 2239 |
case ENOTTY: |
2240 |
msg = "Not a typewriter"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2241 |
sym = @symbol(ENOTTY); |
185 | 2242 |
break; |
443 | 2243 |
#endif |
2244 |
#ifdef EFBIG |
|
185 | 2245 |
case EFBIG: |
2246 |
msg = "File too large"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2247 |
sym = @symbol(EFBIG); |
185 | 2248 |
break; |
443 | 2249 |
#endif |
2250 |
#ifdef ENOSPC |
|
185 | 2251 |
case ENOSPC: |
2252 |
msg = "No space left on device"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2253 |
sym = @symbol(ENOSPC); |
185 | 2254 |
break; |
443 | 2255 |
#endif |
2256 |
#ifdef ESPIPE |
|
185 | 2257 |
case ESPIPE: |
2258 |
msg = "Illegal seek"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2259 |
sym = @symbol(ESPIPE); |
185 | 2260 |
break; |
443 | 2261 |
#endif |
2262 |
#ifdef EROFS |
|
185 | 2263 |
case EROFS: |
2264 |
msg = "Read-only file system"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2265 |
sym = @symbol(EROFS); |
185 | 2266 |
break; |
443 | 2267 |
#endif |
2268 |
#ifdef EMLINK |
|
185 | 2269 |
case EMLINK: |
2270 |
msg = "Too many links"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2271 |
sym = @symbol(EMLINK); |
185 | 2272 |
break; |
443 | 2273 |
#endif |
2274 |
#ifdef EPIPE |
|
185 | 2275 |
case EPIPE: |
2276 |
msg = "Broken pipe"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2277 |
sym = @symbol(EPIPE); |
185 | 2278 |
break; |
443 | 2279 |
#endif |
2280 |
#ifdef EDOM |
|
185 | 2281 |
case EDOM: |
2282 |
msg = "Math argument out of domain"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2283 |
sym = @symbol(EDOM); |
185 | 2284 |
break; |
443 | 2285 |
#endif |
2286 |
#ifdef ERANGE |
|
185 | 2287 |
case ERANGE: |
2288 |
msg = "Math result not representable"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2289 |
sym = @symbol(ERANGE); |
185 | 2290 |
break; |
443 | 2291 |
#endif |
77 | 2292 |
#ifdef EDEADLK |
308 | 2293 |
# if EDEADLK != EWOULDBLOCK |
185 | 2294 |
case EDEADLK: |
2295 |
msg = "Resource deadlock would occur"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2296 |
sym = @symbol(EDEADLK); |
185 | 2297 |
break; |
308 | 2298 |
# endif |
77 | 2299 |
#endif |
2300 |
#ifdef ENAMETOOLONG |
|
185 | 2301 |
case ENAMETOOLONG: |
2302 |
msg = "File name too long"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2303 |
sym = @symbol(ENAMETOOLONG); |
185 | 2304 |
break; |
77 | 2305 |
#endif |
2306 |
#ifdef ENOLCK |
|
185 | 2307 |
case ENOLCK: |
2308 |
msg = "No record locks available"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2309 |
sym = @symbol(ENOLCK); |
185 | 2310 |
break; |
77 | 2311 |
#endif |
2312 |
#ifdef ENOSYS |
|
185 | 2313 |
case ENOSYS: |
2314 |
msg = "Function not implemented"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2315 |
sym = @symbol(ENOSYS); |
185 | 2316 |
break; |
77 | 2317 |
#endif |
359 | 2318 |
#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST) |
185 | 2319 |
case ENOTEMPTY: |
2320 |
msg = "Directory not empty"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2321 |
sym = @symbol(ENOTEMPTY); |
185 | 2322 |
break; |
77 | 2323 |
#endif |
2324 |
#ifdef EILSEQ |
|
185 | 2325 |
case EILSEQ: |
2326 |
msg = "Illegal byte sequence"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2327 |
sym = @symbol(EILSEQ); |
185 | 2328 |
break; |
77 | 2329 |
#endif |
185 | 2330 |
/* |
2331 |
* XPG3 errnos - defined on most systems |
|
2332 |
*/ |
|
77 | 2333 |
#ifdef ENOTBLK |
185 | 2334 |
case ENOTBLK: |
2335 |
msg = "Block device required"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2336 |
sym = @symbol(ENOTBLK); |
185 | 2337 |
break; |
77 | 2338 |
#endif |
2339 |
#ifdef ETXTBSY |
|
185 | 2340 |
case ETXTBSY: |
2341 |
msg = "Text file busy"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2342 |
sym = @symbol(ETXTBSY); |
185 | 2343 |
break; |
77 | 2344 |
#endif |
185 | 2345 |
/* |
2346 |
* some others |
|
2347 |
*/ |
|
77 | 2348 |
#ifdef EWOULDBLOCK |
185 | 2349 |
case EWOULDBLOCK: |
2350 |
msg = "Operation would block"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2351 |
sym = @symbol(EWOULDBLOCK); |
185 | 2352 |
break; |
77 | 2353 |
#endif |
2354 |
#ifdef ENOMSG |
|
185 | 2355 |
case ENOMSG: |
2356 |
msg = "No message of desired type"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2357 |
sym = @symbol(ENOMSG); |
185 | 2358 |
break; |
77 | 2359 |
#endif |
2360 |
#ifdef ELOOP |
|
185 | 2361 |
case ELOOP: |
2362 |
msg = "Too many levels of symbolic links"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2363 |
sym = @symbol(ELOOP); |
185 | 2364 |
break; |
77 | 2365 |
#endif |
2366 |
||
185 | 2367 |
/* |
2368 |
* some stream errors |
|
2369 |
*/ |
|
77 | 2370 |
#ifdef ETIME |
185 | 2371 |
case ETIME: |
2372 |
msg = "Timer expired"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2373 |
sym = @symbol(ETIME); |
185 | 2374 |
break; |
77 | 2375 |
#endif |
2376 |
#ifdef ENOSR |
|
185 | 2377 |
case ENOSR: |
2378 |
msg = "Out of streams resources"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2379 |
sym = @symbol(ENOSR); |
185 | 2380 |
break; |
77 | 2381 |
#endif |
2382 |
#ifdef ENOSTR |
|
185 | 2383 |
case ENOSTR: |
2384 |
msg = "Device not a stream"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2385 |
sym = @symbol(ENOSTR); |
185 | 2386 |
break; |
77 | 2387 |
#endif |
2388 |
#ifdef ECOMM |
|
185 | 2389 |
case ECOMM: |
2390 |
msg = "Communication error on send"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2391 |
sym = @symbol(ECOMM); |
185 | 2392 |
break; |
77 | 2393 |
#endif |
2394 |
#ifdef EPROTO |
|
185 | 2395 |
case EPROTO: |
2396 |
msg = "Protocol error"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2397 |
sym = @symbol(EPROTO); |
185 | 2398 |
break; |
77 | 2399 |
#endif |
185 | 2400 |
/* |
2401 |
* nfs errors |
|
2402 |
*/ |
|
77 | 2403 |
#ifdef ESTALE |
185 | 2404 |
case ESTALE: |
2405 |
msg = "Stale NFS file handle"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2406 |
sym = @symbol(ESTALE); |
185 | 2407 |
break; |
77 | 2408 |
#endif |
2409 |
#ifdef EREMOTE |
|
185 | 2410 |
case EREMOTE: |
2411 |
msg = "Too many levels of remote in path"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2412 |
sym = @symbol(EREMOTE); |
185 | 2413 |
break; |
77 | 2414 |
#endif |
185 | 2415 |
/* |
2416 |
* some networking errors |
|
2417 |
*/ |
|
77 | 2418 |
#ifdef EINPROGRESS |
185 | 2419 |
case EINPROGRESS: |
2420 |
msg = "Operation now in progress"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2421 |
sym = @symbol(EINPROGRESS); |
185 | 2422 |
break; |
77 | 2423 |
#endif |
2424 |
#ifdef EALREADY |
|
185 | 2425 |
case EALREADY: |
2426 |
msg = "Operation already in progress"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2427 |
sym = @symbol(EALREADY); |
185 | 2428 |
break; |
77 | 2429 |
#endif |
2430 |
#ifdef ENOTSOCK |
|
185 | 2431 |
case ENOTSOCK: |
2432 |
msg = "Socket operation on non-socket"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2433 |
sym = @symbol(ENOTSOCK); |
185 | 2434 |
break; |
77 | 2435 |
#endif |
2436 |
#ifdef EDESTADDRREQ |
|
185 | 2437 |
case EDESTADDRREQ: |
2438 |
msg = "Destination address required"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2439 |
sym = @symbol(EDESTADDRREQ); |
185 | 2440 |
break; |
77 | 2441 |
#endif |
2442 |
#ifdef EMSGSIZE |
|
185 | 2443 |
case EMSGSIZE: |
2444 |
msg = "Message too long"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2445 |
sym = @symbol(EMSGSIZE); |
185 | 2446 |
break; |
77 | 2447 |
#endif |
2448 |
#ifdef EPROTOTYPE |
|
185 | 2449 |
case EPROTOTYPE: |
2450 |
msg = "Protocol wrong type for socket"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2451 |
sym = @symbol(EPROTOTYPE); |
185 | 2452 |
break; |
77 | 2453 |
#endif |
2454 |
#ifdef ENOPROTOOPT |
|
185 | 2455 |
case ENOPROTOOPT: |
2456 |
msg = "Protocol not available"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2457 |
sym = @symbol(ENOPROTOOPT); |
185 | 2458 |
break; |
77 | 2459 |
#endif |
2460 |
#ifdef EPROTONOSUPPORT |
|
185 | 2461 |
case EPROTONOSUPPORT: |
2462 |
msg = "Protocol not supported"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2463 |
sym = @symbol(EPROTONOSUPPORT); |
185 | 2464 |
break; |
77 | 2465 |
#endif |
2466 |
#ifdef ESOCKTNOSUPPORT |
|
185 | 2467 |
case ESOCKTNOSUPPORT: |
2468 |
msg = "Socket type not supported"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2469 |
sym = @symbol(ESOCKTNOSUPPORT); |
185 | 2470 |
break; |
77 | 2471 |
#endif |
2472 |
#ifdef EOPNOTSUPP |
|
185 | 2473 |
case EOPNOTSUPP: |
2474 |
msg = "Operation not supported on socket"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2475 |
sym = @symbol(EOPNOTSUPP); |
185 | 2476 |
break; |
77 | 2477 |
#endif |
2478 |
#ifdef EPFNOSUPPORT |
|
185 | 2479 |
case EPFNOSUPPORT: |
2480 |
msg = "Protocol family not supported"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2481 |
sym = @symbol(EPFNOSUPPORT); |
185 | 2482 |
break; |
77 | 2483 |
#endif |
2484 |
#ifdef EAFNOSUPPORT |
|
185 | 2485 |
case EAFNOSUPPORT: |
2486 |
msg = "Address family not supported by protocol family"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2487 |
sym = @symbol(EAFNOSUPPORT); |
185 | 2488 |
break; |
77 | 2489 |
#endif |
2490 |
#ifdef EADDRINUSE |
|
185 | 2491 |
case EADDRINUSE: |
2492 |
msg = "Address already in use"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2493 |
sym = @symbol(EADDRINUSE); |
185 | 2494 |
break; |
77 | 2495 |
#endif |
2496 |
#ifdef EADDRNOTAVAIL |
|
185 | 2497 |
case EADDRNOTAVAIL: |
2498 |
msg = "Can\'t assign requested address"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2499 |
sym = @symbol(EADDRNOTAVAIL); |
185 | 2500 |
break; |
77 | 2501 |
#endif |
2502 |
#ifdef ETIMEDOUT |
|
185 | 2503 |
case ETIMEDOUT: |
2504 |
msg = "Connection timed out"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2505 |
sym = @symbol(ETIMEDOUT); |
185 | 2506 |
break; |
77 | 2507 |
#endif |
2508 |
#ifdef ECONNREFUSED |
|
185 | 2509 |
case ECONNREFUSED: |
2510 |
msg = "Connection refused"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2511 |
sym = @symbol(ECONNREFUSED); |
185 | 2512 |
break; |
77 | 2513 |
#endif |
362 | 2514 |
#ifdef ENETDOWN |
2515 |
case ENETDOWN: |
|
2516 |
msg = "Network is down"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2517 |
sym = @symbol(ENETDOWN); |
362 | 2518 |
break; |
2519 |
#endif |
|
2520 |
#ifdef ENETUNREACH |
|
2521 |
case ENETUNREACH: |
|
2522 |
msg = "Network is unreachable"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2523 |
sym = @symbol(ENETUNREACH); |
362 | 2524 |
break; |
2525 |
#endif |
|
2526 |
#ifdef ENETRESET |
|
2527 |
case ENETRESET: |
|
2528 |
msg = "Network dropped conn due to reset"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2529 |
sym = @symbol(ENETRESET); |
362 | 2530 |
break; |
2531 |
#endif |
|
2532 |
#ifdef ECONNABORTED |
|
2533 |
case ECONNABORTED: |
|
2534 |
msg = "Software caused connection abort"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2535 |
sym = @symbol(ECONNABORTED); |
362 | 2536 |
break; |
2537 |
#endif |
|
2538 |
#ifdef ECONNRESET |
|
2539 |
case ECONNRESET: |
|
2540 |
msg = "Connection reset by peer"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2541 |
sym = @symbol(ECONNRESET); |
362 | 2542 |
break; |
2543 |
#endif |
|
2544 |
#ifdef EISCONN |
|
2545 |
case EISCONN: |
|
2546 |
msg = "Socket is already connected"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2547 |
sym = @symbol(EISCONN); |
362 | 2548 |
break; |
2549 |
#endif |
|
2550 |
#ifdef ENOTCONN |
|
2551 |
case ENOTCONN: |
|
2552 |
msg = "Socket is not connected"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2553 |
sym = @symbol(ENOTCONN); |
362 | 2554 |
break; |
2555 |
#endif |
|
2556 |
#ifdef ESHUTDOWN |
|
2557 |
case ESHUTDOWN: |
|
2558 |
msg = "Can't send after socket shutdown"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2559 |
sym = @symbol(ESHUTDOWN); |
362 | 2560 |
break; |
2561 |
#endif |
|
2562 |
#ifdef EHOSTDOWN |
|
2563 |
case EHOSTDOWN: |
|
2564 |
msg = "Host is down"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2565 |
sym = @symbol(EHOSTDOWN); |
362 | 2566 |
break; |
2567 |
#endif |
|
2568 |
#ifdef EHOSTUNREACH |
|
2569 |
case EHOSTUNREACH: |
|
2570 |
msg = "No route to host"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2571 |
sym = @symbol(EHOSTUNREACH); |
362 | 2572 |
break; |
2573 |
#endif |
|
2574 |
||
185 | 2575 |
default: |
368 | 2576 |
{ |
809
5eef87c2907b
e convenient macro for register saving (sparc only)
Claus Gittinger <cg@exept.de>
parents:
805
diff
changeset
|
2577 |
__BEGIN_PROTECT_REGISTERS__ |
1135 | 2578 |
sprintf(buffer, "ErrorNr: %d", __intVal(eno)); |
809
5eef87c2907b
e convenient macro for register saving (sparc only)
Claus Gittinger <cg@exept.de>
parents:
805
diff
changeset
|
2579 |
__END_PROTECT_REGISTERS__ |
368 | 2580 |
} |
185 | 2581 |
msg = buffer; |
2582 |
break; |
|
2583 |
} |
|
77 | 2584 |
} |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2585 |
text = __MKSTRING(msg); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2586 |
%}. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2587 |
^ Array with:sym with:text |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2588 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2589 |
" |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2590 |
OperatingSystem errorSymbolAndTextForNumber:4 |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2591 |
" |
616 | 2592 |
! |
2593 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2594 |
errorSymbolForNumber:errNr |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2595 |
"return a symbol for a unix errorNumber |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2596 |
(as returned by a system call)." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2597 |
|
1153
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
2598 |
^ (self errorSymbolAndTextForNumber:errNr) at:1 |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2599 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2600 |
" |
1666 | 2601 |
OperatingSystem errorSymbolForNumber:4 |
2602 |
OperatingSystem errorSymbolForNumber:2 |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2603 |
" |
1153
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
2604 |
|
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
2605 |
"Modified: 12.4.1996 / 09:16:29 / stefan" |
1666 | 2606 |
"Modified: 13.9.1996 / 16:23:35 / cg" |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2607 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2608 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2609 |
errorTextForNumber:errNr |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2610 |
"return a message string from a unix errorNumber |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2611 |
(as returned by a system call). |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2612 |
The returned message is in english (as found in /usr/include/errno.h) |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2613 |
and should be replaced by a resource lookup before being presented to the user." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2614 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2615 |
^ (self errorSymbolAndTextForNumber:errNr) at:2 |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2616 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2617 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2618 |
OperatingSystem errorTextForNumber:4 |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2619 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2620 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2621 |
|
616 | 2622 |
lastErrorNumber |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2623 |
"return the last errors number. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2624 |
See also: #lastErrorSymbol and #lastErrorString. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2625 |
Notice: having a single error number is a bad idea in a multithreaded |
1487 | 2626 |
environment - this interface will change." |
616 | 2627 |
|
2628 |
^ LastErrorNumber |
|
2629 |
||
2630 |
" |
|
2631 |
OperatingSystem lastErrorNumber |
|
2632 |
" |
|
2633 |
! |
|
2634 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2635 |
lastErrorString |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2636 |
"return a message string describing the last error. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2637 |
See also: #lastErrorNumber and #lastErrorSymbol. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2638 |
Notice: having a single error number is a bad idea in a multithreaded |
1487 | 2639 |
environment - this interface will change." |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2640 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2641 |
^ self errorTextForNumber:LastErrorNumber |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2642 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2643 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2644 |
OperatingSystem lastErrorString |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2645 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2646 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2647 |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2648 |
lastErrorSymbol |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2649 |
"return a symbol (such as #EBADF or #EACCESS) describing the last error. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2650 |
See also: #lastErrorNumber and #lastErrorString. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2651 |
Notice: having a single error number is a bad idea in a multithreaded |
1487 | 2652 |
environment - this interface will change." |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2653 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2654 |
^ self errorSymbolForNumber:LastErrorNumber |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2655 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2656 |
" |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2657 |
OperatingSystem lastErrorSymbol |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2658 |
" |
1 | 2659 |
! ! |
2660 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
2661 |
!OperatingSystem class methodsFor:'executing OS commands'! |
616 | 2662 |
|
2663 |
canExecuteCommand:aCommandString |
|
2664 |
"return true, if the OS can execute aCommand." |
|
2665 |
||
2666 |
|cmd| |
|
2667 |
||
2668 |
cmd := aCommandString asCollectionOfWords first. |
|
2669 |
^ (self pathOfCommand:cmd) notNil |
|
2670 |
||
2671 |
" |
|
2672 |
OperatingSystem canExecuteCommand:'fooBar' |
|
2673 |
OperatingSystem canExecuteCommand:'ls' |
|
2674 |
OperatingSystem canExecuteCommand:'cvs' |
|
2675 |
" |
|
2676 |
||
2677 |
"Created: 4.11.1995 / 19:13:54 / cg" |
|
68 | 2678 |
! |
2679 |
||
616 | 2680 |
exec:aPath withArguments:argArray |
2681 |
"execute the unix command specified by the argument, aPath, with |
|
2682 |
arguments in argArray (no arguments, if nil). |
|
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2683 |
If successful, this method does NOT return and smalltalk is gone. |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2684 |
If not successful, false is returned. Can be used with fork or to transfer |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2685 |
to another program." |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2686 |
|
792 | 2687 |
^ self exec:aPath withArguments:argArray fork:false |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2688 |
! |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2689 |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2690 |
exec:aPath withArguments:argArray fileDescriptors:fdArray closeDescriptors:closeFdArray fork:doFork newPgrp:newPgrp |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2691 |
"Internal combined fork & exec; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2692 |
If fork is false: |
1487 | 2693 |
execute the unix command specified by the argument, aPath, with |
2694 |
arguments in argArray (no arguments, if nil). |
|
2695 |
If successful, this method does not return and smalltalk is gone. |
|
2696 |
If not successful, false is returned. Normal use is with forkForCommand. |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2697 |
if its true: |
1487 | 2698 |
for a child to do the above. |
2699 |
The id of the child process is returned; -1 if fork failed. |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2700 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2701 |
fdArray contains the filedescriptors, to be used for the child (if fork is true). |
1487 | 2702 |
fdArray[1] = 15 -> use fd 15 as stdin. |
2703 |
If an element of the array is set to nil, the corresponding filedescriptor |
|
2704 |
will be closed for the child. |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2705 |
|
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2706 |
closeFdArray contains descriptors that will be closed in the subprocess. |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2707 |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2708 |
If newPgrp is true, the subprocess will be established in a new process group. |
1487 | 2709 |
Ths processgroup will be equal to id. |
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2710 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2711 |
Notice: this used to be two separate ST-methods; however, in order to use |
1487 | 2712 |
vfork on some machines, it had to be merged into one, to avoid write |
2713 |
accesses to ST/X memory from the vforked-child. The code below only does |
|
2714 |
read accesses." |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2715 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2716 |
%{ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2717 |
#ifndef MSDOS_LIKE |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2718 |
char **argv; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2719 |
int nargs, i, id; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2720 |
OBJ arg; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2721 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2722 |
if (__isString(aPath) && |
1487 | 2723 |
((argArray == nil) || __isArray(argArray)) && |
2724 |
((fdArray == nil) || __isArray(fdArray)) && |
|
2725 |
((closeFdArray == nil) || __isArray(closeFdArray)) |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2726 |
) { |
1487 | 2727 |
nargs = argArray == nil ? 0 : _arraySize(argArray); |
2728 |
argv = (char **) malloc(sizeof(char *) * (nargs + 1)); |
|
2729 |
if (argv) { |
|
2730 |
for (i=0; i < nargs; i++) { |
|
2731 |
arg = __ArrayInstPtr(argArray)->a_element[i]; |
|
2732 |
if (__isString(arg)) { |
|
2733 |
argv[i] = (char *) __stringVal(arg); |
|
2734 |
} else { |
|
2735 |
argv[i] = ""; |
|
2736 |
} |
|
2737 |
} |
|
2738 |
argv[i] = NULL; |
|
2739 |
||
2740 |
if (doFork == true) { |
|
2741 |
int nfd, nclose; |
|
2742 |
||
2743 |
nfd = fdArray == nil ? 0 : _arraySize(fdArray); |
|
2744 |
nclose = closeFdArray == nil ? 0 : _arraySize(closeFdArray); |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2745 |
#ifdef HAS_VFORK |
1487 | 2746 |
id = vfork(); |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2747 |
#else |
1487 | 2748 |
id = fork(); |
2749 |
#endif |
|
2750 |
if (id == 0) { |
|
2751 |
/* |
|
2752 |
** In child. |
|
2753 |
** first: dup filedescriptors |
|
2754 |
*/ |
|
2755 |
for (i = 0; i < nfd; i++) { |
|
2756 |
if (__isSmallInteger(__ArrayInstPtr(fdArray)->a_element[i]) && |
|
2757 |
__intVal(__ArrayInstPtr(fdArray)->a_element[i]) != i |
|
2758 |
) { |
|
2759 |
dup2(__intVal(__ArrayInstPtr(fdArray)->a_element[i]), i); |
|
2760 |
} |
|
2761 |
} |
|
2762 |
/* |
|
2763 |
** second: close unused filedescriptors |
|
2764 |
*/ |
|
2765 |
for (i = 0; i < nfd; i++) { |
|
2766 |
if (__ArrayInstPtr(fdArray)->a_element[i] == nil) { |
|
2767 |
close(i); |
|
2768 |
} |
|
2769 |
} |
|
2770 |
/* |
|
2771 |
** third: close filedescriptors |
|
2772 |
*/ |
|
2773 |
for (i = 0; i < nclose; i++) { |
|
2774 |
if (__isSmallInteger(__ArrayInstPtr(closeFdArray)->a_element[i])) { |
|
2775 |
close(__intVal(__ArrayInstPtr(closeFdArray)->a_element[i])); |
|
2776 |
} |
|
2777 |
} |
|
2778 |
if (newPgrp == true) { |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2779 |
#if defined(_POSIX_JOB_CONTROL) |
1487 | 2780 |
(void) setpgid(0, 0); |
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2781 |
#else |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2782 |
#if defined(BSD) |
1487 | 2783 |
(void) setpgrp(0); |
2784 |
#endif |
|
2785 |
#endif |
|
2786 |
} |
|
2787 |
||
2788 |
execv(__stringVal(aPath), argv); |
|
2789 |
/* should not be reached */ |
|
2790 |
_exit(127); /* POSIX 2 compatible exit value */ |
|
2791 |
} |
|
2792 |
/* |
|
2793 |
** In parent: succes or failure |
|
2794 |
*/ |
|
2795 |
free(argv); |
|
2796 |
RETURN (__MKSMALLINT(id)); |
|
2797 |
} else { |
|
2798 |
execv(__stringVal(aPath), argv); |
|
2799 |
/* |
|
2800 |
* should not be reached |
|
2801 |
* (well, it is, if you pass a wrong command-path) |
|
2802 |
*/ |
|
2803 |
free(argv); |
|
2804 |
RETURN ( false ); |
|
2805 |
} |
|
2806 |
} |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2807 |
} |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2808 |
#endif |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2809 |
%}. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2810 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2811 |
path-argument not string |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2812 |
or argArray not an array/nil |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2813 |
or malloc failed |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2814 |
or not supported by OS |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2815 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2816 |
^ self primitiveFailed |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2817 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2818 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2819 |
|id| |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2820 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2821 |
id := OperatingSystem fork. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2822 |
id == 0 ifTrue:[ |
1487 | 2823 |
"I am the child" |
2824 |
OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp'). |
|
2825 |
"not reached" |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2826 |
] |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2827 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2828 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2829 |
|id| |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2830 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2831 |
id := OperatingSystem fork. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2832 |
id == 0 ifTrue:[ |
1487 | 2833 |
"I am the child" |
2834 |
OperatingSystem exec:'/bin/sh' withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2'). |
|
2835 |
"not reached" |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2836 |
]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2837 |
id printNL. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2838 |
(Delay forSeconds:3.5) wait. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2839 |
'killing ...' printNL. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2840 |
OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2841 |
OperatingSystem sendSignal:(OperatingSystem sigKILL) to:id |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2842 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2843 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2844 |
|
1076
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2845 |
exec:aPath withArguments:argArray fileDescriptors:fdArray fork:doFork |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2846 |
"Internal combined fork & exec; |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2847 |
If fork is false: |
1487 | 2848 |
execute the unix command specified by the argument, aPath, with |
2849 |
arguments in argArray (no arguments, if nil). |
|
2850 |
If successful, this method does not return and smalltalk is gone. |
|
2851 |
If not successful, false is returned. Normal use is with forkForCommand. |
|
1076
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2852 |
if its true: |
1487 | 2853 |
for a child to do the above. |
2854 |
The id of the child process is returned; -1 if fork failed. |
|
1076
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2855 |
|
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2856 |
fdArray contains the filedescriptors, to be used for the child (if fork is true). |
1487 | 2857 |
fdArray[1] = 15 -> use fd 15 as stdin. |
2858 |
If an element of the array is set to nil, the corresponding filedescriptor |
|
2859 |
will be closed for the child. |
|
1076
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2860 |
|
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2861 |
Notice: this used to be two separate ST-methods; however, in order to use |
1487 | 2862 |
vfork on some machines, it had to be merged into one, to avoid write |
2863 |
accesses to ST/X memory from the vforked-child. The code below only does |
|
2864 |
read accesses." |
|
1076
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2865 |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2866 |
^ self exec:aPath withArguments:argArray fileDescriptors:fdArray closeDescriptors:nil fork:doFork newPgrp:false |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2867 |
|
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2868 |
"Modified: 23.4.1996 / 17:05:41 / stefan" |
1076
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2869 |
! |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2870 |
|
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2871 |
exec:aPath withArguments:argArray fork:doFork |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2872 |
"Internal combined fork & exec; |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2873 |
If fork is false: |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2874 |
execute the unix command specified by the argument, aPath, with |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2875 |
arguments in argArray (no arguments, if nil). |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2876 |
If successful, this method does not return and smalltalk is gone. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2877 |
If not successful, false is returned. Normal use is with forkForCommand. |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2878 |
if its true: |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2879 |
for a child to do the above. |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2880 |
The id of the child process is returned; -1 if fork failed. |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2881 |
|
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2882 |
Notice: this used to be two separate ST-methods; however, in order to use |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2883 |
vfork on some machines, it had to be merged into one, to avoid write |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2884 |
accesses to ST/X memory from the vforked-child. The code below only does |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2885 |
read accesses." |
616 | 2886 |
|
2887 |
%{ |
|
792 | 2888 |
#ifndef MSDOS_LIKE |
616 | 2889 |
char **argv; |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2890 |
int nargs, i, id; |
616 | 2891 |
OBJ arg; |
2892 |
||
2893 |
if (__isString(aPath) && ((argArray == nil) || __isArray(argArray))) { |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2894 |
nargs = argArray == nil ? 0 : _arraySize(argArray); |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2895 |
argv = (char **) malloc(sizeof(char *) * (nargs + 1)); |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2896 |
if (argv) { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2897 |
for (i=0; i < nargs; i++) { |
1135 | 2898 |
arg = __ArrayInstPtr(argArray)->a_element[i]; |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2899 |
if (__isString(arg)) { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2900 |
argv[i] = (char *) __stringVal(arg); |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2901 |
} else { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2902 |
argv[i] = ""; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2903 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2904 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2905 |
argv[i] = NULL; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2906 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2907 |
if (doFork == true) { |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2908 |
#ifdef HAS_VFORK |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2909 |
id = vfork(); |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2910 |
#else |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2911 |
id = fork(); |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2912 |
#endif |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2913 |
if (id == 0) { |
1135 | 2914 |
execv(__stringVal(aPath), argv); |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2915 |
/* should not be reached */ |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2916 |
_exit(127); /* POSIX-2 compatible exit value */ |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2917 |
} |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2918 |
free(argv); |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2919 |
RETURN (__MKSMALLINT(id)); |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2920 |
} else { |
1135 | 2921 |
execv(__stringVal(aPath), argv); |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2922 |
/* |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2923 |
* should not be reached |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2924 |
* (well, it is, if you pass a wrong command-path) |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2925 |
*/ |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2926 |
free(argv); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2927 |
RETURN ( false ); |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2928 |
} |
616 | 2929 |
} |
2930 |
} |
|
792 | 2931 |
#endif |
616 | 2932 |
%}. |
2933 |
" |
|
792 | 2934 |
path-argument not string |
2935 |
or argArray not an array/nil |
|
2936 |
or malloc failed |
|
2937 |
or not supported by OS |
|
616 | 2938 |
" |
2939 |
^ self primitiveFailed |
|
2940 |
||
2941 |
" |
|
2942 |
|id| |
|
2943 |
||
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2944 |
id := OperatingSystem fork. |
616 | 2945 |
id == 0 ifTrue:[ |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2946 |
"I am the child" |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2947 |
OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp'). |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2948 |
"not reached" |
616 | 2949 |
] |
2950 |
" |
|
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2951 |
" |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2952 |
|id| |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2953 |
|
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2954 |
id := OperatingSystem fork. |
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2955 |
id == 0 ifTrue:[ |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2956 |
"I am the child" |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2957 |
OperatingSystem exec:'/bin/sh' withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2'). |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2958 |
"not reached" |
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2959 |
]. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2960 |
id printNL. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2961 |
(Delay forSeconds:3.5) wait. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2962 |
'killing ...' printNL. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2963 |
OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2964 |
OperatingSystem sendSignal:(OperatingSystem sigKILL) to:id |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2965 |
" |
616 | 2966 |
! |
2967 |
||
2968 |
executeCommand:aCommandString |
|
2969 |
"execute the unix command specified by the argument, aCommandString. |
|
676 | 2970 |
The commandString is passed to a shell for execution - see the description of |
2971 |
'sh -c' in your UNIX manual. |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2972 |
Return true if successful, false otherwise." |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2973 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2974 |
^ self executeCommand:aCommandString onError:[:status| false] |
2080
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2975 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2976 |
"/Old code: |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2977 |
"/ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2978 |
"/%{ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2979 |
"/ int status; |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2980 |
"/ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2981 |
"/ if (__isString(aCommandString)) { |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2982 |
"/ /* |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2983 |
"/ * ST/X provides a modified (fixed) implementation of the |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2984 |
"/ * system() libc-function, which is interruptable ... |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2985 |
"/ */ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2986 |
"/# ifdef WANT_SYSTEM |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2987 |
"/ status = mySystem((char *) __stringVal(aCommandString)); |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2988 |
"/# else |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2989 |
"/ status = system((char *) __stringVal(aCommandString)); |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2990 |
"/# endif |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2991 |
"/ OperatingSystem_LastExecStatus = __MKSMALLINT(status); |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2992 |
"/ if (status == 0) { |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2993 |
"/ RETURN ( true ); |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2994 |
"/ } |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2995 |
"/ OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2996 |
"/ RETURN ( false ); |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2997 |
"/ } |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2998 |
"/%}. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
2999 |
"/ "/ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
3000 |
"/ "/ invalid argument (non-string) |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
3001 |
"/ "/ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
3002 |
"/ ^ self primitiveFailed |
616 | 3003 |
|
3004 |
" |
|
805 | 3005 |
OperatingSystem executeCommand:'sleep 30'. |
616 | 3006 |
OperatingSystem executeCommand:'pwd'. |
3007 |
OperatingSystem executeCommand:'ls -l'. |
|
3008 |
OperatingSystem executeCommand:'invalidCommand'. |
|
3009 |
OperatingSystem executeCommand:'rm /tmp/foofoofoofoo'. |
|
3010 |
" |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3011 |
|
2080
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
3012 |
"Modified: 7.1.1997 / 19:29:55 / stefan" |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3013 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3014 |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3015 |
executeCommand:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream errorTo:anExternalErrStream onError:aBlock |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3016 |
"execute the unix command specified by the argument, aCommandString. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3017 |
The commandString is passed to a shell for execution - see the description of |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3018 |
'sh -c' in your UNIX manual. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3019 |
Return true if successful. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3020 |
If not successfull, aBlock is called with a Dictionary containing the exit status |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3021 |
as argument." |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3022 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3023 |
|pid exitStatus sema| |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3024 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3025 |
sema := Semaphore new. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3026 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3027 |
[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3028 |
pid := self |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3029 |
startProcess:aCommandString |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3030 |
inputFrom:anExternalInStream |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3031 |
outputTo:anExternalOutStream |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3032 |
errorTo:anExternalErrStream. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3033 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3034 |
pid > 0 ifTrue:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3035 |
Processor monitorPid:pid action:[:status | |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3036 |
status stillAlive ifFalse:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3037 |
exitStatus := status. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3038 |
sema signal |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3039 |
]. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3040 |
]. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3041 |
sema wait. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3042 |
] ifFalse:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3043 |
exitStatus := OSProcessStatus processCreationFailure. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3044 |
]. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3045 |
] valueUninterruptably. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3046 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3047 |
exitStatus success ifFalse:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3048 |
^ aBlock value:exitStatus |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3049 |
]. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3050 |
^ true. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3051 |
! |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3052 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3053 |
executeCommand:aCommandString onError:aBlock |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3054 |
"execute the unix command specified by the argument, aCommandString. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3055 |
The commandString is passed to a shell for execution - see the description of |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3056 |
'sh -c' in your UNIX manual. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3057 |
Return true if successful. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3058 |
If not successfull, aBlock is called with a Dictionary containing the exit status |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3059 |
as argument." |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3060 |
|
1034 | 3061 |
|pid exitStatus sema| |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3062 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3063 |
sema := Semaphore new. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3064 |
|
1034 | 3065 |
[ |
1487 | 3066 |
pid := self startProcess:aCommandString. |
3067 |
pid > 0 ifTrue:[ |
|
3068 |
Processor monitorPid:pid action:[:status | |
|
3069 |
status stillAlive ifFalse:[ |
|
3070 |
exitStatus := status. |
|
3071 |
sema signal |
|
3072 |
]. |
|
3073 |
]. |
|
3074 |
sema wait. |
|
3075 |
] ifFalse:[ |
|
3076 |
exitStatus := OSProcessStatus processCreationFailure. |
|
3077 |
]. |
|
1034 | 3078 |
] valueUninterruptably. |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3079 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3080 |
exitStatus success ifFalse:[ |
1487 | 3081 |
^ aBlock value:exitStatus |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3082 |
]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3083 |
^ true. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3084 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3085 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3086 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3087 |
OperatingSystem executeCommand:'sleep 30' onError:[]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3088 |
OperatingSystem executeCommand:'pwd' onError:[:status|status inspect]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3089 |
OperatingSystem executeCommand:'ls -l' onError:[]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3090 |
OperatingSystem executeCommand:'invalidCommand' onError:[:status| status inspect]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3091 |
OperatingSystem executeCommand:'rm /tmp/foofoofoofoo'onError:[:status | status inspect]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3092 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3093 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3094 |
"Created: 22.12.1995 / 14:49:59 / stefan" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3095 |
"Modified: 28.12.1995 / 15:25:48 / stefan" |
1034 | 3096 |
"Modified: 28.2.1996 / 21:41:23 / cg" |
616 | 3097 |
! |
3098 |
||
3099 |
fork |
|
3100 |
"fork a new (HEAVY-weight) unix process. |
|
3101 |
Dont confuse this with Block>>fork, which creates |
|
3102 |
lightweight smalltalk processes. This method will return |
|
676 | 3103 |
0 to the child process, and a non-zero number (which is the childs |
3104 |
unix-process-id) to the parent (original) process. |
|
764
eadba1b6a721
vfork interface (for poor BSD ultrix) - without it, it takes 20 seconds
Claus Gittinger <cg@exept.de>
parents:
763
diff
changeset
|
3105 |
|
676 | 3106 |
In normal situations, you dont need to use this low level entry; see |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
3107 |
#startProcess: and #executCommand: for higher level interfaces." |
68 | 3108 |
|
3109 |
%{ /* NOCONTEXT */ |
|
792 | 3110 |
#ifndef MSDOS_LIKE |
616 | 3111 |
|
3112 |
int pid; |
|
3113 |
||
3114 |
pid = fork(); |
|
1135 | 3115 |
RETURN ( __MKSMALLINT(pid) ); |
792 | 3116 |
#endif |
3117 |
%}. |
|
3118 |
"/ |
|
3119 |
"/ not supported by OS |
|
3120 |
"/ |
|
3121 |
^ self primitiveFailed |
|
3122 |
||
616 | 3123 |
" |
3124 |
|id| |
|
3125 |
||
3126 |
id := OperatingSystem fork. |
|
3127 |
id == 0 ifTrue:[ |
|
3128 |
OperatingSystem exit |
|
3129 |
] |
|
3130 |
" |
|
68 | 3131 |
! |
3132 |
||
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3133 |
getStatusOfProcess:aProcessId |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3134 |
"wait for a process to terminate and fetch its exit status. |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3135 |
This is required to avoid zombie processes." |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3136 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3137 |
%{ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3138 |
#ifndef MSDOS_LIKE |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3139 |
int status; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3140 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3141 |
if (__isSmallInteger(aProcessId)) { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3142 |
pid_t pid = (pid_t)(__intVal(aProcessId)); |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3143 |
{ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3144 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3145 |
# ifdef NO_WAITPID |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3146 |
pid_t child; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3147 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3148 |
do { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3149 |
__BEGIN_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3150 |
child = __wait (&status); |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3151 |
__END_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3152 |
if (child < 0 && errno != EINTR) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
3153 |
fprintf(stderr, "OS: child-wait errno=%d\n", errno); |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3154 |
status = -1; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3155 |
break; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3156 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3157 |
} while (child != pid); |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3158 |
# else |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3159 |
pid_t child; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3160 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3161 |
/* claus: the original did not care for EINTR here ... */ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3162 |
do { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3163 |
__BEGIN_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3164 |
child = __waitpid (pid, &status, 0); |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3165 |
__END_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3166 |
} while ((child != pid) && (errno == EINTR)); |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3167 |
if (child != pid) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
3168 |
fprintf(stderr, "OS: child-waitpid errno=%d\n", errno); |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3169 |
status = -1; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3170 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3171 |
# endif /* NO_WAITPID */ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3172 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3173 |
RETURN ( __MKSMALLINT(status)); |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3174 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3175 |
#endif |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3176 |
%}. |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3177 |
self primitiveFailed |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3178 |
|
1034 | 3179 |
! |
3180 |
||
3181 |
pathOfCommand:aCommand |
|
3182 |
"find where aCommand's executable file is" |
|
3183 |
||
3184 |
|path f| |
|
3185 |
||
3186 |
path := self getEnvironment:'PATH'. |
|
3187 |
path notNil ifTrue:[ |
|
3188 |
(path asCollectionOfSubstringsSeparatedBy:$:) do:[:path | |
|
3189 |
(f := (path asFilename construct:aCommand)) isExecutable ifTrue:[ |
|
3190 |
^ f pathName |
|
3191 |
] |
|
3192 |
]. |
|
3193 |
]. |
|
3194 |
^ nil |
|
3195 |
||
3196 |
" |
|
3197 |
OperatingSystem pathOfCommand:'fooBar' |
|
3198 |
OperatingSystem pathOfCommand:'ls' |
|
3199 |
OperatingSystem pathOfCommand:'cvs' |
|
3200 |
" |
|
3201 |
! |
|
3202 |
||
3203 |
startProcess:aCommandString |
|
3204 |
"start executing the unix command as specified by the argument, aCommandString |
|
3205 |
as a separate process; do not wait for the command to finish. |
|
3206 |
The commandString is passed to a shell for execution - see the description of |
|
3207 |
'sh -c' in your UNIX manual. |
|
3208 |
Return the processId if successful, nil otherwise. |
|
3209 |
Use #waitForProcess: for synchronization and exec status return, |
|
3210 |
or #killProcess: to stop it." |
|
3211 |
||
3212 |
^ self |
|
3213 |
exec:'/bin/sh' |
|
3214 |
withArguments:(Array with:'sh' with:'-c' with:aCommandString) |
|
3215 |
fork:true. |
|
3216 |
||
3217 |
" |
|
3218 |
|pid| |
|
3219 |
||
3220 |
pid := OperatingSystem startProcess:'sleep 2; echo 1; sleep 2; echo 2'. |
|
3221 |
(Delay forSeconds:3) wait. |
|
3222 |
OperatingSystem killProcess:pid. |
|
3223 |
" |
|
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3224 |
! |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3225 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3226 |
startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream errorTo:anExternalErrStream |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3227 |
"start executing the unix command as specified by the argument, aCommandString |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3228 |
as a separate process; do not wait for the command to finish. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3229 |
The commandString is passed to a shell for execution - see the description of |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3230 |
'sh -c' in your UNIX manual. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3231 |
The command gets stdIn, stdOut and stdErr assigned from the arguments; |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3232 |
each may be nil. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3233 |
Return the processId if successful, nil otherwise. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3234 |
Use #monitorPid:action: for synchronization and exec status return, |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3235 |
or #killProcess: to stop it." |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3236 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3237 |
|in out err| |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3238 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3239 |
anExternalInStream notNil ifTrue:[ |
1487 | 3240 |
in := anExternalInStream fileDescriptor. |
1046 | 3241 |
] ifFalse:[ |
1487 | 3242 |
in := '/dev/null' asFilename readStream fileDescriptor |
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3243 |
]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3244 |
anExternalOutStream notNil ifTrue:[ |
1487 | 3245 |
out := anExternalOutStream fileDescriptor. |
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3246 |
]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3247 |
anExternalErrStream notNil ifTrue:[ |
1487 | 3248 |
err := anExternalErrStream fileDescriptor. |
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3249 |
]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3250 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3251 |
^ self |
1487 | 3252 |
exec:'/bin/sh' |
3253 |
withArguments:(Array with:'sh' with:'-c' with:aCommandString) |
|
3254 |
fileDescriptors:(Array with:in with:out with:err) |
|
3255 |
fork:true. |
|
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3256 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3257 |
"blocking at current prio (i.e. only higher prio threads execute): |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3258 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3259 |
OperatingSystem executeCommand:'ls -l > out'. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3260 |
" |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3261 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3262 |
"non-blocking (lower prio threads continue): |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3263 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3264 |
|in out err pid sema| |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3265 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3266 |
in := 'out' asFilename readStream. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3267 |
out := 'out2' asFilename writeStream. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3268 |
err := 'err' asFilename writeStream. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3269 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3270 |
sema := Semaphore new. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3271 |
pid := OperatingSystem startProcess:'sleep 10; grep drw' inputFrom:in outputTo:out errorTo:err. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3272 |
pid notNil ifTrue:[ |
1487 | 3273 |
Processor monitorPid:pid action:[:OSstatus | sema signal ]. |
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3274 |
]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3275 |
in close. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3276 |
out close. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3277 |
err close. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3278 |
sema wait. |
1422 | 3279 |
Transcript showCR:'finished' |
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3280 |
" |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3281 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3282 |
"Created: 29.2.1996 / 12:31:29 / cg" |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3283 |
"Modified: 29.2.1996 / 12:49:14 / cg" |
616 | 3284 |
! ! |
3285 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
3286 |
!OperatingSystem class methodsFor:'file access'! |
616 | 3287 |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3288 |
closeFd:anInteger |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3289 |
"low level close of a filedescriptor" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3290 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3291 |
%{ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3292 |
#if !defined(transputer) && !defined(MSDOS_LIKE) |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3293 |
if (__isSmallInteger(anInteger)) { |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3294 |
close(__intVal(anInteger)); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3295 |
RETURN(self); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3296 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3297 |
#endif |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3298 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3299 |
^ self primitiveFailed. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3300 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3301 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3302 |
createDirectory:newPathName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3303 |
"create a new directory with name 'newPathName'. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3304 |
Return true if successful, false if failed. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3305 |
This is a low-level entry - use Filename protocol for compatibility." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3306 |
|
1497 | 3307 |
"/ if it already exists this is ok |
3308 |
||
3309 |
(self isDirectory:newPathName) ifTrue:[^ true]. |
|
3310 |
||
3311 |
"/ since createDirectory is not used too often, |
|
3312 |
"/ you'll forgive me using mkdir ... |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3313 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3314 |
^ self executeCommand:('mkdir 2>/dev/null ', newPathName) |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3315 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3316 |
" |
1497 | 3317 |
OperatingSystem createDirectory:'foo' |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3318 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3319 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3320 |
"Modified: 20.12.1995 / 11:24:13 / stefan" |
1497 | 3321 |
"Modified: 29.6.1996 / 14:06:54 / cg" |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3322 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3323 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3324 |
linkFile:oldPath to:newPath |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3325 |
"link the file 'oldPath' to 'newPath'. The link will be a hard link. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3326 |
Return true if successful, false if not." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3327 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3328 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3329 |
#ifndef MSDOS_LIKE |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3330 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3331 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3332 |
if (__isString(oldPath) && __isString(newPath)) { |
1487 | 3333 |
__BEGIN_INTERRUPTABLE__ |
3334 |
do { |
|
3335 |
ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath)); |
|
3336 |
} while (ret < 0 && errno == EINTR); |
|
3337 |
__END_INTERRUPTABLE__ |
|
3338 |
if (ret < 0) { |
|
3339 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3340 |
RETURN ( false ); |
|
3341 |
} |
|
3342 |
RETURN (true); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3343 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3344 |
#endif |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3345 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3346 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3347 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3348 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3349 |
OperatingSystem linkFile:'foo' to:'bar' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3350 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3351 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3352 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3353 |
makePipe |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3354 |
"make a pipe, return array with two filedescriptors on success, |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3355 |
nil on failure. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3356 |
This is a lowLevel entry, not for public use. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3357 |
See ExternalStream>>makePipe for a more user-friendly, public interface." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3358 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3359 |
|fd1 fd2| |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3360 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3361 |
%{ |
1597 | 3362 |
#ifdef UNIX_LIKE |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3363 |
int fds[2]; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3364 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3365 |
if (pipe(fds) < 0) { |
1487 | 3366 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
3367 |
RETURN ( nil ); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3368 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3369 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3370 |
fd1 = __MKSMALLINT(fds[0]); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3371 |
fd2 = __MKSMALLINT(fds[1]); |
1597 | 3372 |
#endif |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3373 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3374 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3375 |
^ Array with:fd1 with:fd2. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3376 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3377 |
|
1132 | 3378 |
recursiveCopyDirectory:sourcePathName to:destination |
3379 |
"copy the directory named 'sourcePathName' and all contained files/directories to 'destination'. |
|
3380 |
Return true if successful." |
|
3381 |
||
3382 |
^ self executeCommand:('cp -rf ' , sourcePathName, ' ', destination) |
|
3383 |
||
3384 |
"Modified: 7.3.1996 / 15:26:30 / cg" |
|
3385 |
! |
|
3386 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3387 |
recursiveCreateDirectory:dirName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3388 |
"create a directory - with all parent dirs if needed. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3389 |
Return true if successful, false otherwise. If false |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3390 |
is returned, a partial created tree may be left, |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3391 |
which is not cleaned-up here." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3392 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3393 |
self createDirectory:dirName. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3394 |
(self isDirectory:dirName) ifFalse:[ |
1487 | 3395 |
(self recursiveCreateDirectory:(self directoryNameOf:dirName)) ifFalse:[^ false]. |
3396 |
^ self createDirectory:dirName |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3397 |
]. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3398 |
^ true |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3399 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3400 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3401 |
OperatingSystem recursiveCreateDirectory:'foo/bar/baz' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3402 |
OperatingSystem recursiveRemoveDirectory:'foo' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3403 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3404 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3405 |
"Modified: 7.3.1996 / 15:26:22 / cg" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3406 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3407 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3408 |
recursiveRemoveDirectory:fullPathName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3409 |
"remove the directory named 'fullPathName' and all contained files/directories. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3410 |
Return true if successful." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3411 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3412 |
^ self executeCommand:('rm -rf ' , fullPathName) |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3413 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3414 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3415 |
OperatingSystem recursiveCreateDirectory:'foo/bar/baz' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3416 |
OperatingSystem recursiveRemoveDirectory:'foo' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3417 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3418 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3419 |
"Modified: 7.3.1996 / 15:26:30 / cg" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3420 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3421 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3422 |
removeDirectory:fullPathName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3423 |
"remove the directory named 'fullPathName'. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3424 |
Return true if successful, false if directory is not empty or no permission. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3425 |
This is a lowLevel entry - use Filename protocol for compatibility." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3426 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3427 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3428 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3429 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3430 |
if (__isString(fullPathName)) { |
1487 | 3431 |
__BEGIN_INTERRUPTABLE__ |
3432 |
do { |
|
3433 |
ret = rmdir((char *) __stringVal(fullPathName)); |
|
3434 |
} while (ret < 0 && errno == EINTR); |
|
3435 |
__END_INTERRUPTABLE__ |
|
3436 |
if (ret < 0) { |
|
3437 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3438 |
RETURN ( false ); |
|
3439 |
} |
|
3440 |
RETURN (true); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3441 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3442 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3443 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3444 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3445 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3446 |
OperatingSystem createDirectory:'foo' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3447 |
OperatingSystem removeDirectory:'foo' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3448 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3449 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3450 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3451 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3452 |
removeFile:fullPathName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3453 |
"remove the file named 'fullPathName'; return true if successful. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3454 |
This is a lowLevel entry - use Filename protocol for compatibility." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3455 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3456 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3457 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3458 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3459 |
if (__isString(fullPathName)) { |
1487 | 3460 |
__BEGIN_INTERRUPTABLE__ |
3461 |
do { |
|
3462 |
ret = unlink((char *) __stringVal(fullPathName)); |
|
3463 |
} while (ret < 0 && errno == EINTR); |
|
3464 |
__END_INTERRUPTABLE__ |
|
3465 |
if (ret < 0) { |
|
3466 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3467 |
RETURN ( false ); |
|
3468 |
} |
|
3469 |
RETURN (true); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3470 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3471 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3472 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3473 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3474 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3475 |
renameFile:oldPath to:newPath |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3476 |
"rename the file 'oldPath' to 'newPath'. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3477 |
Return true if successful, false if not" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3478 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3479 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3480 |
int ret, eno; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3481 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3482 |
if (__isString(oldPath) && __isString(newPath)) { |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3483 |
#if defined(HAS_RENAME) |
1487 | 3484 |
__BEGIN_INTERRUPTABLE__ |
3485 |
do { |
|
3486 |
ret = rename((char *) __stringVal(oldPath), (char *) __stringVal(newPath)); |
|
3487 |
} while (ret < 0 && errno == EINTR); |
|
3488 |
__END_INTERRUPTABLE__ |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3489 |
#else |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3490 |
# ifndef MSDOS_LIKE |
1487 | 3491 |
ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath)); |
3492 |
if (ret >= 0) { |
|
3493 |
ret = unlink((char *) __stringVal(oldPath)); |
|
3494 |
if (ret < 0) { |
|
3495 |
eno = errno; |
|
3496 |
unlink((char *) __stringVal(newPath)); |
|
3497 |
errno = eno; |
|
3498 |
} |
|
3499 |
} |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3500 |
# endif |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3501 |
#endif |
1487 | 3502 |
if (ret < 0) { |
3503 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3504 |
RETURN ( false ); |
|
3505 |
} |
|
3506 |
RETURN (true); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3507 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3508 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3509 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3510 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3511 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3512 |
OperatingSystem renameFile:'foo' to:'bar' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3513 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3514 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3515 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3516 |
truncateFile:aPathName to:newSize |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3517 |
"change a files size return true on success, false on failure. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3518 |
This may not be supported on all architectures. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3519 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3520 |
This is a low-level entry - use Filename protocol." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3521 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3522 |
%{ |
1623
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3523 |
#ifdef HAS_TRUNCATE |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3524 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3525 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3526 |
if (__isString(aPathName) |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3527 |
&& __isSmallInteger(newSize)) { |
1487 | 3528 |
__BEGIN_INTERRUPTABLE__ |
3529 |
do { |
|
3530 |
ret = truncate((char *) __stringVal(aPathName), __intVal(newSize)); |
|
3531 |
} while (ret < 0 && errno == EINTR); |
|
3532 |
__END_INTERRUPTABLE__ |
|
3533 |
if (ret < 0) { |
|
3534 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3535 |
RETURN ( false ); |
|
3536 |
} |
|
3537 |
RETURN (true); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3538 |
} |
1623
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3539 |
#else |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3540 |
# ifdef HAS_FTRUNCATE |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3541 |
int ret; |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3542 |
int fd; |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3543 |
|
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3544 |
if (__isString(aPathName) |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3545 |
&& __isSmallInteger(newSize)) { |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3546 |
do { |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3547 |
fd = open((char *) __stringVal(aPathName), 2); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3548 |
} while (fd < 0 && errno == EINTR); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3549 |
if (fd < 0) { |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3550 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3551 |
RETURN ( false ); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3552 |
} |
1632 | 3553 |
|
1623
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3554 |
ret = ftruncate(fd, __intVal(newSize)); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3555 |
close(fd); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3556 |
if (ret < 0) { |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3557 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3558 |
RETURN ( false ); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3559 |
} |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3560 |
RETURN (true); |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3561 |
} |
95009f9bfc18
use ftruncate if truncate is not available
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3562 |
# endif /* using FTRUNCATE */ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3563 |
#endif |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3564 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3565 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3566 |
! ! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3567 |
|
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
3568 |
!OperatingSystem class methodsFor:'file access rights'! |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3569 |
|
616 | 3570 |
accessMaskFor:aSymbol |
3571 |
"return the access bits mask for numbers as returned by |
|
3572 |
OperatingSystem>>accessModeOf: |
|
3573 |
and expected by OperatingSystem>>changeAccessModeOf:to:. |
|
3574 |
Since these numbers are OS dependent, always use the mask |
|
3575 |
(never hardcode 8rxxx into your code)." |
|
68 | 3576 |
|
3577 |
%{ /* NOCONTEXT */ |
|
616 | 3578 |
# ifndef S_IRUSR |
3579 |
/* posix systems should define these ... */ |
|
3580 |
# define S_IRUSR 0400 |
|
3581 |
# define S_IWUSR 0200 |
|
3582 |
# define S_IXUSR 0100 |
|
3583 |
# define S_IRGRP 0040 |
|
3584 |
# define S_IWGRP 0020 |
|
3585 |
# define S_IXGRP 0010 |
|
3586 |
# define S_IROTH 0004 |
|
3587 |
# define S_IWOTH 0002 |
|
3588 |
# define S_IXOTH 0001 |
|
3589 |
||
3590 |
# endif |
|
3591 |
||
3592 |
if (aSymbol == @symbol(readUser)) { |
|
1135 | 3593 |
RETURN ( __MKSMALLINT(S_IRUSR) ); |
616 | 3594 |
} |
3595 |
if (aSymbol == @symbol(writeUser)) { |
|
1135 | 3596 |
RETURN ( __MKSMALLINT(S_IWUSR) ); |
616 | 3597 |
} |
3598 |
if (aSymbol == @symbol(executeUser)) { |
|
1135 | 3599 |
RETURN ( __MKSMALLINT(S_IXUSR) ); |
616 | 3600 |
} |
3601 |
if (aSymbol == @symbol(readGroup)) { |
|
1135 | 3602 |
RETURN ( __MKSMALLINT(S_IRGRP) ); |
616 | 3603 |
} |
3604 |
if (aSymbol == @symbol(writeGroup)) { |
|
1135 | 3605 |
RETURN ( __MKSMALLINT(S_IWGRP) ); |
616 | 3606 |
} |
3607 |
if (aSymbol == @symbol(executeGroup)) { |
|
1135 | 3608 |
RETURN ( __MKSMALLINT(S_IXGRP) ); |
616 | 3609 |
} |
3610 |
if (aSymbol == @symbol(readOthers)) { |
|
1135 | 3611 |
RETURN ( __MKSMALLINT(S_IROTH) ); |
616 | 3612 |
} |
3613 |
if (aSymbol == @symbol(writeOthers)) { |
|
1135 | 3614 |
RETURN ( __MKSMALLINT(S_IWOTH) ); |
616 | 3615 |
} |
3616 |
if (aSymbol == @symbol(executeOthers)) { |
|
1135 | 3617 |
RETURN ( __MKSMALLINT(S_IXOTH) ); |
616 | 3618 |
} |
3619 |
%}. |
|
792 | 3620 |
^ self primitiveFailed |
616 | 3621 |
|
3622 |
" |
|
3623 |
OperatingSystem accessMaskFor:#readUser |
|
3624 |
" |
|
68 | 3625 |
! |
3626 |
||
616 | 3627 |
accessModeOf:aPathName |
3628 |
"return a number representing access rights rwxrwxrwx for owner, |
|
3629 |
group and others. Return nil if such a file does not exist. |
|
3630 |
Notice that the returned number is OS dependent - use the |
|
3631 |
modeMasks as returned by OperatingSystem>>accessMaskFor:" |
|
3632 |
||
3633 |
" |
|
3634 |
this could have been implemented as: |
|
1487 | 3635 |
(self infoOf:aPathName) at:#mode |
616 | 3636 |
but for huge directory searches the code below is faster |
3637 |
" |
|
345 | 3638 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3639 |
%{ |
616 | 3640 |
struct stat buf; |
3641 |
int ret; |
|
3642 |
||
3643 |
if (__isString(aPathName)) { |
|
1487 | 3644 |
__BEGIN_INTERRUPTABLE__ |
3645 |
do { |
|
3646 |
ret = stat((char *) __stringVal(aPathName), &buf); |
|
3647 |
} while ((ret < 0) && (errno == EINTR)); |
|
3648 |
__END_INTERRUPTABLE__ |
|
3649 |
||
3650 |
if (ret < 0) { |
|
3651 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3652 |
RETURN ( nil ); |
|
3653 |
} |
|
3654 |
RETURN ( __MKSMALLINT(buf.st_mode & 0777) ); |
|
616 | 3655 |
} |
3656 |
%}. |
|
792 | 3657 |
^ self primitiveFailed |
616 | 3658 |
|
3659 |
" |
|
3660 |
(OperatingSystem accessModeOf:'/') printStringRadix:8 |
|
3661 |
" |
|
345 | 3662 |
! |
3663 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3664 |
changeAccessModeOf:aPathName to:modeBits |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3665 |
"change the access rights of aPathName to the OS dependent modeBits. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3666 |
You should construct this mask using accessMaskFor, to be OS |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3667 |
independent. Return true if changed, |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3668 |
false if such a file does not exist or change was not allowd." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3669 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3670 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3671 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3672 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3673 |
if (__isString(aPathName) && __isSmallInteger(modeBits)) { |
1487 | 3674 |
__BEGIN_INTERRUPTABLE__ |
3675 |
do { |
|
3676 |
ret = chmod((char *)__stringVal(aPathName), __intVal(modeBits)); |
|
3677 |
} while (ret < 0 && errno == EINTR); |
|
3678 |
__END_INTERRUPTABLE__ |
|
3679 |
if (ret < 0) { |
|
3680 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3681 |
RETURN ( false ); |
|
3682 |
} |
|
3683 |
RETURN ( true ); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3684 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3685 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3686 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3687 |
! ! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3688 |
|
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
3689 |
!OperatingSystem class methodsFor:'file locking'! |
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3690 |
|
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3691 |
lockFD:aFileDescriptor shared:isSharedReadLock blocking:blockIfLocked |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3692 |
"set a lock on the file represented by aFileDescriptor. |
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3693 |
(such as returned by ExternalStream>>fileDescriptor). |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3694 |
On some systems, only advisory locks are available - |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3695 |
these depends on other accessors to also perform the locking operation. |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3696 |
If they do not, they may still access the file |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3697 |
(on some systems, locks are mandatory, on others, they are advisory). |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3698 |
The isSharedReadLock argument (if true) specifies if multiple readers |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3699 |
are to be allowed - if false, they are not. |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3700 |
On some systems, all locks are non-exclusive locks. |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3701 |
|
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3702 |
Returns true, if the lock was aquired, false otherwise. |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3703 |
|
1616
fa734ea238f8
type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents:
1615
diff
changeset
|
3704 |
Notice, that not all OS's support these locks; |
fa734ea238f8
type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents:
1615
diff
changeset
|
3705 |
on some, this may simply be a no-op. |
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3706 |
Also notice, that some systems block the process, to wait for the lock. |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3707 |
This can (again: on some systems) be avoided by passing a false blockIfLocked |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3708 |
argument." |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3709 |
|
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3710 |
%{ |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3711 |
if (__isSmallInteger(aFileDescriptor)) { |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3712 |
int fd = __intVal(aFileDescriptor); |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3713 |
int lockArg; |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3714 |
|
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3715 |
/* |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3716 |
* claus: sigh - each one has a different interface ... |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3717 |
*/ |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3718 |
#if defined(F_SETLK) |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3719 |
{ |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3720 |
/* |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3721 |
* new fcntl(SETLK) interface; |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3722 |
* available on SYSV4 and Linux |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3723 |
*/ |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3724 |
struct flock flock; |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3725 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3726 |
if (isSharedReadLock == true) { |
1632 | 3727 |
flock.l_type = F_RDLCK; |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3728 |
} else { |
1632 | 3729 |
flock.l_type = F_WRLCK; |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3730 |
} |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3731 |
flock.l_whence = 0; |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3732 |
flock.l_start = 0; |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3733 |
flock.l_len = 0; |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3734 |
lockArg = F_SETLK; |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3735 |
# if defined(F_SETLKW) |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3736 |
if (blockIfLocked == true) { |
1632 | 3737 |
lockArg = F_SETLKW; |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3738 |
} |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3739 |
# endif |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3740 |
if (fcntl(fd, lockArg, &flock) != -1) { |
1632 | 3741 |
RETURN (true); |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3742 |
} |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3743 |
} |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3744 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3745 |
#else /* no F_SETLK available */ |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3746 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3747 |
# if defined(LOCK_EX) && defined(LOCK_UN) |
1632 | 3748 |
/* |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3749 |
* BSD 4.3 advisory locks |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3750 |
*/ |
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3751 |
lockArg = LOCK_EX; |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3752 |
# if defined(LOCK_SH) |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3753 |
if (isSharedReadLock == true) { |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3754 |
lockArg = LOCK_SH |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3755 |
} |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3756 |
# endif |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3757 |
# if defined(LOCK_NB) |
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3758 |
if (blockIfLocked == false) { |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3759 |
lockArg |= LOCK_NB; |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3760 |
} |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3761 |
# endif |
1632 | 3762 |
if (flock(fd, lockArg) != -1) { |
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3763 |
RETURN (true); |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3764 |
} |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3765 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3766 |
# else /* no flock available */ |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3767 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3768 |
# if defined(F_LOCK) && defined(F_UNLOCK) |
1632 | 3769 |
/* |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3770 |
* SYSV3 advisory locks |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3771 |
*/ |
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3772 |
if (lockf(fd, F_LOCK, 0) != -1) { |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3773 |
RETURN (true); |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3774 |
} |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3775 |
# endif |
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3776 |
# endif |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3777 |
#endif |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3778 |
} |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3779 |
%}. |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3780 |
^ false |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3781 |
! |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3782 |
|
1616
fa734ea238f8
type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents:
1615
diff
changeset
|
3783 |
supportsFileLocks |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3784 |
"return true, if the OS supports file locking" |
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3785 |
|
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3786 |
%{ /* NOCONTEXT */ |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3787 |
#if defined(F_SETLK) |
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3788 |
RETURN (true); |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3789 |
#else |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3790 |
# if defined(LOCK_EX) && defined(LOCK_UN) |
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3791 |
RETURN (true); |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3792 |
# else |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3793 |
# if defined(F_LOCK) && defined(F_UNLOCK) |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3794 |
RETURN (true); |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3795 |
# endif |
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3796 |
# endif |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3797 |
#endif |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3798 |
%}. |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3799 |
^ false |
1616
fa734ea238f8
type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents:
1615
diff
changeset
|
3800 |
|
fa734ea238f8
type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents:
1615
diff
changeset
|
3801 |
" |
fa734ea238f8
type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents:
1615
diff
changeset
|
3802 |
OperatingSystem supportsFileLocks |
fa734ea238f8
type & include file.h on all systems
Claus Gittinger <cg@exept.de>
parents:
1615
diff
changeset
|
3803 |
" |
1617
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3804 |
! |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3805 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3806 |
supportsNonBlockingFileLocks |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3807 |
"return true, if the OS supports nonBlocking file locking |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3808 |
(i.e. with immediate return instead of waiting for the lock)" |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3809 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3810 |
%{ /* NOCONTEXT */ |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3811 |
#if defined(F_SETLK) && defined(F_SETLKW) |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3812 |
RETURN (true); |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3813 |
#else |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3814 |
# if defined(LOCK_EX) && defined(LOCK_UN) && defined(LOCK_NB) |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3815 |
RETURN (true); |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3816 |
# endif |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3817 |
#endif |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3818 |
%}. |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3819 |
^ false |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3820 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3821 |
" |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3822 |
OperatingSystem supportsNonBlockingFileLocks |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3823 |
" |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3824 |
! |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3825 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3826 |
supportsSharedLocks |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3827 |
"return true, if the OS supports shared (i.e. multiple reader) |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3828 |
file locking." |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3829 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3830 |
%{ /* NOCONTEXT */ |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3831 |
#if defined(F_SETLK) && defined(F_RDLCK) && defined(F_WRLCK) |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3832 |
RETURN (true); |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3833 |
#else |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3834 |
# if defined(LOCK_EX) && defined(LOCK_SH) && defined(LOCK_UN) |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3835 |
RETURN (true); |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3836 |
# endif |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3837 |
#endif |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3838 |
%}. |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3839 |
^ false |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3840 |
|
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3841 |
" |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3842 |
OperatingSystem supportsNonBlockingFileLocks |
9b72f5efb8cb
added fcntl based file locking
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
3843 |
" |
1621 | 3844 |
! |
3845 |
||
3846 |
unlockFD:aFileDescriptor |
|
3847 |
"clear a file lock on the file represented by aFileDescriptor, |
|
3848 |
which was previously aquired by #lockFD:. |
|
3849 |
Return false, if the unlock failed |
|
3850 |
(which may happens when a wrong fd is passed, |
|
3851 |
no lock was set previously, or the systsem does not support locks). |
|
3852 |
Notice, that not all OS's support file locks; |
|
3853 |
on some, this may simply be a no-op." |
|
3854 |
||
3855 |
%{ |
|
3856 |
if (__isSmallInteger(aFileDescriptor)) { |
|
1632 | 3857 |
int fd = __intVal(aFileDescriptor); |
3858 |
||
3859 |
/* |
|
3860 |
* claus: sigh - each one has a different interface ... |
|
3861 |
*/ |
|
1621 | 3862 |
#if defined(F_SETLK) |
3863 |
{ |
|
1632 | 3864 |
/* |
3865 |
* new fcntl(SETLK) interface; |
|
3866 |
* available on SYSV4 and Linux |
|
3867 |
*/ |
|
3868 |
struct flock flock; |
|
3869 |
||
3870 |
flock.l_type = F_UNLCK; |
|
3871 |
flock.l_whence = 0; |
|
3872 |
flock.l_start = 0; |
|
3873 |
flock.l_len = 0; |
|
3874 |
if (fcntl(fd, F_SETLK, &flock) != -1) { |
|
3875 |
RETURN (true); |
|
3876 |
} |
|
1621 | 3877 |
} |
3878 |
||
3879 |
#else /* no F_SETLK available */ |
|
3880 |
||
3881 |
# if defined(LOCK_EX) && defined(LOCK_UN) |
|
1632 | 3882 |
/* |
1621 | 3883 |
* BSD 4.3 advisory locks |
3884 |
*/ |
|
1632 | 3885 |
if (flock(fd, LOCK_UN) != -1) { |
3886 |
RETURN (true); |
|
3887 |
} |
|
1621 | 3888 |
|
3889 |
# else /* no flock available */ |
|
3890 |
||
3891 |
# if defined(F_LOCK) && defined(F_UNLOCK) |
|
3892 |
/* |
|
3893 |
* SYSV3 advisory locks |
|
3894 |
*/ |
|
3895 |
if (lockf(fd, F_UNLOCK, 0) != -1) { |
|
3896 |
RETURN (true); |
|
3897 |
} |
|
3898 |
# endif |
|
3899 |
# endif |
|
3900 |
#endif |
|
3901 |
} |
|
3902 |
%}. |
|
3903 |
^ false |
|
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3904 |
! ! |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3905 |
|
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
3906 |
!OperatingSystem class methodsFor:'file queries'! |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3907 |
|
616 | 3908 |
baseNameOf:aPathString |
3909 |
"return the baseName of the argument, aPathString |
|
3910 |
- thats the file/directory name without leading parent-dirs |
|
3911 |
(i.e. OperatingSystem baseNameOf:'/usr/lib/st/file' -> 'file' |
|
3912 |
and OperatingSystem baseNameOf:'/usr/lib' -> lib). |
|
3913 |
This method does not check if the path is valid |
|
3914 |
(i.e. if these directories really exist & is readable)." |
|
3915 |
||
3916 |
|prev index sep| |
|
3917 |
||
3918 |
sep := self fileSeparator. |
|
3919 |
((aPathString size == 1) and:[(aPathString at:1) == sep]) ifTrue:[ |
|
3920 |
^ aPathString |
|
3921 |
]. |
|
3922 |
prev := 1. |
|
3923 |
[true] whileTrue:[ |
|
3924 |
index := aPathString indexOf:sep startingAt:prev. |
|
3925 |
index == 0 ifTrue:[ |
|
3926 |
^ aPathString copyFrom:prev |
|
3927 |
]. |
|
3928 |
prev := index + 1 |
|
3929 |
] |
|
3930 |
||
3931 |
" |
|
3932 |
OperatingSystem baseNameOf:'/fee/foo/bar' |
|
3933 |
OperatingSystem baseNameOf:'foo/bar' |
|
3934 |
OperatingSystem baseNameOf:'../../foo/bar' |
|
3935 |
OperatingSystem baseNameOf:'hello' |
|
3936 |
" |
|
3937 |
! |
|
3938 |
||
3939 |
caseSensitiveFilenames |
|
3940 |
"return true, if the OS has caseSensitive file naming. |
|
3941 |
On MSDOS, this will return false. Since this is for Unix, we |
|
3942 |
return true." |
|
3943 |
||
3944 |
^ true |
|
3945 |
! |
|
3946 |
||
3947 |
compressPath:pathName |
|
3948 |
"return the pathName compressed - that is, remove all ..-entries |
|
3949 |
and . entries. This does not always (in case of symbolic links) |
|
3950 |
return the true pathName and is therefore used as a fallback |
|
3951 |
if realPath and popen failed." |
|
3952 |
||
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
3953 |
|names n "{ Class: SmallInteger }" | |
616 | 3954 |
|
3955 |
names := pathName |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3956 |
asCollectionOfSubstringsSeparatedBy:self fileSeparator. |
616 | 3957 |
names := names asOrderedCollection. |
3958 |
" |
|
3959 |
cut off initial double-slashes |
|
3960 |
" |
|
3961 |
[names startsWith:#('' '')] whileTrue:[ |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3962 |
names removeFirst. |
616 | 3963 |
]. |
3964 |
" |
|
3965 |
cut off double-slashes at end |
|
3966 |
" |
|
3967 |
[names endsWith:#('')] whileTrue:[ |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3968 |
names removeLast. |
616 | 3969 |
]. |
3970 |
" |
|
3971 |
cut off current-dir at beginning |
|
3972 |
" |
|
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
3973 |
n := names size. |
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
3974 |
[(n >= 2) and:[names startsWith:#('.')]] whileTrue:[ |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3975 |
names removeFirst. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3976 |
n := n - 1. |
616 | 3977 |
]. |
3978 |
||
3979 |
" |
|
3980 |
cut off parent-dirs at end |
|
3981 |
" |
|
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
3982 |
[(n > 2) |
616 | 3983 |
and:[(names endsWith:#('..')) |
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
3984 |
and:[((names at:(n - 1)) startsWith:'.') not ]]] whileTrue:[ |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3985 |
names removeLast; removeLast. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3986 |
n := n - 2. |
616 | 3987 |
]. |
3988 |
||
3989 |
^ names asStringWith:self fileSeparator |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3990 |
from:1 |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3991 |
to:n |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
3992 |
compressTabs:false final:nil |
616 | 3993 |
|
3994 |
" |
|
3995 |
OperatingSystem compressPath:'./..' |
|
3996 |
OperatingSystem compressPath:'/foo/bar/baz/..' |
|
3997 |
OperatingSystem compressPath:'foo/bar/baz/..' |
|
3998 |
OperatingSystem compressPath:'foo/bar/baz/../' |
|
3999 |
OperatingSystem compressPath:'foo/bar/baz/..///' |
|
4000 |
OperatingSystem compressPath:'///foo/bar/baz/..///' |
|
4001 |
" |
|
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4002 |
|
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4003 |
"Modified: 1.11.1996 / 20:13:48 / cg" |
68 | 4004 |
! |
4005 |
||
616 | 4006 |
directoryNameOf:aPathString |
4007 |
"return the directoryName of the argument, aPath |
|
4008 |
- thats the name of the directory where aPath is |
|
4009 |
(i.e. OperatingSystem directoryNameOf:'/usr/lib/st/file' -> '/usr/lib/st' |
|
4010 |
and OperatingSystem directoryNameOf:'/usr/lib' -> /usr'). |
|
4011 |
This method does not check if the path is valid |
|
4012 |
(i.e. if these directories really exist & are readable)." |
|
4013 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4014 |
|last index sep sepString p| |
616 | 4015 |
|
4016 |
sep := self fileSeparator. |
|
4017 |
sepString := sep asString. |
|
4018 |
(aPathString = sepString) ifTrue:[ |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4019 |
" |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4020 |
the trivial '/' case |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4021 |
" |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4022 |
^ aPathString |
616 | 4023 |
]. |
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4024 |
|
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4025 |
p := aPathString. |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4026 |
[p endsWith:sepString] whileTrue:[ |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4027 |
(p = sepString) ifTrue:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4028 |
^ p |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4029 |
]. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4030 |
p := p copyWithoutLast:1 |
616 | 4031 |
]. |
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4032 |
|
616 | 4033 |
last := 1. |
4034 |
[true] whileTrue:[ |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4035 |
index := p indexOf:sep startingAt:(last + 1). |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4036 |
index == 0 ifTrue:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4037 |
(last == 1) ifTrue:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4038 |
(p startsWith:sepString) ifTrue:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4039 |
^ sepString |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4040 |
]. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4041 |
^ '.' |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4042 |
]. |
616 | 4043 |
" |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4044 |
(p startsWith:sepString) ifFalse:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4045 |
(p startsWith:('..' , sepString)) ifFalse:[ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4046 |
^ './' , (p copyTo:(last - 1)) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4047 |
] |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4048 |
]. |
616 | 4049 |
" |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4050 |
^ p copyTo:(last - 1) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4051 |
]. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4052 |
last := index. |
616 | 4053 |
] |
4054 |
||
4055 |
" |
|
4056 |
OperatingSystem directoryNameOf:'/fee/foo/bar' |
|
4057 |
OperatingSystem directoryNameOf:'foo/bar' |
|
4058 |
OperatingSystem directoryNameOf:'../../foo/bar' |
|
4059 |
OperatingSystem directoryNameOf:'bar' |
|
4060 |
OperatingSystem directoryNameOf:'/bar' |
|
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4061 |
OperatingSystem directoryNameOf:'/tmp' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4062 |
OperatingSystem directoryNameOf:'/tmp///' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4063 |
OperatingSystem directoryNameOf:'/bar///' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4064 |
OperatingSystem directoryNameOf:'/bar/' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4065 |
OperatingSystem directoryNameOf:'./bar' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4066 |
OperatingSystem directoryNameOf:'/./bar' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4067 |
" |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4068 |
|
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4069 |
"Modified: 22.10.1996 / 18:53:47 / cg" |
616 | 4070 |
! |
4071 |
||
4072 |
fileSeparator |
|
4073 |
"return the character used to separate names in a path. |
|
4074 |
This character differs for MSDOS and other systems, |
|
4075 |
(but those are currently not supported - so this is some |
|
4076 |
preparation for the future)" |
|
4077 |
||
4078 |
^ $/ |
|
4079 |
! |
|
4080 |
||
4081 |
idOf:aPathName |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4082 |
"return the fileNumber (i.e. inode number) of a file. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4083 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4084 |
Not all operatingSystems may provide this - on those that do not, |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4085 |
some dummy id will be returned. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4086 |
On unix, this information can be used to check for two files being |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4087 |
physically identical, even if found in different directories |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4088 |
(i.e. if they are hardLinked)." |
616 | 4089 |
|
4090 |
" |
|
4091 |
this could have been implemented as: |
|
1487 | 4092 |
(self infoOf:aPathName) at:#id |
616 | 4093 |
but for huge directory searches the code below is faster |
4094 |
" |
|
68 | 4095 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4096 |
%{ |
616 | 4097 |
struct stat buf; |
4098 |
int ret; |
|
4099 |
||
4100 |
if (__isString(aPathName)) { |
|
1487 | 4101 |
__BEGIN_INTERRUPTABLE__ |
4102 |
do { |
|
4103 |
ret = stat((char *) __stringVal(aPathName), &buf); |
|
4104 |
} while (ret < 0 && errno == EINTR); |
|
4105 |
__END_INTERRUPTABLE__ |
|
4106 |
if (ret >= 0) { |
|
4107 |
RETURN (__MKSMALLINT(buf.st_ino)); |
|
4108 |
} |
|
4109 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
4110 |
RETURN (nil); |
|
616 | 4111 |
} |
68 | 4112 |
%} |
616 | 4113 |
. |
792 | 4114 |
^ self primitiveFailed |
616 | 4115 |
|
4116 |
"OperatingSystem idOf:'/'" |
|
68 | 4117 |
! |
4118 |
||
616 | 4119 |
infoOf:aPathName |
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4120 |
"return some object filled with info for the file 'aPathName'; |
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4121 |
the info (for which corresponding access methods are understood by |
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4122 |
the returned object) is: |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4123 |
type - a symbol giving the files fileType |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4124 |
mode - numeric access mode |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4125 |
uid - owners user id |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4126 |
gid - owners group id |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4127 |
size - files size |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4128 |
id - files number (i.e. inode number) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4129 |
accessed - last access time (as osTime-stamp) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4130 |
modified - last modification time (as osTime-stamp) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4131 |
statusChanged - last status change time (as osTime-stamp) |
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4132 |
|
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4133 |
Some of the fields may be returned as nil on systems which do not provide |
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4134 |
all of the information. |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4135 |
Return nil if such a file does not exist. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4136 |
For symbolic links, the info of the pointed-to-file is returned; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4137 |
use #linkInfoOf: to get info about the link itself. |
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4138 |
" |
616 | 4139 |
|
4140 |
|info type mode uid gid size id |
|
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4141 |
atime mtime ctime| |
616 | 4142 |
|
4143 |
%{ |
|
4144 |
struct stat buf; |
|
4145 |
int ret; |
|
4146 |
||
4147 |
if (__isString(aPathName)) { |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4148 |
__BEGIN_INTERRUPTABLE__ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4149 |
do { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4150 |
ret = stat((char *) __stringVal(aPathName), &buf); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4151 |
} while ((ret < 0) && (errno == EINTR)); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4152 |
__END_INTERRUPTABLE__ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4153 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4154 |
if (ret < 0) { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4155 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4156 |
RETURN ( nil ); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4157 |
} |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4158 |
switch (buf.st_mode & S_IFMT) { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4159 |
case S_IFDIR: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4160 |
type = @symbol(directory); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4161 |
break; |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4162 |
case S_IFREG: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4163 |
type = @symbol(regular); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4164 |
break; |
616 | 4165 |
#ifdef S_IFCHR |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4166 |
case S_IFCHR: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4167 |
type = @symbol(characterSpecial); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4168 |
break; |
616 | 4169 |
#endif |
4170 |
#ifdef S_IFBLK |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4171 |
case S_IFBLK: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4172 |
type = @symbol(blockSpecial); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4173 |
break; |
616 | 4174 |
#endif |
4175 |
#ifdef S_IFLNK |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4176 |
case S_IFLNK: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4177 |
type = @symbol(symbolicLink); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4178 |
break; |
616 | 4179 |
#endif |
4180 |
#ifdef S_IFSOCK |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4181 |
case S_IFSOCK: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4182 |
type = @symbol(socket); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4183 |
break; |
616 | 4184 |
#endif |
4185 |
#ifdef S_IFIFO |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4186 |
case S_IFIFO: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4187 |
type = @symbol(fifo); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4188 |
break; |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4189 |
#endif |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4190 |
default: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4191 |
type = @symbol(unknown); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4192 |
break; |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4193 |
} |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4194 |
mode = __MKSMALLINT(buf.st_mode & 0777); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4195 |
uid = __MKSMALLINT(buf.st_uid); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4196 |
gid = __MKSMALLINT(buf.st_gid); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4197 |
size = __MKSMALLINT(buf.st_size); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4198 |
id = __MKSMALLINT(buf.st_ino); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4199 |
atime = __MKUINT(buf.st_atime); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4200 |
mtime = __MKUINT(buf.st_mtime); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4201 |
ctime = __MKUINT(buf.st_ctime); |
616 | 4202 |
} |
4203 |
%}. |
|
4204 |
mode notNil ifTrue:[ |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4205 |
^ FileStatusInfo |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4206 |
type:type |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4207 |
mode:mode |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4208 |
uid:uid |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4209 |
gid:gid |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4210 |
size:size |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4211 |
id:id |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4212 |
accessed:(AbsoluteTime fromOSTime:(atime * 1000)) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4213 |
modified:(AbsoluteTime fromOSTime:(mtime * 1000)) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4214 |
statusChanged:(AbsoluteTime fromOSTime:(ctime * 1000)) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4215 |
path:nil |
616 | 4216 |
]. |
792 | 4217 |
^ self primitiveFailed |
616 | 4218 |
|
4219 |
" |
|
4220 |
OperatingSystem infoOf:'/' |
|
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4221 |
(OperatingSystem infoOf:'/') uid |
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4222 |
(OperatingSystem infoOf:'/') accessed |
616 | 4223 |
" |
68 | 4224 |
! |
4225 |
||
616 | 4226 |
isDirectory:aPathName |
4227 |
"return true, if 'aPathName' is a valid directory path name. |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4228 |
(i.e. exists and is a directory). |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4229 |
This also returns true for symbolic links pointing to a directory; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4230 |
if you need to check for this, use #linkInfo:." |
68 | 4231 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4232 |
%{ |
616 | 4233 |
struct stat buf; |
4234 |
int ret; |
|
4235 |
||
4236 |
if (__isString(aPathName)) { |
|
1487 | 4237 |
__BEGIN_INTERRUPTABLE__ |
4238 |
do { |
|
4239 |
ret = stat((char *) __stringVal(aPathName), &buf); |
|
4240 |
} while ((ret < 0) && (errno == EINTR)); |
|
4241 |
__END_INTERRUPTABLE__ |
|
4242 |
if (ret < 0) { |
|
4243 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
4244 |
RETURN ( false ); |
|
4245 |
} |
|
4246 |
RETURN ( ((buf.st_mode & S_IFMT) == S_IFDIR) ? true : false); |
|
616 | 4247 |
} |
4248 |
%}. |
|
792 | 4249 |
^ self primitiveFailed |
616 | 4250 |
|
4251 |
"an alternative implementation would be: |
|
1487 | 4252 |
^ (self infoOf:aPathName) at:#type == #directory |
616 | 4253 |
" |
68 | 4254 |
! |
4255 |
||
616 | 4256 |
isExecutable:aPathName |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4257 |
"return true, if the given file is executable. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4258 |
For symbolic links, the pointed-to-file is checked." |
68 | 4259 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4260 |
%{ |
616 | 4261 |
int ret; |
4262 |
||
4263 |
if (__isString(aPathName)) { |
|
1487 | 4264 |
__BEGIN_INTERRUPTABLE__ |
4265 |
do { |
|
4266 |
ret = access(__stringVal(aPathName), X_OK); |
|
4267 |
} while ((ret < 0) && (errno == EINTR)); |
|
4268 |
__END_INTERRUPTABLE__ |
|
4269 |
if (ret < 0) { |
|
4270 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
4271 |
} |
|
4272 |
RETURN ( ((ret == 0) ? true : false) ); |
|
616 | 4273 |
} |
4274 |
%}. |
|
792 | 4275 |
^ self primitiveFailed |
68 | 4276 |
! |
4277 |
||
616 | 4278 |
isReadable:aPathName |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4279 |
"return true, if the file/dir 'aPathName' is readable. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4280 |
For symbolic links, the pointed-to-file is checked." |
68 | 4281 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4282 |
%{ |
616 | 4283 |
int ret; |
4284 |
||
4285 |
if (__isString(aPathName)) { |
|
1487 | 4286 |
__BEGIN_INTERRUPTABLE__ |
4287 |
do { |
|
4288 |
ret = access(__stringVal(aPathName), R_OK); |
|
4289 |
} while ((ret < 0) && (errno == EINTR)); |
|
4290 |
__END_INTERRUPTABLE__ |
|
4291 |
if (ret < 0) { |
|
4292 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
4293 |
} |
|
4294 |
RETURN ( ((ret == 0) ? true : false) ); |
|
616 | 4295 |
} |
4296 |
%}. |
|
792 | 4297 |
^ self primitiveFailed |
68 | 4298 |
! |
4299 |
||
616 | 4300 |
isSymbolicLink:aPathName |
4301 |
"return true, if the given file is a symbolic link" |
|
4302 |
||
4303 |
^ (self linkInfoOf:aPathName) notNil |
|
4304 |
||
4305 |
" |
|
4306 |
OperatingSystem isSymbolicLink:'Make.proto' |
|
4307 |
OperatingSystem isSymbolicLink:'Makefile' |
|
4308 |
" |
|
4309 |
! |
|
4310 |
||
4311 |
isValidPath:aPathName |
|
4312 |
"return true, if 'aPathName' is a valid path name |
|
4313 |
(i.e. the file or directory exists)" |
|
68 | 4314 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4315 |
%{ |
616 | 4316 |
struct stat buf; |
4317 |
int ret; |
|
4318 |
||
4319 |
if (__isString(aPathName) || __isSymbol(aPathName) ) { |
|
4320 |
__BEGIN_INTERRUPTABLE__ |
|
4321 |
do { |
|
1135 | 4322 |
ret = stat((char *) __stringVal(aPathName), &buf); |
616 | 4323 |
} while ((ret < 0) && (errno == EINTR)); |
4324 |
__END_INTERRUPTABLE__ |
|
4325 |
if (ret < 0) { |
|
1135 | 4326 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 4327 |
RETURN (false); |
4328 |
} |
|
4329 |
RETURN ( ret ? false : true ); |
|
4330 |
} |
|
792 | 4331 |
%}. |
4332 |
^ self primitiveFailed |
|
68 | 4333 |
! |
4334 |
||
616 | 4335 |
isWritable:aPathName |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4336 |
"return true, if the given file is writable. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4337 |
For symbolic links, the pointed-to-file is checked." |
68 | 4338 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4339 |
%{ |
616 | 4340 |
int ret; |
4341 |
||
4342 |
if (__isString(aPathName)) { |
|
1487 | 4343 |
__BEGIN_INTERRUPTABLE__ |
4344 |
do { |
|
4345 |
ret = access(__stringVal(aPathName), W_OK); |
|
4346 |
} while ((ret < 0) && (errno == EINTR)); |
|
4347 |
__END_INTERRUPTABLE__ |
|
4348 |
if (ret < 0) { |
|
4349 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
4350 |
} |
|
4351 |
RETURN ( ((ret == 0) ? true : false) ); |
|
616 | 4352 |
} |
4353 |
%}. |
|
792 | 4354 |
^ self primitiveFailed |
68 | 4355 |
! |
4356 |
||
616 | 4357 |
linkInfoOf:aPathName |
4358 |
"return a dictionary filled with info for the file 'aPathName', |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4359 |
IFF aPathName is a symbolic link. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4360 |
If aPathName is invalid, or its NOT a symbolic link, nil is returned. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4361 |
|
616 | 4362 |
The contents of the dictionary gives info about the link itself, |
4363 |
on contrast to #infoOf:, which returns the info of the pointed to file |
|
4364 |
in case of a symbolic link." |
|
4365 |
||
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4366 |
|info type mode uid gid size id atime mtime ctime path| |
616 | 4367 |
|
4368 |
%{ /* STACK: 1200 */ |
|
792 | 4369 |
#ifdef S_IFLNK |
616 | 4370 |
struct stat buf; |
4371 |
int ret; |
|
4372 |
char pathBuffer[1024]; |
|
4373 |
||
4374 |
if (__isString(aPathName)) { |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4375 |
__BEGIN_INTERRUPTABLE__ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4376 |
do { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4377 |
ret = lstat((char *) __stringVal(aPathName), &buf); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4378 |
} while ((ret < 0) && (errno == EINTR)); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4379 |
__END_INTERRUPTABLE__ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4380 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4381 |
if (ret < 0) { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4382 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4383 |
RETURN ( nil ); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4384 |
} |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4385 |
switch (buf.st_mode & S_IFMT) { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4386 |
default: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4387 |
RETURN ( nil ); /* not a symbolic link */ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4388 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4389 |
case S_IFLNK: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4390 |
type = @symbol(symbolicLink); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4391 |
break; |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4392 |
} |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4393 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4394 |
mode = __MKSMALLINT(buf.st_mode & 0777); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4395 |
uid = __MKSMALLINT(buf.st_uid); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4396 |
gid = __MKSMALLINT(buf.st_gid); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4397 |
size = __MKSMALLINT(buf.st_size); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4398 |
id = __MKSMALLINT(buf.st_ino); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4399 |
atime = __MKUINT(buf.st_atime); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4400 |
mtime = __MKUINT(buf.st_mtime); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4401 |
ctime = __MKUINT(buf.st_ctime); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4402 |
if ((ret = readlink((char *) __stringVal(aPathName), pathBuffer, sizeof(pathBuffer))) < 0) { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4403 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4404 |
RETURN ( nil ); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4405 |
} |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4406 |
pathBuffer[ret] = '\0'; /* readlink does not 0-terminate */ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4407 |
path = __MKSTRING(pathBuffer); |
616 | 4408 |
} |
792 | 4409 |
#else |
4410 |
RETURN ( nil ); |
|
4411 |
#endif |
|
616 | 4412 |
%}. |
4413 |
mode notNil ifTrue:[ |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4414 |
info := IdentityDictionary new. |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4415 |
^ FileStatusInfo |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4416 |
type:type |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4417 |
mode:mode |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4418 |
uid:uid |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4419 |
gid:gid |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4420 |
size:size |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4421 |
id:id |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4422 |
accessed:(AbsoluteTime fromOSTime:(atime * 1000)) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4423 |
modified:(AbsoluteTime fromOSTime:(mtime * 1000)) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4424 |
statusChanged:(AbsoluteTime fromOSTime:(ctime * 1000)) |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4425 |
path:path |
616 | 4426 |
]. |
792 | 4427 |
^ self primitiveFailed |
616 | 4428 |
|
4429 |
" |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4430 |
OperatingSystem infoOf:'Make.proto' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4431 |
OperatingSystem linkInfoOf:'Make.proto' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4432 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4433 |
OperatingSystem infoOf:'resources/motif.style' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4434 |
OperatingSystem linkInfoOf:'resources/motif.style' |
616 | 4435 |
" |
4436 |
! |
|
4437 |
||
4438 |
parentDirectoryName |
|
4439 |
"return the name used to refer to parent directories. |
|
4440 |
In MSDOS, Unix and other systems this is '..', but maybe different |
|
4441 |
for other systems. |
|
4442 |
(but those are currently not supported - so this is some |
|
4443 |
preparation for the future)" |
|
4444 |
||
4445 |
^ '..' |
|
68 | 4446 |
! |
4447 |
||
616 | 4448 |
pathNameOf:pathName |
4449 |
"return the pathName of the argument, aPathString, |
|
4450 |
- thats the full pathname of the directory, starting at '/'. |
|
4451 |
This method needs the path to be valid |
|
4452 |
(i.e. all directories must exist, be readable and executable). |
|
4453 |
Notice: if symbolic links are involved, the result may look different |
|
4454 |
from what you expect." |
|
4455 |
||
4456 |
|p path command| |
|
4457 |
||
4458 |
"some systems have a convenient function for this ..." |
|
4459 |
path := self primPathNameOf:pathName. |
|
4460 |
||
4461 |
path isNil ifTrue:[ |
|
2080
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4462 |
(self isValidPath:pathName) ifFalse:[ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4463 |
p := pathName. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4464 |
[(p size > 1) |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4465 |
and:[p endsWith:(self fileSeparator)] |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4466 |
] whileTrue:[ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4467 |
p := p copyWithoutLast:1. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4468 |
]. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4469 |
^ p |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4470 |
]. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4471 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4472 |
(SlowFork==true or:[ForkFailed==true]) ifFalse:[ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4473 |
PipeStream openErrorSignal handle:[:ex | |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4474 |
ForkFailed := true. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4475 |
'OS: cannot fork/popen' errorPrintNL. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4476 |
ex return. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4477 |
] do:[ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4478 |
"have to fall back ..." |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4479 |
command := 'cd ' , pathName , '; pwd'. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4480 |
p := PipeStream readingFrom:command. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4481 |
]. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4482 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4483 |
(p isNil or:[p atEnd]) ifTrue:[ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4484 |
('OS: PipeStream for <' , command , '> failed') errorPrintNL. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4485 |
] ifFalse:[ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4486 |
path := p nextLine. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4487 |
p close. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4488 |
]. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4489 |
]. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4490 |
path isNil ifTrue:[ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4491 |
path := pathName |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4492 |
]. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4493 |
(SlowFork==true or:[ForkFailed==true]) ifTrue:[ |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4494 |
path := self compressPath:path |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
4495 |
] |
616 | 4496 |
]. |
4497 |
^ path. |
|
4498 |
||
4499 |
" |
|
4500 |
OperatingSystem pathNameOf:'.' |
|
4501 |
OperatingSystem pathNameOf:'../smalltalk/../smalltalk' |
|
4502 |
OperatingSystem pathNameOf:'../../..' |
|
4503 |
OperatingSystem pathNameOf:'..' |
|
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4504 |
OperatingSystem pathNameOf:'/tmp////' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4505 |
OperatingSystem pathNameOf:'/foo/bar' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4506 |
OperatingSystem pathNameOf:'/foo/bar/' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4507 |
OperatingSystem pathNameOf:'/foo/bar//' |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4508 |
" |
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4509 |
|
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4510 |
"Modified: 22.10.1996 / 17:59:19 / cg" |
1991
6dc27b78da3e
Fix pathNameOf: for systems not supporting primPathNameOf:
Stefan Vogel <sv@exept.de>
parents:
1987
diff
changeset
|
4511 |
"Modified: 29.11.1996 / 18:02:12 / stefan" |
359 | 4512 |
! |
4513 |
||
616 | 4514 |
primPathNameOf:pathName |
4515 |
"return the pathName of the argument, aPathString, |
|
4516 |
- thats the full pathname of the directory, starting at '/'. |
|
4517 |
This method here returns nil, if the OS does not provide a |
|
4518 |
realPath library function. |
|
4519 |
Notice: if symbolic links are involved, the result may look different |
|
4520 |
from what you expect." |
|
4521 |
||
4522 |
|path| |
|
4523 |
||
4524 |
"some systems have a convenient function for this ..." |
|
4525 |
%{ /* STACK: 16000 */ |
|
4526 |
#ifdef HAS_REALPATH |
|
4527 |
char nameBuffer[MAXPATHLEN + 1]; |
|
4528 |
||
4529 |
if (__isString(pathName)) { |
|
1135 | 4530 |
if (realpath(__stringVal(pathName), nameBuffer)) { |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
4531 |
RETURN ( __MKSTRING(nameBuffer) ); |
616 | 4532 |
} |
4533 |
} |
|
1632 | 4534 |
#else |
4535 |
# ifdef WIN32 |
|
4536 |
char nameBuffer[MAXPATHLEN + 1]; |
|
4537 |
char *pFinal; |
|
4538 |
||
4539 |
if (__isString(pathName)) { |
|
4540 |
if (GetFullPathName(__stringVal(pathName), sizeof(nameBuffer), |
|
4541 |
nameBuffer, &pFinal)) { |
|
4542 |
RETURN ( __MKSTRING(nameBuffer) ); |
|
4543 |
} |
|
4544 |
} |
|
4545 |
# endif |
|
616 | 4546 |
#endif |
4547 |
%}. |
|
4548 |
^ nil |
|
359 | 4549 |
! |
4550 |
||
616 | 4551 |
timeOfLastAccess:aPathName |
4552 |
"return the time, when the file was last accessed. |
|
4553 |
For nonexistent files, nil is returned." |
|
4554 |
||
4555 |
"could be implemented as: |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4556 |
(self infoOf:aPathName) at:#accessed |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4557 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4558 |
|osSeconds| |
616 | 4559 |
%{ |
4560 |
struct stat buf; |
|
4561 |
time_t mtime; |
|
4562 |
int ret; |
|
4563 |
||
4564 |
if (__isString(aPathName)) { |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4565 |
__BEGIN_INTERRUPTABLE__ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4566 |
do { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4567 |
ret = stat((char *) __stringVal(aPathName), &buf); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4568 |
} while (ret < 0 && errno == EINTR); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4569 |
__END_INTERRUPTABLE__ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4570 |
if (ret < 0) { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4571 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4572 |
RETURN (nil); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4573 |
} |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4574 |
osSeconds = __MKUINT(buf.st_atime); |
616 | 4575 |
} |
792 | 4576 |
%}. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4577 |
osSeconds notNil ifTrue:[^ AbsoluteTime fromOSTime:(osSeconds * 1000)]. |
792 | 4578 |
^ self primitiveFailed |
616 | 4579 |
|
4580 |
" |
|
4581 |
OperatingSystem timeOfLastAccess:'/' |
|
4582 |
" |
|
359 | 4583 |
! |
4584 |
||
616 | 4585 |
timeOfLastChange:aPathName |
4586 |
"return the time, when the file was last changed. |
|
4587 |
For nonexistent files, nil is returned." |
|
4588 |
||
4589 |
"could be implemented as: |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4590 |
(self infoOf:aPathName) at:#modified |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4591 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4592 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4593 |
|osSeconds| |
616 | 4594 |
%{ |
4595 |
struct stat buf; |
|
4596 |
int ret; |
|
4597 |
time_t mtime; |
|
4598 |
||
4599 |
if (__isString(aPathName)) { |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4600 |
__BEGIN_INTERRUPTABLE__ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4601 |
do { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4602 |
ret = stat((char *) __stringVal(aPathName), &buf); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4603 |
} while (ret < 0 && errno == EINTR); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4604 |
__END_INTERRUPTABLE__ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4605 |
if (ret < 0) { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4606 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4607 |
RETURN ( nil ); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4608 |
} |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4609 |
osSeconds = __MKUINT(buf.st_mtime); |
616 | 4610 |
} |
792 | 4611 |
%}. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4612 |
osSeconds notNil ifTrue:[^ AbsoluteTime fromOSTime:(osSeconds * 1000)]. |
792 | 4613 |
^ self primitiveFailed |
616 | 4614 |
|
4615 |
" |
|
4616 |
OperatingSystem timeOfLastChange:'/' |
|
4617 |
" |
|
4618 |
! |
|
4619 |
||
4620 |
typeOf:aPathName |
|
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4621 |
"return the type of a file as a symbol; for nonexistent files, |
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4622 |
nil is returned. |
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4623 |
Notice: for symbolic links, the type of the pointed-to file is returned." |
616 | 4624 |
|
4625 |
" |
|
4626 |
this could have been implemented as: |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4627 |
(self infoOf:aPathName) at:#type |
616 | 4628 |
but for huge directory searches the code below is faster |
4629 |
" |
|
359 | 4630 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4631 |
%{ |
616 | 4632 |
struct stat buf; |
4633 |
int ret; |
|
4634 |
||
4635 |
if (__isString(aPathName)) { |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4636 |
__BEGIN_INTERRUPTABLE__ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4637 |
do { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4638 |
ret = stat((char *) __stringVal(aPathName), &buf); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4639 |
} while (ret < 0 && errno == EINTR); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4640 |
__END_INTERRUPTABLE__ |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4641 |
if (ret < 0) { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4642 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4643 |
RETURN ( nil ); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4644 |
} |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4645 |
switch (buf.st_mode & S_IFMT) { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4646 |
case S_IFDIR: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4647 |
RETURN ( @symbol(directory) ); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4648 |
case S_IFREG: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4649 |
RETURN ( @symbol(regular) ); |
616 | 4650 |
#ifdef S_IFCHR |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4651 |
case S_IFCHR: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4652 |
RETURN ( @symbol(characterSpecial) ); |
616 | 4653 |
#endif |
4654 |
#ifdef S_IFBLK |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4655 |
case S_IFBLK: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4656 |
RETURN ( @symbol(blockSpecial) ); |
616 | 4657 |
#endif |
4658 |
#ifdef S_IFLNK |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4659 |
case S_IFLNK: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4660 |
RETURN ( @symbol(symbolicLink) ); |
616 | 4661 |
#endif |
4662 |
#ifdef S_IFSOCK |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4663 |
case S_IFSOCK: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4664 |
RETURN ( @symbol(socket) ); |
616 | 4665 |
#endif |
4666 |
#ifdef S_IFIFO |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4667 |
case S_IFIFO: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4668 |
RETURN ( @symbol(fifo) ); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4669 |
#endif |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4670 |
default: |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4671 |
RETURN ( @symbol(unknown) ); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
4672 |
} |
616 | 4673 |
} |
4674 |
%}. |
|
792 | 4675 |
^ self primitiveFailed |
616 | 4676 |
|
4677 |
" |
|
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4678 |
OperatingSystem typeOf:'/' |
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4679 |
OperatingSystem typeOf:'.' |
616 | 4680 |
OperatingSystem typeOf:'Make.proto' |
1858
cbbc11c01e10
return a private object for fileInfo.
Claus Gittinger <cg@exept.de>
parents:
1845
diff
changeset
|
4681 |
OperatingSystem typeOf:'resources/motif.style' |
616 | 4682 |
" |
68 | 4683 |
! ! |
4684 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
4685 |
!OperatingSystem class methodsFor:'interrupts & signals'! |
63 | 4686 |
|
10 | 4687 |
blockInterrupts |
95 | 4688 |
"disable interrupt processing - if disabled, incoming |
4689 |
interrupts will be registered and handled as soon as |
|
4690 |
interrupts are reenabled by OperatingSystemclass>>unblockInterrupts. |
|
4691 |
Returns the previous blocking status i.e. true if interrupts |
|
4692 |
where already blocked. You need this information for proper |
|
4693 |
unblocking, in case of nested block/unblock calls." |
|
4694 |
||
4695 |
%{ /* NOCONTEXT */ |
|
710 | 4696 |
RETURN ( __BLOCKINTERRUPTS() ); |
10 | 4697 |
%} |
4698 |
! |
|
4699 |
||
616 | 4700 |
defaultSignal:signalNumber |
4701 |
"revert to the default action on arrival of a (Unix-)signal. |
|
4702 |
Dont confuse Unix signals with smalltalk signals. |
|
4703 |
WARNING: for some signals, it is no good idea to revert to default; |
|
4704 |
for example, the default for SIGINT (i.e. ^C) is to exit; while the |
|
4705 |
default for SIGQUIT (^ \) is to dump core. |
|
4706 |
Also, NOTICE that signal numbers are not portable between unix |
|
4707 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
4708 |
a signal." |
|
4709 |
||
4710 |
%{ /* NOCONTEXT */ |
|
4711 |
||
4712 |
if (__isSmallInteger(signalNumber)) { |
|
831 | 4713 |
#ifdef SIG_DFL |
1135 | 4714 |
signal(__intVal(signalNumber), SIG_DFL); |
616 | 4715 |
RETURN (self); |
831 | 4716 |
#endif |
616 | 4717 |
} |
4718 |
%}. |
|
4719 |
" |
|
4720 |
this error is triggered on non-integer argument |
|
4721 |
" |
|
792 | 4722 |
^ self primitiveFailed |
616 | 4723 |
|
4724 |
"you better save a snapshot image before trying this ..." |
|
4725 |
" |
|
4726 |
'if you hit ^C now, Smalltalk will exit immediately' printNewline. |
|
4727 |
OperatingSystem defaultSignal:(OperatingSystem sigINT). |
|
4728 |
1 to:1000000 do:[:i| ]. |
|
4729 |
OperatingSystem enableSignal:(OperatingSystem sigINT). |
|
4730 |
'normal ^C handling again.' printNewline |
|
4731 |
" |
|
4732 |
! |
|
4733 |
||
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4734 |
disableChildSignalInterrupts |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4735 |
"disable childSignal interrupts |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4736 |
(SIGCHLD, if the architecture supports it). |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4737 |
We have to set the signal back to default, because ignoring |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4738 |
SIGCHLD breaks wait & co" |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4739 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4740 |
^ self defaultSignal:(self sigCHLD) |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4741 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4742 |
"Created: 5.1.1996 / 15:45:28 / stefan" |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4743 |
! |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4744 |
|
616 | 4745 |
disableIOInterruptsOn:fd |
4746 |
"turn off IO interrupts for a filedescriptor" |
|
4747 |
||
4748 |
%{ /* NOCONTEXT */ |
|
4749 |
||
4750 |
int ret, flags, f; |
|
4751 |
||
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4752 |
#if (defined(F_GETFL) && defined(F_SETFL) && defined(FASYNC)) || defined(SYSV4) |
616 | 4753 |
if (__isSmallInteger(fd)) { |
1135 | 4754 |
f = __intVal(fd); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4755 |
# if defined(SYSV4) |
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
756
diff
changeset
|
4756 |
ret = ioctl(f, I_SETSIG, 0); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4757 |
# else /*! SYSV4*/ |
616 | 4758 |
flags = fcntl(f, F_GETFL, 0); |
4759 |
/* |
|
4760 |
* if already clear, there is no need for this syscall ... |
|
4761 |
*/ |
|
4762 |
if (flags & FASYNC) { |
|
4763 |
ret = fcntl(f, F_SETFL, flags & ~FASYNC); |
|
4764 |
if (ret >= 0) ret = flags; |
|
4765 |
} else { |
|
4766 |
ret = flags; |
|
4767 |
} |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4768 |
# endif /* !SYSV4 */ |
1135 | 4769 |
RETURN ( __MKSMALLINT(ret) ); |
616 | 4770 |
} |
4771 |
#endif |
|
4772 |
%}. |
|
4773 |
" |
|
4774 |
this error is triggered on non-integer argument |
|
4775 |
or if the OS does not support IO interrupts. |
|
4776 |
" |
|
792 | 4777 |
^ self primitiveFailed |
10 | 4778 |
! |
4779 |
||
63 | 4780 |
disableSignal:signalNumber |
95 | 4781 |
"disable (Unix-) signal processing for signalNumber. |
4782 |
Dont confuse Unix signals with smalltalk signals. |
|
63 | 4783 |
WARNING: for some signals, it is no good idea to disable |
95 | 4784 |
them; for example, disabling the SIGINT signal turns off ^C |
63 | 4785 |
handling. |
68 | 4786 |
Also, NOTICE that signal numbers are not portable between unix |
4787 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
4788 |
a signal. |
|
63 | 4789 |
Use only for fully debugged stand alone applications." |
4790 |
||
4791 |
%{ /* NOCONTEXT */ |
|
4792 |
||
252 | 4793 |
if (__isSmallInteger(signalNumber)) { |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4794 |
int sigNo = __intVal(signalNumber); |
831 | 4795 |
|
4796 |
if (sigNo == 0) { |
|
4797 |
RETURN (self); |
|
4798 |
} |
|
4799 |
#ifdef SIG_IGN |
|
4800 |
signal(sigNo, SIG_IGN); |
|
185 | 4801 |
RETURN (self); |
831 | 4802 |
#endif |
63 | 4803 |
} |
68 | 4804 |
%}. |
4805 |
" |
|
4806 |
this error is triggered on non-integer argument |
|
4807 |
" |
|
792 | 4808 |
^ self primitiveFailed |
68 | 4809 |
|
4810 |
" |
|
4811 |
'now, ^C is totally ignored ...' printNewline. |
|
4812 |
OperatingSystem disableSignal:(OperatingSystem sigINT). |
|
4813 |
1 to:1000000 do:[:i| ]. |
|
4814 |
OperatingSystem enableSignal:(OperatingSystem sigINT). |
|
4815 |
'^C handled again.' printNewline |
|
4816 |
" |
|
4817 |
! |
|
4818 |
||
616 | 4819 |
disableTimer |
831 | 4820 |
"disable timer interrupts. |
4821 |
WARNING: |
|
4822 |
the system will not operate correctly with timer interrupts |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4823 |
disabled, because no scheduling or timeouts are possible." |
616 | 4824 |
|
4825 |
%{ /* NOCONTEXT */ |
|
4826 |
||
1632 | 4827 |
#if defined(WIN32) |
4828 |
KillTimer(NULL, w32TimerId); |
|
4829 |
w32TimerId = 0; |
|
4830 |
RETURN (true); |
|
4831 |
#else |
|
4832 |
# if defined(ITIMER_REAL) |
|
616 | 4833 |
struct itimerval dt; |
4834 |
||
4835 |
dt.it_interval.tv_sec = 0; |
|
4836 |
dt.it_interval.tv_usec = 0; |
|
4837 |
dt.it_value.tv_sec = 0; |
|
4838 |
dt.it_value.tv_usec = 0; |
|
4839 |
setitimer(ITIMER_REAL, &dt, 0); |
|
4840 |
RETURN (true); |
|
1632 | 4841 |
# endif /* ITIMER_REAL */ |
4842 |
#endif |
|
616 | 4843 |
%} |
4844 |
. |
|
4845 |
^ false |
|
4846 |
! |
|
4847 |
||
4848 |
disableUserInterrupts |
|
4849 |
"disable userInterrupt processing; |
|
4850 |
when disabled, no ^C processing takes place. |
|
831 | 4851 |
WARNING: |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4852 |
If at all, use this only for debugged stand-alone applications, since |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4853 |
no exit to the debugger is possible with user interrupts disabled. |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4854 |
We recommend setting up a handler for the signal instead of disabling it." |
831 | 4855 |
|
4856 |
self disableSignal:(self sigBREAK). |
|
4857 |
self disableSignal:(self sigINT). |
|
616 | 4858 |
! |
4859 |
||
4860 |
enableAbortInterrupts |
|
4861 |
"enable abort signalhandling, and make it a regular signalInterrupt. |
|
4862 |
(the default will dump core and exit - which is not a good idea for |
|
4863 |
end-user applications ...). |
|
4864 |
This is especially useful, if linked-in C-libraries call abort() ..." |
|
4865 |
||
831 | 4866 |
self enableSignal:(self sigABRT) |
616 | 4867 |
! |
4868 |
||
4869 |
enableChildSignalInterrupts |
|
4870 |
"enable childSignal interrupts |
|
4871 |
(SIGCHLD, if the architecture supports it). |
|
831 | 4872 |
After enabling, these signals will send the message |
616 | 4873 |
'childSignalInterrupt' to the ChildSignalInterruptHandler object." |
4874 |
||
831 | 4875 |
self enableSignal:(self sigCHLD) |
616 | 4876 |
! |
4877 |
||
4878 |
enableFpExceptionInterrupts |
|
4879 |
"enable floating point exception interrupts (if the |
|
4880 |
architecture supports it). |
|
831 | 4881 |
After enabling, fpu-exceptions will send the message |
616 | 4882 |
'fpuExceptionInterrupt' to the FPUExceptionInterruptHandler object." |
4883 |
||
831 | 4884 |
self enableSignal:(self sigFP) |
616 | 4885 |
! |
4886 |
||
4887 |
enableHardSignalInterrupts |
|
4888 |
"enable hard signal exception interrupts (trap, buserror & segm. violation). |
|
831 | 4889 |
After enabling, these exceptions will send the message |
616 | 4890 |
'signalInterrupt' to the SignalInterruptHandler object." |
68 | 4891 |
|
855
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
4892 |
"/ leads to trouble ... |
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
4893 |
"/ self enableSignal:(self sigPIPE). |
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
4894 |
|
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
4895 |
"/ ... better to ignore them, and let it be handled as a writeErrorSignal. |
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
4896 |
self disableSignal:(self sigPIPE). |
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
4897 |
|
1808
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
4898 |
self enableSignal:(self sigILL). |
640
be94dfc60eaa
Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents:
630
diff
changeset
|
4899 |
self enableSignal:(self sigBUS). |
be94dfc60eaa
Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents:
630
diff
changeset
|
4900 |
self enableSignal:(self sigSEGV) |
616 | 4901 |
! |
4902 |
||
4903 |
enableIOInterruptsOn:fd |
|
4904 |
"turn on IO interrupts for a filedescriptor" |
|
4905 |
||
4906 |
%{ /* NOCONTEXT */ |
|
4907 |
||
4908 |
int ret, flags, f; |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4909 |
#ifndef __signalIoInterrupt |
616 | 4910 |
extern void __signalIoInterrupt(); |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4911 |
#endif |
616 | 4912 |
static int firstCall = 1; |
4913 |
||
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4914 |
#if (defined(F_GETFL) && defined(F_SETFL) && defined(FASYNC)) || defined(SYSV4) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4915 |
/* |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4916 |
* SIGIO/SIGPOLL - data available for I/O |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4917 |
* (used to wake up waiting processes) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4918 |
*/ |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4919 |
#ifdef SIGIO |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4920 |
# define THESIGNAL SIGIO |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4921 |
#else |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4922 |
# ifdef SIGPOLL |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4923 |
# define THESIGNAL SIGPOLL |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4924 |
# else |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4925 |
# ifdef SIGURG |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4926 |
# define THESIGNAL SIGURG |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4927 |
# endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4928 |
# endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4929 |
#endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4930 |
|
616 | 4931 |
if (__isSmallInteger(fd)) { |
4932 |
if (firstCall) { |
|
762
cea705669628
ok, stefan was right: HAS_SIGACTION works
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
4933 |
#ifdef HAS_SIGACTION |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4934 |
struct sigaction act; |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4935 |
|
1487 | 4936 |
/* |
4937 |
* Do not add SA_RESTART here. A signal can cause a |
|
4938 |
* thread switch, another thread can do a garbage collect |
|
4939 |
* and restarted system calls may write into old |
|
4940 |
* (collected) addresses. |
|
4941 |
*/ |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4942 |
|
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4943 |
act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */ |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4944 |
sigemptyset(&act.sa_mask); |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4945 |
act.sa_handler = __signalIoInterrupt; |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4946 |
sigaction(THESIGNAL, &act, 0); |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4947 |
#else |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4948 |
# ifdef HAS_SIGVEC |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4949 |
struct sigvec vec; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4950 |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4951 |
vec.sv_flags = SV_INTERRUPT; |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4952 |
sigemptyset(&vec.sv_mask); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4953 |
vec.sv_handler = __signalIoInterrupt; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4954 |
sigvec(THESIGNAL, &vec, NULL); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4955 |
# else |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4956 |
signal(THESIGNAL, __signalIoInterrupt); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4957 |
# endif |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4958 |
#endif |
616 | 4959 |
firstCall = 0; |
4960 |
} |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4961 |
#undef THESIGNAL |
616 | 4962 |
|
1135 | 4963 |
f = __intVal(fd); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4964 |
# if defined(SYSV4) |
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
756
diff
changeset
|
4965 |
ret = ioctl(f, I_SETSIG, S_INPUT | S_HIPRI | S_ERROR | S_RDNORM | S_RDBAND | S_MSG | S_HANGUP); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4966 |
# else /*! SYSV4*/ |
616 | 4967 |
flags = fcntl(f, F_GETFL, 0); |
4968 |
/* |
|
4969 |
* if already set, there is no need for this syscall ... |
|
4970 |
*/ |
|
4971 |
if (flags & FASYNC) { |
|
4972 |
ret = flags; |
|
4973 |
} else { |
|
4974 |
ret = fcntl(f, F_SETFL, flags | FASYNC); |
|
4975 |
if (ret >= 0) ret = flags; |
|
4976 |
} |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4977 |
# endif /*!SYSV4*/ |
1135 | 4978 |
RETURN ( __MKSMALLINT(ret) ); |
68 | 4979 |
} |
616 | 4980 |
#endif |
68 | 4981 |
%}. |
4982 |
" |
|
4983 |
this error is triggered on non-integer argument |
|
616 | 4984 |
or if the system does not support SIGIO |
68 | 4985 |
" |
792 | 4986 |
^ self primitiveFailed |
616 | 4987 |
! |
4988 |
||
4989 |
enableQuitInterrupts |
|
4990 |
"enable quitInterrupt (usually ^\) handling, and make it a userInterrupt. |
|
4991 |
(the default will dump core and exit - which is not a good idea for |
|
4992 |
end-user applications ...)" |
|
4993 |
||
831 | 4994 |
self enableSignal:(self sigQUIT) |
68 | 4995 |
! |
4996 |
||
4997 |
enableSignal:signalNumber |
|
95 | 4998 |
"enable (Unix-)signal processing for signalNumber. |
4999 |
Dont confuse Unix signals with smalltalk signals. |
|
68 | 5000 |
The signal will be delivered to one of the standard handlers |
5001 |
(SIGINT, SIGQUIT, etc) or to a general handler, which |
|
5002 |
sends #signalInterrupt:. |
|
5003 |
||
5004 |
NOTICE that signal numbers are not portable between unix |
|
5005 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
5006 |
a signal." |
|
5007 |
||
5008 |
%{ /* NOCONTEXT */ |
|
5009 |
||
5010 |
#ifdef NSIG |
|
5011 |
# define SIG_LIMIT NSIG |
|
5012 |
#else |
|
5013 |
# ifdef SIGUSR2 |
|
5014 |
# define SIG_LIMIT SIGUSR2 |
|
5015 |
# else |
|
5016 |
# ifdef SIGUSR |
|
5017 |
# define SIG_LIMIT SIGUSR |
|
5018 |
# endif |
|
5019 |
# endif |
|
5020 |
#endif |
|
5021 |
||
5022 |
#if defined(SIGPOLL) && !defined(SIGIO) |
|
5023 |
# define SIGIO SIGPOLL |
|
5024 |
#endif |
|
5025 |
||
5026 |
#ifdef SIGCHLD |
|
5027 |
# define CHILD_SIGNAL SIGCHLD |
|
5028 |
#else |
|
5029 |
# ifdef SIGCLD |
|
5030 |
# define CHILD_SIGNAL SIGCLD |
|
5031 |
# endif |
|
5032 |
#endif |
|
5033 |
||
5034 |
int sigNr; |
|
443 | 5035 |
#if defined(SIGINT) || defined(SIGQUIT) |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5036 |
# ifndef __signalUserInterrupt |
831 | 5037 |
extern void __signalUserInterrupt(SIGHANDLER_ARG); |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5038 |
# endif |
443 | 5039 |
#endif |
5040 |
#ifdef SIGFPE |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5041 |
# ifndef __signalFpExceptionInterrupt |
831 | 5042 |
extern void __signalFpExceptionInterrupt(SIGHANDLER_ARG); |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5043 |
# endif |
443 | 5044 |
#endif |
5045 |
#ifdef SIGIO |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5046 |
# ifndef __signalIoInterrupt |
831 | 5047 |
extern void __signalIoInterrupt(SIGHANDLER_ARG); |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5048 |
# endif |
443 | 5049 |
#endif |
68 | 5050 |
#ifdef CHILD_SIGNAL |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5051 |
# ifndef __signalChildInterrupt |
831 | 5052 |
extern void __signalChildInterrupt(SIGHANDLER_ARG); |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5053 |
# endif |
68 | 5054 |
#endif |
443 | 5055 |
#ifdef SIGPIPE |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5056 |
# ifndef __signalPIPEInterrupt |
831 | 5057 |
extern void __signalPIPEInterrupt(SIGHANDLER_ARG); |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5058 |
# endif |
443 | 5059 |
#endif |
5060 |
#ifdef SIGBUS |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5061 |
# ifndef __signalBUSInterrupt |
831 | 5062 |
extern void __signalBUSInterrupt(SIGHANDLER_ARG); |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5063 |
# endif |
443 | 5064 |
#endif |
5065 |
#ifdef SIGSEGV |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5066 |
# ifndef __signalSEGVInterrupt |
831 | 5067 |
extern void __signalSEGVInterrupt(SIGHANDLER_ARG); |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5068 |
# endif |
443 | 5069 |
#endif |
1808
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
5070 |
#ifdef SIGILL |
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
5071 |
# ifndef __signalTrapInterrupt |
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
5072 |
extern void __signalTrapInterrupt(SIGHANDLER_ARG); |
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
5073 |
# endif |
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
5074 |
#endif |
443 | 5075 |
#ifdef SIGALRM |
831 | 5076 |
# ifndef WIN32 |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5077 |
# ifndef __signalTimerInterrupt |
831 | 5078 |
extern void __signalTimerInterrupt(SIGHANDLER_ARG); |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5079 |
# endif |
831 | 5080 |
# endif |
5081 |
#endif |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5082 |
#ifndef __signalInterrupt |
831 | 5083 |
extern void __signalInterrupt(SIGHANDLER_ARG); |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5084 |
#endif |
831 | 5085 |
void (*handler)(SIGHANDLER_ARG); |
68 | 5086 |
|
252 | 5087 |
if (__isSmallInteger(signalNumber) |
1135 | 5088 |
&& ((sigNr = __intVal(signalNumber)) >= 0) |
831 | 5089 |
#ifdef SIG_LIMIT |
5090 |
&& (sigNr <= SIG_LIMIT) |
|
5091 |
#endif |
|
5092 |
) { |
|
185 | 5093 |
/* |
5094 |
* standard signals are forced into standard handlers |
|
5095 |
* - all others go into general signalInterrupt |
|
5096 |
*/ |
|
68 | 5097 |
#if defined(SIGPOLL) && defined(SIGIO) |
185 | 5098 |
if (sigNr == SIGPOLL) |
5099 |
sigNr = SIGIO; |
|
68 | 5100 |
#endif |
185 | 5101 |
switch (sigNr) { |
831 | 5102 |
case 0: |
5103 |
/* enabling a non-supported signal */ |
|
5104 |
RETURN (self); |
|
5105 |
||
5106 |
#ifdef SIGBREAK |
|
5107 |
case SIGBREAK: |
|
5108 |
#endif |
|
443 | 5109 |
#ifdef SIGINT |
185 | 5110 |
case SIGINT: |
443 | 5111 |
#endif |
5112 |
#ifdef SIGQUIT |
|
185 | 5113 |
case SIGQUIT: |
443 | 5114 |
#endif |
831 | 5115 |
#if defined(SIGINT) || defined(SIGQUIT) || defined(SIGBREAK) |
329 | 5116 |
handler = __signalUserInterrupt; |
185 | 5117 |
break; |
443 | 5118 |
#endif |
5119 |
||
5120 |
#ifdef SIGFPE |
|
185 | 5121 |
case SIGFPE: |
329 | 5122 |
handler = __signalFpExceptionInterrupt; |
185 | 5123 |
break; |
443 | 5124 |
#endif |
5125 |
||
5126 |
#ifdef SIGPIPE |
|
185 | 5127 |
case SIGPIPE: |
329 | 5128 |
handler = __signalPIPEInterrupt; |
185 | 5129 |
break; |
443 | 5130 |
#endif |
68 | 5131 |
#ifdef SIGBUS |
185 | 5132 |
case SIGBUS: |
329 | 5133 |
handler = __signalBUSInterrupt; |
185 | 5134 |
break; |
68 | 5135 |
#endif |
443 | 5136 |
#ifdef SIGSEGV |
185 | 5137 |
case SIGSEGV: |
329 | 5138 |
handler = __signalSEGVInterrupt; |
185 | 5139 |
break; |
443 | 5140 |
#endif |
1982
8d4f97279e55
oops - SIGILL was never cought
Claus Gittinger <cg@exept.de>
parents:
1966
diff
changeset
|
5141 |
#ifdef SIGILL |
8d4f97279e55
oops - SIGILL was never cought
Claus Gittinger <cg@exept.de>
parents:
1966
diff
changeset
|
5142 |
case SIGILL: |
1808
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
5143 |
handler = __signalTrapInterrupt; |
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
5144 |
break; |
58ed32d318d4
handle SIGILL like bus or segv
Claus Gittinger <cg@exept.de>
parents:
1799
diff
changeset
|
5145 |
#endif |
68 | 5146 |
#ifdef SIGIO |
185 | 5147 |
case SIGIO: |
329 | 5148 |
handler = __signalIoInterrupt; |
185 | 5149 |
break; |
68 | 5150 |
#endif |
5151 |
||
5152 |
#ifdef CHILD_SIGNAL |
|
185 | 5153 |
case CHILD_SIGNAL: |
329 | 5154 |
handler = __signalChildInterrupt; |
185 | 5155 |
break; |
68 | 5156 |
#endif |
443 | 5157 |
#ifdef SIGALRM |
831 | 5158 |
# ifndef WIN32 |
185 | 5159 |
case SIGALRM: |
329 | 5160 |
handler = __signalTimerInterrupt; |
185 | 5161 |
break; |
831 | 5162 |
# endif |
443 | 5163 |
#endif |
185 | 5164 |
|
5165 |
default: |
|
329 | 5166 |
handler = __signalInterrupt; |
185 | 5167 |
break; |
5168 |
} |
|
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5169 |
|
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5170 |
{ |
762
cea705669628
ok, stefan was right: HAS_SIGACTION works
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
5171 |
#ifdef HAS_SIGACTION |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5172 |
struct sigaction act; |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5173 |
|
1487 | 5174 |
/* |
5175 |
* Do not add SA_RESTART here. A signal can cause a |
|
5176 |
* thread switch, another thread can do a garbage collect |
|
5177 |
* and restarted system calls may write into old |
|
5178 |
* (collected) addresses. |
|
5179 |
*/ |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
5180 |
|
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
5181 |
act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */ |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5182 |
sigemptyset(&act.sa_mask); |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5183 |
act.sa_handler = handler; |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5184 |
sigaction(sigNr, &act, 0); |
213 | 5185 |
#else |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5186 |
# ifdef HAS_SIGVEC |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5187 |
struct sigvec vec; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5188 |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
5189 |
vec.sv_flags = SV_INTERRUPT; |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5190 |
sigemptyset(&vec.sv_mask); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5191 |
vec.sv_handler = handler; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5192 |
sigvec(sigNr, &vec, NULL); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5193 |
# else |
831 | 5194 |
(void) signal(sigNr, handler); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5195 |
# endif |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5196 |
#endif |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
5197 |
} |
213 | 5198 |
|
185 | 5199 |
/* |
5200 |
* maybe, we should return the old enable-status |
|
5201 |
* as boolean here ... |
|
5202 |
*/ |
|
5203 |
RETURN (self); |
|
68 | 5204 |
} |
5205 |
%}. |
|
5206 |
||
5207 |
" |
|
5208 |
this error is triggered on non-integer argument, or |
|
5209 |
if the signal number is not in the valid range (1..NSIG) |
|
5210 |
" |
|
792 | 5211 |
^ self primitiveFailed |
63 | 5212 |
! |
5213 |
||
831 | 5214 |
enableTimer:milliSeconds |
616 | 5215 |
"trigger a timerInterrupt, to be signalled after some (real) time." |
5216 |
||
5217 |
%{ /* NOCONTEXT */ |
|
831 | 5218 |
int millis; |
5219 |
||
5220 |
millis = __intVal(milliSeconds); |
|
616 | 5221 |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
5222 |
#if defined(ITIMER_REAL) |
831 | 5223 |
{ |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5224 |
static int firstCall = 1; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5225 |
struct itimerval dt; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5226 |
#ifndef __signalTimerInterrupt |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5227 |
extern void __signalTimerInterrupt(SIGHANDLER_ARG); |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5228 |
#endif |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5229 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5230 |
if (firstCall) { |
831 | 5231 |
# ifdef HAS_SIGACTION |
5232 |
struct sigaction act; |
|
5233 |
||
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
5234 |
act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */ |
831 | 5235 |
sigemptyset(&act.sa_mask); |
5236 |
act.sa_handler = __signalTimerInterrupt; |
|
5237 |
sigaction(SIGALRM, &act, 0); |
|
5238 |
# else |
|
5239 |
# ifdef HAS_SIGVEC |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5240 |
struct sigvec vec; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5241 |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
5242 |
vec.sv_flags = SV_INTERRUPT; |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5243 |
sigemptyset(&vec.sv_mask); |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5244 |
vec.sv_handler = __signalTimerInterrupt; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5245 |
sigvec(SIGALRM, &vec, NULL); |
831 | 5246 |
# else |
5247 |
signal(SIGALRM, __signalTimerInterrupt); |
|
5248 |
# endif |
|
5249 |
# endif |
|
5250 |
firstCall = 0; |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5251 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5252 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5253 |
dt.it_interval.tv_sec = 0; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5254 |
dt.it_interval.tv_usec = 0; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5255 |
dt.it_value.tv_sec = millis / 1000; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5256 |
dt.it_value.tv_usec = (millis % 1000) * 1000; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5257 |
setitimer(ITIMER_REAL, &dt, 0); |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5258 |
RETURN (true); |
831 | 5259 |
} |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
5260 |
#else |
831 | 5261 |
# ifdef WIN32 |
5262 |
{ |
|
5263 |
/* |
|
5264 |
* two mechanisms - which one to use ? |
|
5265 |
*/ |
|
5266 |
# ifdef USE_TimerProc |
|
5267 |
||
5268 |
extern VOID CALLBACK __win32TimerProc(HWND, UINT, UINT, DWORD); |
|
1632 | 5269 |
w32TimerId = SetTimer(NULL, 0, millis, __win32TimerProc); |
831 | 5270 |
|
5271 |
# else /* USE_TimeProc */ |
|
5272 |
||
5273 |
extern void CALLBACK __win32TimeProc(UINT, UINT, DWORD, DWORD, DWORD, DWORD); |
|
1632 | 5274 |
timeSetEvent(millis, 5, (LPTIMECALLBACK)__win32TimeProc, 0, TIME_ONESHOT); |
831 | 5275 |
# endif |
1632 | 5276 |
RETURN (true); |
640
be94dfc60eaa
Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents:
630
diff
changeset
|
5277 |
} |
831 | 5278 |
# endif /* WIN32 */ |
5279 |
#endif /* ITIMER_REAL */ |
|
5280 |
%}. |
|
616 | 5281 |
^ false |
5282 |
! |
|
5283 |
||
1 | 5284 |
enableUserInterrupts |
5285 |
"enable userInterrupt (^C) handling; |
|
95 | 5286 |
when enabled, ^C in the terminal window will send the message |
5287 |
'userInterrupt' to the UserInterruptHandler object." |
|
1 | 5288 |
|
831 | 5289 |
self enableSignal:(self sigINT). |
5290 |
self enableSignal:(self sigBREAK). |
|
63 | 5291 |
! |
5292 |
||
616 | 5293 |
interruptPending |
5294 |
"return true, if an interrupt is pending. The returned value is |
|
5295 |
invalid if interrupts are not currently blocked, since otherwise |
|
5296 |
the interrupt is usually already handled before arriving here, |
|
5297 |
or may be served while returning from here." |
|
5298 |
||
2117
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5299 |
%{ /* NOCONTEXT */ |
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5300 |
extern OBJ __INTERRUPTPENDING(); |
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5301 |
|
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5302 |
RETURN ( __INTERRUPTPENDING() ); |
616 | 5303 |
%} |
1 | 5304 |
! |
5305 |
||
2117
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5306 |
interruptsBlocked |
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5307 |
"return true, if interrupt handling is currently disabled; |
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5308 |
false otherwise." |
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5309 |
|
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5310 |
%{ /* NOCONTEXT */ |
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5311 |
extern OBJ __INTERRUPTS_BLOCKED(); |
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5312 |
|
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5313 |
RETURN ( __INTERRUPTS_BLOCKED() ); |
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5314 |
%} |
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5315 |
! |
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
5316 |
|
704 | 5317 |
killProcess:processId |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5318 |
"kill a unix process. |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5319 |
The process terminates immediately and has no chance to perform any cleanup actions. |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5320 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5321 |
WARNING: in order to avoid zombie processes (on unix), |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5322 |
you have to fetch the processes exitstatus with |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5323 |
OperatingSystem>>getStatusOfProcess:aProcessId." |
704 | 5324 |
|
5325 |
self sendSignal:(self sigKILL) to:processId. |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5326 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5327 |
"Modified: 28.12.1995 / 15:06:18 / stefan" |
704 | 5328 |
! |
5329 |
||
616 | 5330 |
nameForSignal:aSignalNumber |
5331 |
"for a given Unix signalnumber, return a descriptive string" |
|
5332 |
||
5333 |
aSignalNumber == self sigHUP ifTrue:[^ 'hangup']. |
|
5334 |
aSignalNumber == self sigINT ifTrue:[^ 'interrupt']. |
|
5335 |
aSignalNumber == self sigKILL ifTrue:[^ 'kill']. |
|
5336 |
aSignalNumber == self sigQUIT ifTrue:[^ 'quit']. |
|
5337 |
aSignalNumber == self sigILL ifTrue:[^ 'illegal instruction']. |
|
5338 |
aSignalNumber == self sigTRAP ifTrue:[^ 'trap']. |
|
5339 |
aSignalNumber == self sigABRT ifTrue:[^ 'abort']. |
|
5340 |
aSignalNumber == self sigIOT ifTrue:[^ 'iot trap']. |
|
5341 |
aSignalNumber == self sigEMT ifTrue:[^ 'emt trap']. |
|
5342 |
aSignalNumber == self sigFP ifTrue:[^ 'fp exception']. |
|
5343 |
aSignalNumber == self sigBUS ifTrue:[^ 'bus error']. |
|
5344 |
aSignalNumber == self sigSEGV ifTrue:[^ 'segmentation violation']. |
|
5345 |
aSignalNumber == self sigSYS ifTrue:[^ 'bad system call']. |
|
5346 |
aSignalNumber == self sigPIPE ifTrue:[^ 'broken pipe']. |
|
5347 |
aSignalNumber == self sigALRM ifTrue:[^ 'alarm timer']. |
|
5348 |
aSignalNumber == self sigTERM ifTrue:[^ 'termination']. |
|
5349 |
aSignalNumber == self sigSTOP ifTrue:[^ 'stop']. |
|
5350 |
aSignalNumber == self sigTSTP ifTrue:[^ 'tty stop']. |
|
5351 |
aSignalNumber == self sigCONT ifTrue:[^ 'continue']. |
|
5352 |
aSignalNumber == self sigCHLD ifTrue:[^ 'child death']. |
|
5353 |
aSignalNumber == self sigTTIN ifTrue:[^ 'background tty input']. |
|
5354 |
aSignalNumber == self sigTTOU ifTrue:[^ 'background tty output']. |
|
5355 |
aSignalNumber == self sigIO ifTrue:[^ 'io available']. |
|
5356 |
aSignalNumber == self sigXCPU ifTrue:[^ 'cpu time expired']. |
|
5357 |
aSignalNumber == self sigXFSZ ifTrue:[^ 'file size limit']. |
|
5358 |
aSignalNumber == self sigVTALRM ifTrue:[^ 'virtual alarm timer']. |
|
5359 |
aSignalNumber == self sigPROF ifTrue:[^ 'profiling timer']. |
|
5360 |
aSignalNumber == self sigWINCH ifTrue:[^ 'winsize changed']. |
|
5361 |
aSignalNumber == self sigLOST ifTrue:[^ 'resource lost']. |
|
5362 |
aSignalNumber == self sigUSR1 ifTrue:[^ 'user signal 1']. |
|
5363 |
aSignalNumber == self sigUSR2 ifTrue:[^ 'user signal 2']. |
|
5364 |
aSignalNumber == self sigMSG ifTrue:[^ 'HFT message']. |
|
5365 |
aSignalNumber == self sigPWR ifTrue:[^ 'power-fail']. |
|
5366 |
aSignalNumber == self sigPRE ifTrue:[^ 'programming exception']. |
|
5367 |
aSignalNumber == self sigGRANT ifTrue:[^ 'HFT access wanted']. |
|
5368 |
aSignalNumber == self sigRETRACT ifTrue:[^ 'HFT access relinquish']. |
|
5369 |
aSignalNumber == self sigSOUND ifTrue:[^ 'HFT sound complete']. |
|
5370 |
aSignalNumber == self sigDANGER ifTrue:[^ 'low on paging space']. |
|
5371 |
||
5372 |
"notice: many systems map SIGPOLL and/or SIGUSR onto SIGIO |
|
5373 |
therefore, keep SIGIO always above the two below" |
|
5374 |
aSignalNumber == self sigPOLL ifTrue:[^ 'io available']. |
|
5375 |
aSignalNumber == self sigURG ifTrue:[^ 'urgent']. |
|
5376 |
||
5377 |
^ 'unknown signal' |
|
5378 |
||
68 | 5379 |
" |
616 | 5380 |
OperatingSystem nameForSignal:9 |
5381 |
OperatingSystem nameForSignal:(OperatingSystem sigPOLL) |
|
68 | 5382 |
" |
616 | 5383 |
! |
5384 |
||
5385 |
operatingSystemSignal:signalNumber |
|
5386 |
"return the signal to be raised when an |
|
5387 |
operatingSystem-signal occurs, or nil" |
|
5388 |
||
5389 |
OSSignals notNil ifTrue:[ |
|
5390 |
^ OSSignals at:signalNumber ifAbsent:[nil] |
|
5391 |
]. |
|
5392 |
^ nil |
|
10 | 5393 |
! |
5394 |
||
616 | 5395 |
operatingSystemSignal:signalNumber install:aSignal |
5396 |
"install a signal to be raised when an operatingSystem-signal occurs" |
|
5397 |
||
5398 |
OSSignals isNil ifTrue:[ |
|
5399 |
OSSignals := Array new:32 |
|
5400 |
]. |
|
5401 |
OSSignals at:signalNumber put:aSignal |
|
5402 |
! |
|
5403 |
||
5404 |
sendSignal:signalNumber to:processId |
|
5405 |
"send a unix signal to some process (maybe myself). |
|
5406 |
Returns false if any error occurred, true otherwise. |
|
5407 |
||
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5408 |
Do not confuse UNIX signals with Smalltalk-Signals. |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5409 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5410 |
WARNING: in order to avoid zombie processes (on unix), |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5411 |
you may have to fetch the processes exitstatus with |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5412 |
OperatingSystem>>getStatusOfProcess:aProcessId |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5413 |
if the signal terminates that process." |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5414 |
|
616 | 5415 |
%{ |
792 | 5416 |
#ifndef MSDOS_LIKE |
616 | 5417 |
if (__bothSmallInteger(signalNumber, processId)) { |
5418 |
if (kill(__intVal(processId), __intVal(signalNumber)) < 0) { |
|
1135 | 5419 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 5420 |
RETURN ( false ); |
216 | 5421 |
} |
616 | 5422 |
RETURN ( true ); |
10 | 5423 |
} |
792 | 5424 |
#endif |
68 | 5425 |
%}. |
792 | 5426 |
"/ |
5427 |
"/ either invalid argument (non-integers) |
|
5428 |
"/ or not supported by OS |
|
5429 |
"/ |
|
5430 |
^ self primitiveFailed |
|
1 | 5431 |
! |
5432 |
||
5433 |
startSpyTimer |
|
63 | 5434 |
"trigger a spyInterrupt, to be signalled after some short (virtual) time. |
359 | 5435 |
This is used by the old MessageTally for profiling. |
63 | 5436 |
Should be changed to use real profiling timer if available. |
68 | 5437 |
On systems, where no virtual timer is available, use the real timer |
359 | 5438 |
(which is of course less correct). |
5439 |
OBSOLETE: the new messageTally runs as a high prio process, not using |
|
5440 |
spy interrupts." |
|
1 | 5441 |
|
5442 |
%{ /* NOCONTEXT */ |
|
5443 |
||
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5444 |
#ifndef __spyInterrupt |
329 | 5445 |
extern void __spyInterrupt(); |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5446 |
#endif |
10 | 5447 |
#if defined(ITIMER_VIRTUAL) |
1 | 5448 |
struct itimerval dt; |
5449 |
||
13 | 5450 |
# ifdef SIGVTALRM |
329 | 5451 |
signal(SIGVTALRM, __spyInterrupt); |
13 | 5452 |
# else |
329 | 5453 |
signal(SIGALRM, __spyInterrupt); |
13 | 5454 |
# endif |
5455 |
||
348 | 5456 |
dt.it_interval.tv_sec = 0; |
5457 |
dt.it_interval.tv_usec = 0; |
|
5458 |
dt.it_value.tv_sec = 0; |
|
5459 |
dt.it_value.tv_usec = 1000; /* 1000 Hz */ |
|
5460 |
setitimer(ITIMER_VIRTUAL, &dt, 0); |
|
5461 |
||
13 | 5462 |
RETURN (true); |
1 | 5463 |
#endif |
5464 |
%} |
|
13 | 5465 |
. |
5466 |
^ false |
|
1 | 5467 |
! |
5468 |
||
5469 |
stopSpyTimer |
|
359 | 5470 |
"stop spy timing - disable spy timer. |
5471 |
OBSOLETE: the new messageTally runs as a high prio process, not using |
|
5472 |
spy interrupts." |
|
1 | 5473 |
|
5474 |
%{ /* NOCONTEXT */ |
|
5475 |
||
10 | 5476 |
#if defined(ITIMER_VIRTUAL) |
1 | 5477 |
struct itimerval dt; |
5478 |
||
5479 |
dt.it_interval.tv_sec = 0; |
|
5480 |
dt.it_interval.tv_usec = 0; |
|
5481 |
dt.it_value.tv_sec = 0; |
|
5482 |
dt.it_value.tv_usec = 0; |
|
5483 |
setitimer(ITIMER_VIRTUAL, &dt, 0); |
|
13 | 5484 |
RETURN (true); |
10 | 5485 |
#endif |
5486 |
%} |
|
13 | 5487 |
. |
5488 |
^ false |
|
10 | 5489 |
! |
5490 |
||
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5491 |
terminateProcess:processId |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5492 |
"terminate a unix process. |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5493 |
The process has a chance to do some cleanup. |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5494 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5495 |
WARNING: in order to avoid zombie processes (on unix), |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5496 |
you may have to fetch the processes exitstatus with |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5497 |
OperatingSystem>>getStatusOfProcess:aProcessId." |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5498 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5499 |
self sendSignal:(self sigTERM) to:processId. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5500 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5501 |
"Modified: 28.12.1995 / 15:05:37 / stefan" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5502 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5503 |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5504 |
terminateProcessGroup:processGroupId |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5505 |
"terminate a unix process group. |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5506 |
The process has a chance to do some cleanup. |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5507 |
|
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5508 |
WARNING: in order to avoid zombie processes (on unix), |
1487 | 5509 |
you may have to fetch the processes exitstatus with |
5510 |
OperatingSystem>>getStatusOfProcess:aProcessId." |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5511 |
|
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5512 |
self sendSignal:(self sigTERM) to:(processGroupId negated). |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5513 |
|
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5514 |
"Modified: 28.12.1995 / 15:05:37 / stefan" |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5515 |
"Created: 23.4.1996 / 16:40:34 / stefan" |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5516 |
! |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5517 |
|
616 | 5518 |
unblockInterrupts |
5519 |
"enable interrupt processing - if any interrupts are pending, |
|
5520 |
these will be handled immediately. |
|
5521 |
When unblocking interrupts, take care of nested block/unblock |
|
5522 |
calls - you must only unblock after a blockcall if they where |
|
5523 |
really not blocked before. See OperatingSystemclass>>blockInterrupts." |
|
5524 |
%{ |
|
5525 |
__UNBLOCKINTERRUPTS(); |
|
1040
60e4c4bbbca2
return nil from unblockInterrupts (thats what the inlined code returns)
Claus Gittinger <cg@exept.de>
parents:
1034
diff
changeset
|
5526 |
RETURN (nil); |
616 | 5527 |
%} |
5528 |
! ! |
|
5529 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
5530 |
!OperatingSystem class methodsFor:'misc'! |
616 | 5531 |
|
5532 |
exit |
|
710 | 5533 |
"shutdown smalltalk immediately - this method does not return. |
5534 |
Return 'good'-status (0) to the parent unix process." |
|
616 | 5535 |
|
5536 |
%{ /* NOCONTEXT */ |
|
5537 |
__mainExit(0); |
|
5538 |
%} |
|
5539 |
"OperatingSystem exit - dont evaluate this" |
|
5540 |
! |
|
5541 |
||
5542 |
exit:exitCode |
|
5543 |
"shutdown smalltalk immediately - |
|
5544 |
returning an exit-code to the parent unix process." |
|
5545 |
||
5546 |
%{ /* NOCONTEXT */ |
|
5547 |
int code = 1; |
|
5548 |
||
5549 |
if (__isSmallInteger(exitCode)) { |
|
1135 | 5550 |
code = __intVal(exitCode); |
616 | 5551 |
} |
5552 |
__mainExit(code); |
|
5553 |
%} |
|
5554 |
"OperatingSystem exit:1 - dont evaluate this" |
|
5555 |
! |
|
5556 |
||
5557 |
exitWithCoreDump |
|
5558 |
"shutdown smalltalk immediately - dumping core. |
|
5559 |
This always returns 'bad'-status to the parent unix process. |
|
5560 |
Notice, that no cleanup is performed at all - you may have to |
|
5561 |
manually remove any tempfiles. |
|
5562 |
Use this only for debugging ST/X itself" |
|
5563 |
||
5564 |
%{ /* NOCONTEXT */ |
|
5565 |
abort(); |
|
5566 |
%} |
|
831 | 5567 |
" |
5568 |
OperatingSystem exitWithCoreDump - dont evaluate this |
|
5569 |
" |
|
616 | 5570 |
! |
5571 |
||
5572 |
slowFork:aBoolean |
|
1247 | 5573 |
"set/clear the `avoid-fork-if-possible-because-its-slow' flag. |
5574 |
Only used internally on SYSV3 systems" |
|
5575 |
||
616 | 5576 |
SlowFork := aBoolean |
1247 | 5577 |
|
5578 |
"Modified: 22.4.1996 / 13:13:09 / cg" |
|
616 | 5579 |
! ! |
5580 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
5581 |
!OperatingSystem class methodsFor:'os queries'! |
616 | 5582 |
|
5583 |
getCPUDefine |
|
831 | 5584 |
"return a string which was used to identify this CPU type when STX was |
616 | 5585 |
compiled, and which should be passed down when compiling methods. |
831 | 5586 |
For example, on linux, this may be '-Di386'; on a vax, this would be '-Dvax'. |
5587 |
This is normally not of interest to 'normal' users; however, it is passed |
|
5588 |
down to the c-compiler when methods are incrementally compiled to machine code." |
|
616 | 5589 |
|
5590 |
%{ /* NOCONTEXT */ |
|
831 | 5591 |
# ifndef CPU_DEFINE |
5592 |
# define CPU_DEFINE "-DunknownCPU" |
|
5593 |
# endif |
|
5594 |
||
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5595 |
RETURN ( __MKSTRING(CPU_DEFINE)); |
616 | 5596 |
%} |
5597 |
" |
|
5598 |
OperatingSystem getCPUDefine |
|
5599 |
" |
|
5600 |
! |
|
5601 |
||
5602 |
getCPUType |
|
5603 |
"return a string giving the type of machine we're running on. |
|
831 | 5604 |
Here, the machine for which ST/X was compiled is returned |
5605 |
(i.e. for all x86's, the same i386 is returned). |
|
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
756
diff
changeset
|
5606 |
This may normally not be of any interest to you ..." |
616 | 5607 |
|
5608 |
|cpu| |
|
5609 |
||
5610 |
%{ /* NOCONTEXT */ |
|
5611 |
||
5612 |
# ifdef vax |
|
5613 |
# define CPU_STRING "vax" |
|
5614 |
# endif |
|
5615 |
# ifdef mips |
|
5616 |
# define CPU_STRING "mips" |
|
5617 |
# endif |
|
5618 |
# ifdef i386 |
|
5619 |
# define CPU_STRING "i386" |
|
5620 |
# endif |
|
5621 |
# ifdef ns32k |
|
5622 |
# define CPU_STRING "ns32k" |
|
5623 |
# endif |
|
5624 |
# ifdef mc68k |
|
5625 |
# define CPU_STRING "mc68k" |
|
5626 |
# endif |
|
5627 |
# ifdef mc88k |
|
5628 |
# define CPU_STRING "mc88k" |
|
5629 |
# endif |
|
5630 |
# ifdef sparc |
|
5631 |
# define CPU_STRING "sparc" |
|
5632 |
# endif |
|
5633 |
# ifdef hppa |
|
5634 |
# define CPU_STRING "hppa" |
|
5635 |
# endif |
|
5636 |
# ifdef rs6000 |
|
5637 |
# define CPU_STRING "rs6000" |
|
5638 |
# endif |
|
831 | 5639 |
# ifdef powerPC |
5640 |
# define CPU_STRING "powerPC" |
|
5641 |
# endif |
|
616 | 5642 |
# ifdef alpha |
5643 |
# define CPU_STRING "alpha" |
|
5644 |
# endif |
|
5645 |
# ifdef transputer |
|
5646 |
# define CPU_STRING "transputer" |
|
5647 |
# endif |
|
5648 |
# ifdef ibm370 |
|
5649 |
# define CPU_STRING "ibm370" |
|
5650 |
# endif |
|
5651 |
||
5652 |
# ifndef CPU_STRING |
|
5653 |
# define CPU_STRING "unknown" |
|
5654 |
# endif |
|
5655 |
||
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5656 |
cpu = __MKSTRING(CPU_STRING); |
616 | 5657 |
# undef CPU_STRING |
831 | 5658 |
%}. |
616 | 5659 |
^ cpu |
5660 |
||
5661 |
" |
|
5662 |
OperatingSystem getCPUType |
|
5663 |
" |
|
5664 |
||
5665 |
"examples: are we running on a ss-10/solaris ?" |
|
5666 |
" |
|
5667 |
(OperatingSystem getCPUType = 'sparc') |
|
5668 |
and:[OperatingSystem getOSType = 'solaris'] |
|
5669 |
" |
|
5670 |
||
5671 |
"or on a pc/solaris ?" |
|
5672 |
" |
|
5673 |
(OperatingSystem getCPUType = 'i386') |
|
5674 |
and:[OperatingSystem getOSType = 'solaris'] |
|
5675 |
" |
|
5676 |
! |
|
5677 |
||
5678 |
getCommandOutputFrom:aCommand |
|
5679 |
"execute a simple command (such as hostname) and |
|
5680 |
return the commands output as a string" |
|
5681 |
||
5682 |
|p result| |
|
5683 |
||
5684 |
ForkFailed ifFalse:[ |
|
5685 |
PipeStream openErrorSignal handle:[:ex | |
|
5686 |
ForkFailed := true. |
|
5687 |
'OS: cannot fork/popen' errorPrintNL. |
|
5688 |
ex return. |
|
5689 |
] do:[ |
|
5690 |
p := PipeStream readingFrom:aCommand. |
|
5691 |
p notNil ifTrue:[ |
|
5692 |
result := p nextLine. |
|
5693 |
p close |
|
5694 |
] |
|
5695 |
] |
|
5696 |
]. |
|
5697 |
^ result |
|
5698 |
! |
|
5699 |
||
5700 |
getDomainName |
|
5701 |
"return the domain this host is in. |
|
5702 |
Notice: |
|
1487 | 5703 |
not all systems support this; on some, 'unknown' is returned." |
616 | 5704 |
|
5705 |
|name| |
|
5706 |
||
5707 |
DomainName notNil ifTrue:[ |
|
1487 | 5708 |
^ DomainName |
616 | 5709 |
]. |
5710 |
||
5711 |
%{ /* STACK: 2048 */ |
|
5712 |
#if defined(HAS_GETDOMAINNAME) |
|
5713 |
char buffer[128]; |
|
5714 |
||
5715 |
if (getdomainname(buffer, sizeof(buffer)) == 0) { |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5716 |
name = __MKSTRING(buffer); |
616 | 5717 |
} |
5718 |
#else |
|
5719 |
# if defined(HAS_UNAME) && defined(HAS_UTS_DOMAINNAME) |
|
5720 |
struct utsname ubuff; |
|
5721 |
||
5722 |
if (uname(&ubuff) >= 0) { |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5723 |
name = __MKSTRING(ubuff.domainname); |
1433 | 5724 |
} |
5725 |
# else |
|
5726 |
# if defined(HAS_SYSINFO) && defined(SI_SRPC_DOMAIN) |
|
5727 |
char buffer[256]; |
|
5728 |
int ret; |
|
5729 |
||
5730 |
if ((ret = sysinfo(SI_SRPC_DOMAIN, buffer, sizeof(buffer))) >= 0 && ret <= sizeof(buffer)) { |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5731 |
name = __MKSTRING(buffer); |
1433 | 5732 |
} |
5733 |
# endif |
|
616 | 5734 |
# endif |
5735 |
#endif |
|
5736 |
%}. |
|
5737 |
name isNil ifTrue:[ |
|
1487 | 5738 |
name := self getEnvironment:'DOMAIN'. |
5739 |
name isNil ifTrue:[ |
|
5740 |
name := self getCommandOutputFrom:'domainname' |
|
5741 |
] |
|
616 | 5742 |
]. |
5743 |
name isNil ifTrue:[ |
|
1487 | 5744 |
'OS: cannot find out domainname' errorPrintNL. |
5745 |
name := 'unknown'. |
|
616 | 5746 |
]. |
5747 |
DomainName := name. |
|
5748 |
^ name |
|
5749 |
||
5750 |
" |
|
5751 |
OperatingSystem getDomainName |
|
5752 |
" |
|
1433 | 5753 |
|
5754 |
"Modified: 26.4.1996 / 10:04:54 / stefan" |
|
616 | 5755 |
! |
5756 |
||
5757 |
getEnvironment:aStringOrSymbol |
|
5758 |
"get an environment string" |
|
10 | 5759 |
|
5760 |
%{ /* NOCONTEXT */ |
|
5761 |
||
616 | 5762 |
char *env; |
5763 |
||
5764 |
if (__isString(aStringOrSymbol) || __isSymbol(aStringOrSymbol)) { |
|
1632 | 5765 |
#ifdef WIN32 |
5766 |
char buff[512]; |
|
5767 |
||
5768 |
env = NULL; |
|
5769 |
if (GetEnvironmentVariable(__stringVal(aStringOrSymbol), |
|
5770 |
buff, |
|
5771 |
sizeof(buff)-1)) { |
|
5772 |
env = buff; |
|
5773 |
} |
|
5774 |
#else |
|
1135 | 5775 |
env = (char *)getenv(__stringVal(aStringOrSymbol)); |
1632 | 5776 |
#endif |
616 | 5777 |
if (env) { |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5778 |
RETURN ( __MKSTRING(env) ); |
616 | 5779 |
} |
5780 |
} |
|
5781 |
%} |
|
5782 |
. |
|
5783 |
^ nil |
|
5784 |
||
5785 |
" |
|
5786 |
OperatingSystem getEnvironment:'LANG' |
|
5787 |
OperatingSystem getEnvironment:'LOGIN' |
|
5788 |
OperatingSystem getEnvironment:'HOME' |
|
5789 |
OperatingSystem getEnvironment:'NNTPSERVER' |
|
5790 |
OperatingSystem getEnvironment:'MAIL' |
|
5791 |
OperatingSystem getEnvironment:'PATH' |
|
5792 |
" |
|
5793 |
! |
|
5794 |
||
5795 |
getHostName |
|
5796 |
"return the hostname we are running on - if there is |
|
5797 |
a HOST environment variable, we are much faster here ... |
|
5798 |
Notice: |
|
5799 |
not all systems support this; on some, 'unknown' is returned." |
|
5800 |
||
5801 |
|name| |
|
5802 |
||
5803 |
HostName notNil ifTrue:[ |
|
5804 |
^ HostName |
|
5805 |
]. |
|
5806 |
||
5807 |
%{ /* STACK: 2048 */ |
|
5808 |
#if defined(HAS_GETHOSTNAME) |
|
5809 |
char buffer[128]; |
|
5810 |
||
5811 |
if (gethostname(buffer, sizeof(buffer)) == 0) { |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5812 |
name = __MKSTRING(buffer); |
616 | 5813 |
} |
5814 |
#else |
|
5815 |
# if defined(HAS_UNAME) |
|
5816 |
struct utsname ubuff; |
|
5817 |
||
5818 |
if (uname(&ubuff) >= 0) { |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5819 |
name = __MKSTRING(ubuff.nodename); |
616 | 5820 |
} |
831 | 5821 |
# else |
1702 | 5822 |
# if defined(HAS_SYSINFO) && defined(SI_HOSTNAME) |
5823 |
char buffer[256]; |
|
5824 |
int ret; |
|
5825 |
||
5826 |
if ((ret = sysinfo(SI_HOSTNAME, buffer, sizeof(buffer))) >= 0 && ret <= sizeof(buffer)) { |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
5827 |
name = __MKSTRING(buffer); |
1702 | 5828 |
} |
5829 |
# else |
|
5830 |
# ifdef WIN32 |
|
831 | 5831 |
char buffer[128]; |
5832 |
int buffSize = sizeof(buffer); |
|
5833 |
||
5834 |
if (GetComputerName(buffer, &buffSize) == TRUE) { |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
5835 |
name = __MKSTRING(buffer); |
831 | 5836 |
} |
1702 | 5837 |
# endif |
831 | 5838 |
# endif |
1 | 5839 |
# endif |
616 | 5840 |
#endif |
5841 |
%}. |
|
5842 |
name isNil ifTrue:[ |
|
5843 |
name := self getEnvironment:'HOST'. |
|
5844 |
name isNil ifTrue:[ |
|
5845 |
name := self getCommandOutputFrom:'hostname' |
|
5846 |
] |
|
5847 |
]. |
|
5848 |
name isNil ifTrue:[ |
|
5849 |
'OS: cannot find out hostname' errorPrintNL. |
|
5850 |
name := 'unknown'. |
|
5851 |
]. |
|
5852 |
HostName := name. |
|
5853 |
^ name |
|
5854 |
||
5855 |
" |
|
5856 |
OperatingSystem getHostName |
|
5857 |
" |
|
5858 |
! |
|
5859 |
||
1034 | 5860 |
getLocaleInfo |
5861 |
"return a dictionary filled with values from the locale information; |
|
5862 |
Not all fields may be present, depending on the OS's setup and capabilities. |
|
5863 |
Possible fields are: |
|
5864 |
decimalPoint <String> |
|
5865 |
||
5866 |
thousandsSep <String> |
|
5867 |
||
5868 |
internationalCurrencySymbol <String> |
|
5869 |
||
5870 |
currencySymbol <String> |
|
5871 |
||
5872 |
monetaryDecimalPoint <String> |
|
5873 |
||
5874 |
monetaryThousandsSeparator <String> |
|
5875 |
||
5876 |
positiveSign <String> |
|
5877 |
||
5878 |
negativeSign <String> |
|
5879 |
||
5880 |
internationalFractionalDigits <Integer> |
|
5881 |
||
5882 |
fractionalDigits <Integer> |
|
5883 |
||
5884 |
positiveSignPrecedesCurrencySymbol <Boolean> |
|
5885 |
||
5886 |
negativeSignPrecedesCurrencySymbol <Boolean> |
|
5887 |
||
5888 |
positiveSignSeparatedBySpaceFromCurrencySymbol <Boolean> |
|
5889 |
||
5890 |
negativeSignSeparatedBySpaceFromCurrencySymbol <Boolean> |
|
5891 |
||
5892 |
positiveSignPosition <Symbol> |
|
5893 |
one of: #parenthesesAround, |
|
5894 |
#signPrecedes, |
|
5895 |
#signSuceeds, |
|
5896 |
#signPrecedesCurrencySymbol, |
|
5897 |
#signSuceedsCurrencySymbol |
|
5898 |
||
5899 |
negativeSignPosition <like above> |
|
5900 |
||
5901 |
it is up to the application to deal with undefined values. |
|
5902 |
||
5903 |
Notice, that (for now), the system does not use this information; |
|
5904 |
it should be used by applications as required. |
|
5905 |
" |
|
5906 |
||
5907 |
|info val| |
|
5908 |
||
5909 |
LocaleInfo notNil ifTrue:[ |
|
5910 |
"/ return the internal info; useful on systems which do not |
|
5911 |
"/ support this. |
|
5912 |
^ LocaleInfo |
|
5913 |
]. |
|
5914 |
||
5915 |
info := IdentityDictionary new. |
|
5916 |
%{ |
|
5917 |
char *decimalPoint; /* something like "." (US) or "," (german) */ |
|
5918 |
char *thousandsSep; /* something like "," (US) or "." (german) */ |
|
5919 |
char *intCurrencySymbol; /* international currency symbol; something like "USD " "DM " */ |
|
5920 |
char *currencySymbol; /* local currency symbol; something like "USD " "DM " */ |
|
5921 |
char *monDecimalPoint; /* money: decimal point */ |
|
5922 |
char *monThousandsSep; /* money: thousands sep */ |
|
5923 |
char *positiveSign; |
|
5924 |
char *negativeSign; |
|
5925 |
int intFractDigits; /* money: international digits after decPoint */ |
|
5926 |
int fractDigits; /* money: local digits after decPoint */ |
|
5927 |
int csPosPrecedes; /* money: 1 if currency symbol precedes a positive value; 0 if it sceeds */ |
|
5928 |
int csNegPrecedes; /* money: 1 if currency symbol precedes a negative value; 0 if it sceeds */ |
|
5929 |
int csPosSepBySpace; /* money: 1 if currency symbol should be separated by a space from a positive value; 0 if no space */ |
|
5930 |
int csNegSepBySpace; /* money: 1 if currency symbol should be separated by a space from a negative value; 0 if no space */ |
|
5931 |
int csPosSignPosition; /* money: 0: ()'s around the value & currency symbol */ |
|
5932 |
int csNegSignPosition; /* 1: sign precedes the value & currency symbol */ |
|
5933 |
/* 2: sign succeeds the value & currency symbol */ |
|
5934 |
/* 3: sign immediately precedes the currency symbol */ |
|
5935 |
/* 4: sign immediately suceeds the currency symbol */ |
|
5936 |
||
5937 |
#if defined(HAS_LOCALECONV) |
|
5938 |
struct lconv *conf; |
|
5939 |
||
5940 |
conf = localeconv(); |
|
5941 |
if (conf) { |
|
5942 |
decimalPoint = conf->decimal_point; |
|
5943 |
thousandsSep = conf->thousands_sep; |
|
5944 |
intCurrencySymbol = conf->int_curr_symbol; |
|
5945 |
currencySymbol = conf->currency_symbol; |
|
5946 |
monDecimalPoint = conf->mon_decimal_point; |
|
5947 |
monThousandsSep = conf->mon_thousands_sep; |
|
5948 |
positiveSign = conf->positive_sign; |
|
5949 |
negativeSign = conf->negative_sign; |
|
5950 |
intFractDigits = conf->int_frac_digits; |
|
5951 |
fractDigits = conf->frac_digits; |
|
5952 |
csPosPrecedes = conf->p_cs_precedes; |
|
5953 |
csNegPrecedes = conf->n_cs_precedes; |
|
5954 |
csPosSepBySpace = conf->p_sep_by_space; |
|
5955 |
csNegSepBySpace = conf->n_sep_by_space; |
|
5956 |
csPosSignPosition = conf->p_sign_posn; |
|
5957 |
csNegSignPosition = conf->n_sign_posn; |
|
5958 |
} |
|
5959 |
#else |
|
5960 |
decimalPoint = (char *)0; |
|
5961 |
thousandsSep = (char *)0; |
|
5962 |
intCurrencySymbol = (char *)0; |
|
5963 |
currencySymbol = (char *)0; |
|
5964 |
monDecimalPoint = (char *)0; |
|
5965 |
monThousandsSep = (char *)0; |
|
5966 |
positiveSign = (char *)0; |
|
5967 |
negativeSign =(char *)0; |
|
5968 |
intFractDigits = -1; |
|
5969 |
fractDigits = -1; |
|
5970 |
csPosPrecedes = -1; |
|
5971 |
csNegPrecedes = -1; |
|
5972 |
csPosSepBySpace = -1; |
|
5973 |
csNegSepBySpace = -1; |
|
5974 |
csPosSignPosition = -1; |
|
5975 |
csNegSignPosition = -1; |
|
5976 |
#endif |
|
5977 |
if (decimalPoint) { |
|
5978 |
val = __MKSTRING(decimalPoint); |
|
5979 |
__AT_PUT_(info, @symbol(decimalPoint), val); |
|
5980 |
} |
|
5981 |
if (thousandsSep) { |
|
5982 |
val = __MKSTRING(thousandsSep); |
|
5983 |
__AT_PUT_(info, @symbol(thousandsSeparator), val); |
|
5984 |
} |
|
5985 |
if (intCurrencySymbol) { |
|
5986 |
val = __MKSTRING(intCurrencySymbol); |
|
5987 |
__AT_PUT_(info, @symbol(internationCurrencySymbol), val); |
|
5988 |
} |
|
5989 |
if (currencySymbol) { |
|
5990 |
val = __MKSTRING(currencySymbol); |
|
5991 |
__AT_PUT_(info, @symbol(currencySymbol), val); |
|
5992 |
} |
|
5993 |
if (monDecimalPoint) { |
|
5994 |
val = __MKSTRING(monDecimalPoint); |
|
5995 |
__AT_PUT_(info, @symbol(monetaryDecimalPoint), val); |
|
5996 |
} |
|
5997 |
if (monThousandsSep) { |
|
5998 |
val = __MKSTRING(monThousandsSep); |
|
5999 |
__AT_PUT_(info, @symbol(monetaryThousandsSeparator), val); |
|
6000 |
} |
|
6001 |
if (positiveSign) { |
|
6002 |
val = __MKSTRING(positiveSign); |
|
6003 |
__AT_PUT_(info, @symbol(positiveSign), val); |
|
6004 |
} |
|
6005 |
if (negativeSign) { |
|
6006 |
val = __MKSTRING(negativeSign); |
|
6007 |
__AT_PUT_(info, @symbol(negativeSign), val); |
|
6008 |
} |
|
6009 |
if (intFractDigits >= 0) { |
|
6010 |
__AT_PUT_(info, @symbol(internationalFractionalDigits), __MKSMALLINT(intFractDigits)); |
|
6011 |
} |
|
6012 |
if (fractDigits >= 0) { |
|
6013 |
__AT_PUT_(info, @symbol(fractionalDigits), __MKSMALLINT(fractDigits)); |
|
6014 |
} |
|
6015 |
if (csPosPrecedes >= 0) { |
|
6016 |
if (csPosPrecedes == 0) { |
|
6017 |
val = false; |
|
6018 |
} else { |
|
6019 |
val = true; |
|
6020 |
} |
|
6021 |
__AT_PUT_(info, @symbol(positiveSignPrecedesCurrencySymbol), val ); |
|
6022 |
} |
|
6023 |
if (csNegPrecedes >= 0) { |
|
6024 |
if (csNegPrecedes == 0) { |
|
6025 |
val = false; |
|
6026 |
} else { |
|
6027 |
val = true; |
|
6028 |
} |
|
6029 |
__AT_PUT_(info, @symbol(negativeSignPrecedesCurrencySymbol), val ); |
|
6030 |
} |
|
6031 |
if (csPosSepBySpace >= 0) { |
|
6032 |
if (csPosSepBySpace == 0) { |
|
6033 |
val = false; |
|
6034 |
} else { |
|
6035 |
val = true; |
|
6036 |
} |
|
6037 |
__AT_PUT_(info, @symbol(positiveSignSeparatedBySpaceFromCurrencySymbol), val); |
|
6038 |
} |
|
6039 |
if (csNegSepBySpace >= 0) { |
|
6040 |
if (csNegSepBySpace == 0) { |
|
6041 |
val = false; |
|
6042 |
} else { |
|
6043 |
val = true; |
|
6044 |
} |
|
6045 |
__AT_PUT_(info, @symbol(negativeSignSeparatedBySpaceFromCurrencySymbol), val); |
|
6046 |
} |
|
6047 |
switch (csPosSignPosition) { |
|
6048 |
case 0: |
|
6049 |
val = @symbol(parenthesesAround); |
|
6050 |
break; |
|
6051 |
||
6052 |
case 1: |
|
6053 |
val = @symbol(signPrecedes); |
|
6054 |
break; |
|
6055 |
||
6056 |
case 2: |
|
6057 |
val = @symbol(signSuceeds); |
|
6058 |
break; |
|
6059 |
||
6060 |
case 3: |
|
6061 |
val = @symbol(signPrecedesCurrencySymbol); |
|
6062 |
break; |
|
6063 |
||
6064 |
case 4: |
|
6065 |
val = @symbol(signSuceedsCurrencySymbol); |
|
6066 |
break; |
|
6067 |
||
6068 |
default: |
|
6069 |
val = nil; |
|
6070 |
} |
|
6071 |
if (val != nil) { |
|
6072 |
__AT_PUT_(info, @symbol(positiveSignPosition), val); |
|
6073 |
} |
|
6074 |
||
6075 |
switch (csNegSignPosition) { |
|
6076 |
case 0: |
|
6077 |
val = @symbol(parenthesesAround); |
|
6078 |
break; |
|
6079 |
||
6080 |
case 1: |
|
6081 |
val = @symbol(signPrecedes); |
|
6082 |
break; |
|
6083 |
||
6084 |
case 2: |
|
6085 |
val = @symbol(signSuceeds); |
|
6086 |
break; |
|
6087 |
||
6088 |
case 3: |
|
6089 |
val = @symbol(signPrecedesCurrencySymbol); |
|
6090 |
break; |
|
6091 |
||
6092 |
case 4: |
|
6093 |
val = @symbol(signSuceedsCurrencySymbol); |
|
6094 |
break; |
|
6095 |
||
6096 |
default: |
|
6097 |
val = nil; |
|
6098 |
} |
|
6099 |
if (val != nil) { |
|
6100 |
__AT_PUT_(info, @symbol(negativeSignPosition), val); |
|
6101 |
} |
|
6102 |
%}. |
|
6103 |
^ info |
|
6104 |
||
6105 |
" |
|
6106 |
OperatingSystem getLocaleInfo |
|
6107 |
" |
|
6108 |
||
6109 |
"Created: 23.12.1995 / 14:19:20 / cg" |
|
6110 |
! |
|
6111 |
||
616 | 6112 |
getOSDefine |
6113 |
"return a string which was used to identify this machine when stx was |
|
6114 |
compiled, and which should be passed down when compiling methods. |
|
6115 |
For example, on linux, this is '-DLINUX'." |
|
6116 |
||
6117 |
%{ /* NOCONTEXT */ |
|
831 | 6118 |
#ifdef WIN32 |
6119 |
# ifndef OS_DEFINE |
|
6120 |
# define OS_DEFINE "-DWIN32" |
|
6121 |
# endif |
|
6122 |
#endif |
|
6123 |
||
616 | 6124 |
#ifndef OS_DEFINE |
6125 |
# define OS_DEFINE "-DunknownOS" |
|
6126 |
#endif |
|
831 | 6127 |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6128 |
RETURN ( __MKSTRING(OS_DEFINE)); |
1987 | 6129 |
|
6130 |
#undef OS_DEFINE |
|
616 | 6131 |
%} |
6132 |
" |
|
6133 |
OperatingSystem getOSDefine |
|
6134 |
" |
|
6135 |
! |
|
6136 |
||
6137 |
getOSType |
|
6138 |
"return a string giving the type of OS we're running on. |
|
6139 |
This can be used to adapt programs to certain environment |
|
6140 |
differences (for example: mail-lock strategy ...)" |
|
6141 |
||
6142 |
|os| |
|
6143 |
||
6144 |
%{ /* NOCONTEXT */ |
|
6145 |
||
6146 |
# ifdef MSDOS |
|
6147 |
# define OS_STRING "msdos" |
|
6148 |
# endif |
|
6149 |
||
831 | 6150 |
# ifdef WIN32 |
1987 | 6151 |
# define OS_STRING "win32" |
831 | 6152 |
|
6153 |
# endif |
|
6154 |
||
616 | 6155 |
# ifdef MSWINDOWS |
6156 |
# define OS_STRING "mswindows" |
|
6157 |
# endif |
|
6158 |
||
6159 |
# ifdef NT |
|
6160 |
# define OS_STRING "nt" |
|
6161 |
# endif |
|
6162 |
||
6163 |
# ifdef VMS |
|
6164 |
# define OS_STRING "vms" |
|
6165 |
# endif |
|
6166 |
||
6167 |
# ifdef MVS |
|
6168 |
# define OS_STRING "mvs" |
|
6169 |
# endif |
|
6170 |
||
6171 |
# ifdef OS2 |
|
6172 |
# define OS_STRING "os2" |
|
6173 |
# endif |
|
6174 |
||
6175 |
# ifdef sinix |
|
6176 |
# define OS_STRING "sinix" |
|
6177 |
# endif |
|
6178 |
||
6179 |
# ifdef ultrix |
|
6180 |
# define OS_STRING "ultrix" |
|
6181 |
# endif |
|
6182 |
||
6183 |
# ifdef sco |
|
6184 |
# define OS_STRING "sco" |
|
6185 |
# endif |
|
6186 |
||
6187 |
# ifdef hpux |
|
6188 |
# define OS_STRING "hpux" |
|
6189 |
# endif |
|
6190 |
||
6191 |
# ifdef LINUX |
|
6192 |
# define OS_STRING "linux" |
|
6193 |
# endif |
|
6194 |
||
6195 |
# ifdef sunos |
|
6196 |
# define OS_STRING "sunos" |
|
6197 |
# endif |
|
6198 |
||
6199 |
# ifdef solaris |
|
6200 |
# define OS_STRING "solaris" |
|
6201 |
# endif |
|
6202 |
||
6203 |
# ifdef IRIS |
|
6204 |
# define OS_STRING "irix" |
|
6205 |
# endif |
|
6206 |
||
6207 |
# ifdef aix |
|
6208 |
# define OS_STRING "aix" |
|
6209 |
# endif |
|
6210 |
||
6211 |
# ifdef realIX |
|
6212 |
# define OS_STRING "realIX" |
|
6213 |
# endif |
|
6214 |
||
6215 |
/* |
|
6216 |
* no concrete info; become somewhat vague ... |
|
6217 |
*/ |
|
6218 |
# ifndef OS_STRING |
|
6219 |
# ifdef MACH |
|
6220 |
# define OS_STRING "mach" |
|
6221 |
# endif |
|
6222 |
# endif |
|
6223 |
||
6224 |
# ifndef OS_STRING |
|
6225 |
# ifdef BSD |
|
6226 |
# define OS_STRING "bsd" |
|
6227 |
# endif |
|
6228 |
||
6229 |
# ifdef SYSV |
|
6230 |
# ifdef SYSV3 |
|
6231 |
# define OS_STRING "sys5_3" |
|
6232 |
# else |
|
6233 |
# ifdef SYSV4 |
|
6234 |
# define OS_STRING "sys5_4" |
|
6235 |
# else |
|
6236 |
# define OS_STRING "sys5" |
|
6237 |
# endif |
|
6238 |
# endif |
|
6239 |
# endif |
|
6240 |
# endif |
|
6241 |
||
6242 |
/* |
|
6243 |
* become very vague ... |
|
6244 |
*/ |
|
6245 |
# ifndef OS_STRING |
|
6246 |
# ifdef POSIX |
|
6247 |
# define OS_STRING "posix" |
|
6248 |
# endif |
|
6249 |
# endif |
|
6250 |
# ifndef OS_STRING |
|
6251 |
# ifdef UNIX |
|
6252 |
# define OS_STRING "unix" |
|
6253 |
# endif |
|
6254 |
# endif |
|
6255 |
||
6256 |
# ifndef OS_STRING |
|
6257 |
# define OS_STRING "unknown" |
|
6258 |
# endif |
|
6259 |
||
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6260 |
os = __MKSTRING(OS_STRING); |
1987 | 6261 |
|
616 | 6262 |
# undef OS_STRING |
831 | 6263 |
%}. |
616 | 6264 |
^ os |
6265 |
||
6266 |
"OperatingSystem getOSType" |
|
6267 |
! |
|
6268 |
||
6269 |
getProcessId |
|
6270 |
"return the (unix-)processId" |
|
6271 |
||
6272 |
%{ /* NOCONTEXT */ |
|
6273 |
||
6274 |
int pid = 0; |
|
6275 |
#ifdef UNIX_LIKE |
|
6276 |
pid = getpid(); |
|
1632 | 6277 |
#else |
6278 |
# ifdef WIN32 |
|
6279 |
pid = GetCurrentProcessId() & 0x3FFFFFFF; |
|
6280 |
# endif |
|
616 | 6281 |
#endif |
1135 | 6282 |
RETURN ( __MKSMALLINT(pid) ); |
616 | 6283 |
%} |
6284 |
" |
|
6285 |
OperatingSystem getProcessId |
|
6286 |
" |
|
6287 |
! |
|
6288 |
||
6289 |
getSystemID |
|
6290 |
"if supported by the OS, return the systemID; |
|
6291 |
a unique per machine identification. |
|
6292 |
WARNING: |
|
6293 |
not all systems support this; on some, 'unknown' is returned." |
|
6294 |
||
6295 |
%{ /* NO_CONTEXT */ |
|
6296 |
#if defined(IRIX5) && !defined(HAS_GETHOSTID) |
|
6297 |
char idBuffer[MAXSYSIDSIZE]; |
|
6298 |
int retVal; |
|
6299 |
OBJ arr; |
|
6300 |
||
6301 |
if ((retVal = syssgi(SGI_SYSID, idBuffer)) == 0) { |
|
6302 |
arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(MAXSYSIDSIZE); |
|
6303 |
bcopy(idBuffer, __ByteArrayInstPtr(arr)->ba_element, MAXSYSIDSIZE); |
|
6304 |
RETURN (arr); |
|
6305 |
} |
|
6306 |
#endif |
|
6307 |
#if defined(HAS_GETHOSTID) |
|
6308 |
int runningId; |
|
6309 |
OBJ arr; |
|
6310 |
||
6311 |
runningId = gethostid(); |
|
6312 |
arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(4); |
|
6313 |
*(int *)(__ByteArrayInstPtr(arr)->ba_element) = runningId; |
|
6314 |
RETURN (arr); |
|
6315 |
#endif |
|
6316 |
%}. |
|
6317 |
^ 'unknown' |
|
6318 |
||
6319 |
" |
|
6320 |
OperatingSystem getSystemID |
|
6321 |
" |
|
6322 |
! |
|
6323 |
||
6324 |
getSystemInfo |
|
831 | 6325 |
"return info on the system weare running on. |
6326 |
If the system supports the uname system call, that info is returned; |
|
616 | 6327 |
otherwise, some simulated info is returned. |
831 | 6328 |
|
616 | 6329 |
WARNING: |
831 | 6330 |
Do not depend on the amount and contents of the returned information, some |
6331 |
systems may return more/less than others. Also, the contents depends on the |
|
6332 |
OS, for example, linux returns 'ix86', while WIN32 returns 'x86'. |
|
6333 |
||
6334 |
This method is mainly provided to augment error reports with some system |
|
6335 |
information. |
|
6336 |
(in case of system/version specific OS errors, conditional workarounds and patches |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6337 |
may be based upon this info) |
616 | 6338 |
|
6339 |
The returned info may (or may not) contain: |
|
831 | 6340 |
#system -> some operating system identification (irix, Linux, nt, win32s ...) |
6341 |
#version -> OS version (some os version identification) |
|
6342 |
#release -> OS release (3.5, 1.2.1 ...) |
|
6343 |
#node -> some host identification (hostname) |
|
6344 |
#domain -> domain name (hosts domain) |
|
6345 |
#machine -> type of machine (i586, mips ...) |
|
616 | 6346 |
" |
6347 |
||
6348 |
|sys node rel ver mach dom mtyp brel info| |
|
6349 |
||
1060
119d45f975e1
increased getSystemInfos stack - just to make certain
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
6350 |
%{ /* STACK: 4096 */ |
616 | 6351 |
#if defined(HAS_UNAME) |
6352 |
struct utsname ubuff; |
|
6353 |
||
6354 |
if (uname(&ubuff) >= 0) { |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6355 |
sys = __MKSTRING(ubuff.sysname); |
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6356 |
node = __MKSTRING(ubuff.nodename); |
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6357 |
rel = __MKSTRING(ubuff.release); |
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6358 |
ver = __MKSTRING(ubuff.version); |
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6359 |
mach = __MKSTRING(ubuff.machine); |
616 | 6360 |
# ifdef HAS_UTS_DOMAINNAME |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6361 |
dom = __MKSTRING(ubuff.domainname); |
1675 | 6362 |
# else |
6363 |
# if defined(HAS_GETDOMAINNAME) |
|
6364 |
{ |
|
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
6365 |
char buffer[128]; |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
6366 |
|
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
6367 |
if (getdomainname(buffer, sizeof(buffer)) == 0) { |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
6368 |
dom = __MKSTRING(buffer); |
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
6369 |
} |
1675 | 6370 |
} |
6371 |
# endif |
|
616 | 6372 |
# endif |
6373 |
} |
|
831 | 6374 |
#else /* no uname */ |
6375 |
# ifdef WIN32 |
|
6376 |
||
6377 |
char vsnBuffer[32]; |
|
6378 |
char *s; |
|
6379 |
int winVer; |
|
6380 |
DWORD vsn; |
|
6381 |
SYSTEM_INFO sysInfo; |
|
6382 |
||
6383 |
vsn = GetVersion(); |
|
6384 |
||
6385 |
if (HIWORD(vsn) & 0x8000) { |
|
6386 |
s = "win32s"; |
|
6387 |
} else { |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6388 |
s = "nt"; |
831 | 6389 |
} |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6390 |
sys = __MKSTRING(s); |
831 | 6391 |
winVer = LOWORD(vsn); |
6392 |
sprintf(vsnBuffer, "%d.%d", LOBYTE(winVer), HIBYTE(winVer)); |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6393 |
rel = __MKSTRING(vsnBuffer); |
831 | 6394 |
|
6395 |
GetSystemInfo(&sysInfo); |
|
6396 |
if (sysInfo.dwProcessorType) { |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6397 |
sprintf(vsnBuffer, "%d", sysInfo.dwProcessorType); |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6398 |
mach = __MKSTRING(vsnBuffer); |
831 | 6399 |
} |
6400 |
||
6401 |
# endif /* WIN32 */ |
|
6402 |
#endif /* no uname */ |
|
616 | 6403 |
%}. |
6404 |
sys isNil ifTrue:[ |
|
6405 |
sys := self getSystemType. |
|
6406 |
]. |
|
6407 |
node isNil ifTrue:[ |
|
6408 |
node := self getHostName |
|
6409 |
]. |
|
6410 |
dom isNil ifTrue:[ |
|
6411 |
dom := self getDomainName |
|
6412 |
]. |
|
831 | 6413 |
mach isNil ifTrue:[ |
6414 |
mach := self getCPUType |
|
6415 |
]. |
|
616 | 6416 |
|
6417 |
info := IdentityDictionary new. |
|
6418 |
info at:#system put:sys. |
|
6419 |
info at:#node put:node. |
|
6420 |
rel notNil ifTrue:[info at:#release put:rel]. |
|
6421 |
ver notNil ifTrue:[info at:#version put:ver]. |
|
6422 |
mach notNil ifTrue:[info at:#machine put:mach]. |
|
6423 |
dom notNil ifTrue:[info at:#domain put:dom]. |
|
6424 |
^ info |
|
6425 |
||
6426 |
" |
|
6427 |
OperatingSystem getSystemInfo |
|
6428 |
" |
|
6429 |
! |
|
6430 |
||
6431 |
getSystemType |
|
6432 |
"return a string giving the type of system we're running on. |
|
6433 |
This is almost the same as getOSType, but the returned string |
|
6434 |
is slightly different for some systems (i.e. iris vs. irix). |
|
6435 |
Dont depend on this - use getOSType. I dont really see a point |
|
831 | 6436 |
here ... |
6437 |
(except for slight differences between next/mach and other machs)" |
|
616 | 6438 |
|
6439 |
|sys| |
|
6440 |
||
6441 |
%{ |
|
6442 |
# ifdef NEXT |
|
6443 |
# define SYS_STRING "next" |
|
6444 |
# endif |
|
6445 |
||
6446 |
# ifdef IRIS |
|
6447 |
# define SYS_STRING "iris" |
|
6448 |
# endif |
|
6449 |
||
831 | 6450 |
# ifdef WIN32 |
6451 |
# define SYS_STRING "win32" |
|
6452 |
# endif |
|
6453 |
||
616 | 6454 |
# ifdef SYS_STRING |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
6455 |
sys = __MKSTRING(SYS_STRING); |
616 | 6456 |
# undef SYS_STRING |
6457 |
# endif |
|
831 | 6458 |
%}. |
616 | 6459 |
sys isNil ifTrue:[ |
6460 |
^ self getOSType |
|
6461 |
]. |
|
6462 |
^ sys |
|
6463 |
||
6464 |
" |
|
6465 |
OperatingSystem getSystemType |
|
6466 |
" |
|
6467 |
! |
|
6468 |
||
6469 |
isBSDlike |
|
6470 |
"return true, if the OS we're running on is a 'real' unix." |
|
6471 |
||
6472 |
%{ /* NOCONTEXT */ |
|
6473 |
||
6474 |
#if defined(BSD) || defined(MACH) || defined(SYSV4) |
|
6475 |
RETURN ( true ); |
|
13 | 6476 |
#endif |
831 | 6477 |
%}. |
13 | 6478 |
^ false |
10 | 6479 |
! |
6480 |
||
616 | 6481 |
isMSDOSlike |
6482 |
"return true, if the OS we're running on is dos like |
|
6483 |
(in contrast to unix-like)." |
|
6484 |
||
6485 |
%{ /* NOCONTEXT */ |
|
6486 |
||
6487 |
#if defined(MSDOS_LIKE) |
|
6488 |
RETURN ( true ); |
|
6489 |
#endif |
|
831 | 6490 |
%}. |
616 | 6491 |
^ false |
6492 |
! |
|
6493 |
||
831 | 6494 |
isMSWINDOWSlike |
6495 |
"return true, if the OS we're running on is MS-Windows like." |
|
6496 |
||
6497 |
%{ /* NOCONTEXT */ |
|
6498 |
||
6499 |
#if defined(WIN32) |
|
6500 |
RETURN ( true ); |
|
6501 |
#endif |
|
6502 |
||
6503 |
%}. |
|
6504 |
^ false |
|
6505 |
! |
|
6506 |
||
6507 |
isOS2like |
|
6508 |
"return true, if the OS we're running on is OS2 like" |
|
6509 |
||
6510 |
%{ /* NOCONTEXT */ |
|
6511 |
||
6512 |
#if defined(OS2) |
|
6513 |
RETURN (true); |
|
6514 |
#endif |
|
6515 |
||
6516 |
%}. |
|
6517 |
^ false |
|
6518 |
! |
|
6519 |
||
1034 | 6520 |
isUNIXlike |
6521 |
"return true, if the OS we're running on is a unix like." |
|
6522 |
||
6523 |
%{ /* NOCONTEXT */ |
|
6524 |
||
6525 |
#if !defined(UNIX_LIKE) |
|
6526 |
RETURN ( false ); |
|
6527 |
#endif |
|
6528 |
%}. |
|
6529 |
^ true |
|
6530 |
! |
|
6531 |
||
616 | 6532 |
maxFileNameLength |
6533 |
"return the max number of characters in a filename. |
|
831 | 6534 |
CAVEAT: |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6535 |
Actually, the following is somewhat wrong - some systems |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6536 |
support different sizezs, depending on the volume. |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6537 |
We return a somewhat conservative number here." |
10 | 6538 |
|
6539 |
%{ /* NOCONTEXT */ |
|
616 | 6540 |
|
6541 |
/* |
|
6542 |
* XXX: newer systems provide a query function for this ... use it |
|
6543 |
*/ |
|
6544 |
# if defined(BSD) || defined(SYSV4) || defined(LONGFILENAMES) |
|
831 | 6545 |
RETURN ( __MKSMALLINT(255) ); |
616 | 6546 |
# endif |
6547 |
||
6548 |
# ifdef realIX |
|
831 | 6549 |
RETURN ( __MKSMALLINT(127) ); |
616 | 6550 |
# endif |
6551 |
||
6552 |
# ifdef SYSV |
|
831 | 6553 |
RETURN ( __MKSMALLINT(14) ); |
616 | 6554 |
# endif |
6555 |
||
6556 |
# ifdef MSDOS |
|
831 | 6557 |
RETURN ( __MKSMALLINT(9) ); |
616 | 6558 |
# endif |
6559 |
||
831 | 6560 |
# ifdef WIN32 |
616 | 6561 |
/* |
6562 |
* mhmh - depends on the filesystem type |
|
6563 |
*/ |
|
831 | 6564 |
RETURN ( __MKSMALLINT(9) ); |
616 | 6565 |
# endif |
6566 |
%}. |
|
6567 |
"unix default" |
|
831 | 6568 |
|
616 | 6569 |
^ 14 |
6570 |
! |
|
6571 |
||
1034 | 6572 |
setLocaleInfo:anInfoDictionary |
6573 |
"set the locale information; if set, this oerrides the OS's settings. |
|
6574 |
(internal in ST/X only - the OS's settings remain unaffected) |
|
6575 |
See description of fields in #getLocaleInfo. |
|
6576 |
||
6577 |
Notice, that (for now), the system does not use this information; |
|
6578 |
it should be used by applications as required." |
|
6579 |
||
6580 |
LocaleInfo := anInfoDictionary |
|
6581 |
||
6582 |
" |
|
6583 |
|d| |
|
6584 |
||
6585 |
d := IdentityDictionary new. |
|
6586 |
d at:#decimalPoint put:'.' . |
|
6587 |
d at:#thousandsSeparator put:',' . |
|
6588 |
d at:#currencySymbol put:'USD' . |
|
6589 |
d at:#monetaryDecimalPoint put:'.' . |
|
6590 |
d at:#monetaryThousandsSeparator put:'.' . |
|
6591 |
d at:#fractionalDigits put:2 . |
|
6592 |
d at:#positiveSign put:'+' . |
|
6593 |
d at:#negativeSign put:'-' . |
|
6594 |
d at:#positiveSignPrecedesCurrencySymbol put:true . |
|
6595 |
d at:#negativeSignPrecedesCurrencySymbol put:false . |
|
6596 |
OperatingSystem setLocaleInfo:d |
|
6597 |
" |
|
6598 |
! |
|
6599 |
||
616 | 6600 |
supportsIOInterrupts |
6601 |
"return true, if the OS supports IO availability interrupts |
|
6602 |
(i.e. SIGPOLL/SIGIO). |
|
6603 |
||
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6604 |
Currently, this mechanism does work for SYSV4 only ..." |
616 | 6605 |
|
6606 |
%{ /* NOCONTEXT */ |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
6607 |
#if defined(SYSV4) && defined(USE_SIGIO) && 0 |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6608 |
|
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6609 |
# if defined(SIGPOLL) || defined(SIGIO) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6610 |
# if (defined(F_GETFL) && defined(F_SETFL) && defined(FASYNC)) || defined(SYSV4) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6611 |
/* |
765
93bdb4f0e095
no, SIGIO does not work on SGI ...
Claus Gittinger <cg@exept.de>
parents:
764
diff
changeset
|
6612 |
* currently the only system where they work is unixware SYSV4 |
93bdb4f0e095
no, SIGIO does not work on SGI ...
Claus Gittinger <cg@exept.de>
parents:
764
diff
changeset
|
6613 |
* (not even on SGI ...) |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6614 |
*/ |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6615 |
# if !defined(NEXT) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6616 |
RETURN (true); |
616 | 6617 |
# endif |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6618 |
# endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6619 |
# endif |
616 | 6620 |
|
10 | 6621 |
#endif |
831 | 6622 |
%}. |
13 | 6623 |
^ false |
123 | 6624 |
! |
6625 |
||
616 | 6626 |
supportsNonBlockingIO |
6627 |
"return true, if the OS supports nonblocking IO." |
|
6628 |
||
6629 |
%{ /* NOCONTEXT */ |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6630 |
#if defined(F_GETFL) && defined(F_SETFL) && defined(FNDELAY) |
616 | 6631 |
RETURN (true); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6632 |
#endif |
831 | 6633 |
%}. |
616 | 6634 |
^ false |
123 | 6635 |
! |
6636 |
||
616 | 6637 |
supportsSelect |
6638 |
"return true, if the OS supports selecting on multiple |
|
6639 |
filedescriptors via select." |
|
6640 |
||
6641 |
%{ /* NOCONTEXT */ |
|
831 | 6642 |
#if defined(WIN32) |
6643 |
RETURN (false); |
|
6644 |
#endif |
|
616 | 6645 |
#if defined(sco) |
6646 |
/* |
|
831 | 6647 |
* sco has a select, but its broken: always waiting 1 second |
616 | 6648 |
*/ |
6649 |
RETURN(false); |
|
6650 |
#endif |
|
6651 |
%} |
|
6652 |
. |
|
6653 |
^ true |
|
6654 |
! ! |
|
6655 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
6656 |
!OperatingSystem class methodsFor:'shared memory access'! |
616 | 6657 |
|
6658 |
shmAttach:id address:addr flags:flags |
|
1247 | 6659 |
"low level entry to shmat()-system call. |
6660 |
Not supported on all operatingSystems" |
|
6661 |
||
616 | 6662 |
%{ /* NOCONTEXT */ |
6663 |
#ifdef WANT_SHM |
|
6664 |
void *address, *shmaddr; |
|
6665 |
int shmflg, shmid; |
|
6666 |
||
6667 |
if (__isSmallInteger(addr) |
|
6668 |
&& __bothSmallInteger(flags, id)) { |
|
1487 | 6669 |
shmaddr = (void *) __intVal(addr); |
6670 |
shmflg = __intVal(flags); |
|
6671 |
shmid = __intVal(id); |
|
6672 |
||
6673 |
address = shmat(shmid, shmaddr, shmflg); |
|
6674 |
if (address != (void *)-1) { |
|
6675 |
RETURN (__MKEXTERNALBYTES(addr)); |
|
6676 |
} |
|
6677 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
|
6678 |
RETURN (nil); |
|
616 | 6679 |
} |
6680 |
#endif |
|
6681 |
%}. |
|
792 | 6682 |
^ self primitiveFailed |
1247 | 6683 |
|
6684 |
"Modified: 22.4.1996 / 13:15:12 / cg" |
|
370 | 6685 |
! |
6686 |
||
616 | 6687 |
shmDetach:addr |
1247 | 6688 |
"low level entry to shmdt()-system call. |
6689 |
Not supported on all operatingSystems" |
|
6690 |
||
616 | 6691 |
%{ /* NOCONTEXT */ |
6692 |
#ifdef WANT_SHM |
|
6693 |
void *shmaddr; |
|
6694 |
int rslt; |
|
6695 |
||
6696 |
if (__isSmallInteger(addr)) { |
|
1487 | 6697 |
shmaddr = (void *) __intVal(addr); |
6698 |
||
6699 |
rslt = shmdt(shmaddr); |
|
6700 |
if (rslt != -1) { |
|
6701 |
RETURN (true); |
|
6702 |
} |
|
6703 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
|
6704 |
RETURN (false); |
|
370 | 6705 |
} |
616 | 6706 |
#endif |
6707 |
%}. |
|
792 | 6708 |
^ self primitiveFailed |
1247 | 6709 |
|
6710 |
"Modified: 22.4.1996 / 13:15:03 / cg" |
|
616 | 6711 |
! |
6712 |
||
6713 |
shmGet:key size:size flags:flags |
|
1247 | 6714 |
"low level entry to shmget()-system call. |
6715 |
This is not for public use and not supported with all operatingSystems. |
|
616 | 6716 |
- use the provided wrapper class SharedExternalBytes instead." |
6717 |
||
6718 |
%{ /* NOCONTEXT */ |
|
6719 |
#ifdef WANT_SHM |
|
6720 |
if (__bothSmallInteger(key, size) |
|
6721 |
&& __isSmallInteger(flags)) { |
|
1487 | 6722 |
int rslt; |
6723 |
||
6724 |
rslt = shmget(__intVal(key), __intVal(size), __intVal(flags)); |
|
6725 |
if (rslt != -1) { |
|
6726 |
RETURN (__MKSMALLINT(rslt)); |
|
6727 |
} |
|
6728 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
|
6729 |
RETURN (nil); |
|
616 | 6730 |
} |
6731 |
#endif |
|
370 | 6732 |
%}. |
792 | 6733 |
^ self primitiveFailed |
1247 | 6734 |
|
6735 |
"Modified: 22.4.1996 / 13:14:46 / cg" |
|
1 | 6736 |
! ! |
6737 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
6738 |
!OperatingSystem class methodsFor:'time and date'! |
1 | 6739 |
|
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6740 |
computeDatePartsOf:osTime for:aBlock |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6741 |
"compute year, month and day from the OS time, osTime |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6742 |
and evaluate the argument, a 3-arg block with these. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6743 |
Conversion is to localtime including any daylight saving adjustments." |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6744 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6745 |
|year month day osSeconds| |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6746 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6747 |
osSeconds := osTime // 1000. |
1 | 6748 |
%{ |
6749 |
struct tm *tmPtr; |
|
6750 |
long t; |
|
6751 |
||
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6752 |
t = __longIntVal(osSeconds); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6753 |
|
1 | 6754 |
tmPtr = localtime(&t); |
1135 | 6755 |
year = __MKSMALLINT(tmPtr->tm_year + 1900); |
6756 |
month = __MKSMALLINT(tmPtr->tm_mon + 1); |
|
6757 |
day = __MKSMALLINT(tmPtr->tm_mday); |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6758 |
%}. |
1 | 6759 |
aBlock value:year value:month value:day |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6760 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6761 |
" |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6762 |
OperatingSystem computeDatePartsOf:0 for:[:y :m :d | |
1885
219c3437ad01
added executeCommand with i/o redirection
Claus Gittinger <cg@exept.de>
parents:
1863
diff
changeset
|
6763 |
y printCR. m printCR. d printCR |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6764 |
] |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6765 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6766 |
! |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6767 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6768 |
computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millis:millis |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6769 |
"return the OS-dependent time for the given time and day. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6770 |
The arguments are assumed to be in localtime including |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6771 |
any daylight saving adjustings." |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6772 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6773 |
|osSeconds| |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6774 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6775 |
%{ |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6776 |
struct tm tm; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6777 |
long t; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6778 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6779 |
if (__bothSmallInteger(y, m) |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6780 |
&& __bothSmallInteger(d, h) |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6781 |
&& __bothSmallInteger(min, s)) { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6782 |
tm.tm_hour = __intVal(h); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6783 |
tm.tm_min = __intVal(min); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6784 |
tm.tm_sec = __intVal(s); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6785 |
|
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6786 |
tm.tm_year = __intVal(y) - 1900; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6787 |
tm.tm_mon = __intVal(m) - 1; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6788 |
tm.tm_mday = __intVal(d); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6789 |
tm.tm_isdst = -1; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6790 |
|
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6791 |
t = mktime(&tm); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6792 |
osSeconds = __MKUINT(t); |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6793 |
} |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6794 |
%}. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6795 |
osSeconds notNil ifTrue:[ |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6796 |
^ osSeconds * 1000 + millis |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6797 |
]. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6798 |
^ self primitiveFailed |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6799 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6800 |
" |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6801 |
OperatingSystem computeOSTimeFromYear:1970 month:1 day:1 hour:0 minute:0 seconds:0 millis:0 |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6802 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6803 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6804 |
! |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6805 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6806 |
computeTimeAndDateFrom:osTime |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6807 |
"given an OS-dependent time in osTime, return an Array |
1511
823fcfbbb741
weekDay/yearDay start with0 in tm_ struct, but
Claus Gittinger <cg@exept.de>
parents:
1510
diff
changeset
|
6808 |
containing (full-) year, month, day, hour, minute and seconds, |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6809 |
offset to UTC, daylight savings time flag, milliseconds, |
1511
823fcfbbb741
weekDay/yearDay start with0 in tm_ struct, but
Claus Gittinger <cg@exept.de>
parents:
1510
diff
changeset
|
6810 |
dayInYear (1..) and dayInWeek (1..). |
616 | 6811 |
Conversion is to localtime including any daylight saving adjustments." |
6812 |
||
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6813 |
|low hi year month day hours minutes seconds millis utcOffset |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6814 |
dst yDay wDay osSeconds ret| |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6815 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6816 |
millis := osTime \\ 1000. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6817 |
osSeconds := osTime // 1000. |
63 | 6818 |
%{ |
6819 |
struct tm *tmPtr; |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6820 |
struct tm *gmTmPtr; |
63 | 6821 |
long t; |
6822 |
||
2073 | 6823 |
#if defined(HAS_NO_TIMEZONE) |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6824 |
# define TIMEZONE tmPtr->tm_gmtoff |
811 | 6825 |
#else |
831 | 6826 |
# ifdef MSDOS_LIKE |
1487 | 6827 |
# define TIMEZONE 0 |
831 | 6828 |
# else |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6829 |
# define TIMEZONE timezone |
831 | 6830 |
# endif |
811 | 6831 |
#endif |
6832 |
||
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6833 |
t = __longIntVal(osSeconds); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6834 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6835 |
tmPtr = localtime(&t); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6836 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6837 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6838 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6839 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6840 |
year = __MKSMALLINT(tmPtr->tm_year + 1900); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6841 |
month = __MKSMALLINT(tmPtr->tm_mon + 1); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6842 |
day = __MKSMALLINT(tmPtr->tm_mday); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6843 |
|
1511
823fcfbbb741
weekDay/yearDay start with0 in tm_ struct, but
Claus Gittinger <cg@exept.de>
parents:
1510
diff
changeset
|
6844 |
yDay = __MKSMALLINT(tmPtr->tm_yday+1); |
1512
d4e6376dce78
weekDay fix (sunday is 0 in tm_wday)
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
6845 |
wDay = __MKSMALLINT(tmPtr->tm_wday == 0 ? 7 : tmPtr->tm_wday); |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6846 |
|
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6847 |
if (tmPtr->tm_isdst == 0) { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6848 |
dst = false; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6849 |
utcOffset = __MKSMALLINT(TIMEZONE); |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6850 |
} else { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6851 |
dst = true; |
800
067094efdaed
use HAS_ALTZONE / HAS_DAYLIGHT
Claus Gittinger <cg@exept.de>
parents:
798
diff
changeset
|
6852 |
#ifdef HAS_ALTZONE |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6853 |
utcOffset = __MKSMALLINT(altzone); |
800
067094efdaed
use HAS_ALTZONE / HAS_DAYLIGHT
Claus Gittinger <cg@exept.de>
parents:
798
diff
changeset
|
6854 |
#else |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6855 |
utcOffset = __MKSMALLINT(TIMEZONE) + 3600; |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6856 |
#endif |
63 | 6857 |
} |
241 | 6858 |
%}. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6859 |
"I would love to have SELF-like inline objects ..." |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6860 |
ret := Array new:11. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6861 |
ret at:1 put:year. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6862 |
ret at:2 put:month. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6863 |
ret at:3 put:day. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6864 |
ret at:4 put:hours. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6865 |
ret at:5 put:minutes. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6866 |
ret at:6 put:seconds. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6867 |
ret at:7 put:utcOffset. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6868 |
ret at:8 put:dst. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6869 |
ret at:9 put:millis. |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6870 |
ret at:10 put:yDay. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6871 |
ret at:11 put:wDay. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6872 |
^ ret |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6873 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6874 |
" |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6875 |
OperatingSystem computeTimeAndDateFrom:0 |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6876 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6877 |
! |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6878 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6879 |
computeTimePartsOf:osTime for:aBlock |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6880 |
"compute hours, minutes, seconds and milliseconds from the osTime |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6881 |
and evaluate the argument, a 4-arg block with these. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6882 |
Conversion is to localtime including any daylight saving adjustments." |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6883 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6884 |
|hours minutes seconds millis osSeconds| |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6885 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6886 |
osSeconds := osTime // 1000. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6887 |
millis := osTime \\ 1000. |
616 | 6888 |
%{ |
6889 |
struct tm *tmPtr; |
|
6890 |
long t; |
|
6891 |
||
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6892 |
t = __longIntVal(osSeconds); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6893 |
|
616 | 6894 |
tmPtr = localtime(&t); |
1135 | 6895 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
6896 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
|
6897 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6898 |
%}. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6899 |
aBlock value:hours value:minutes value:seconds value:millis |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6900 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6901 |
" |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6902 |
OperatingSystem computeTimePartsOf:100 for:[:h :m :s :milli | |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6903 |
h printCR. m printCR. s printCR. millis printCR |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6904 |
] |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6905 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6906 |
! |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6907 |
|
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6908 |
computeUTCTimeAndDateFrom:osTime |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6909 |
"given an OS-dependent time in osTime, return an Array |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6910 |
containing year, month, day, hour, minute and seconds, |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6911 |
offset to UTC, daylight savings time flag, milliseconds, |
1511
823fcfbbb741
weekDay/yearDay start with0 in tm_ struct, but
Claus Gittinger <cg@exept.de>
parents:
1510
diff
changeset
|
6912 |
dayInYear (1..) and dayInWeek (1..). |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6913 |
Conversion is to UTC." |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6914 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6915 |
|low hi year month day hours minutes seconds millis utcOffset |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6916 |
dst yDay wDay osSeconds ret| |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6917 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6918 |
millis := osTime \\ 1000. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6919 |
osSeconds := osTime // 1000. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6920 |
%{ |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6921 |
struct tm *tmPtr; |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6922 |
struct tm *gmTmPtr; |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6923 |
long t; |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6924 |
|
2073 | 6925 |
#if defined(HAS_NO_TIMEZONE) |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6926 |
# define TIMEZONE tmPtr->tm_gmtoff |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6927 |
#else |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6928 |
# ifdef MSDOS_LIKE |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6929 |
# define TIMEZONE 0 |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6930 |
# else |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6931 |
# define TIMEZONE timezone |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6932 |
# endif |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6933 |
#endif |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6934 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6935 |
t = __longIntVal(osSeconds); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6936 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6937 |
tmPtr = gmtime(&t); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6938 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6939 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6940 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6941 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6942 |
year = __MKSMALLINT(tmPtr->tm_year + 1900); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6943 |
month = __MKSMALLINT(tmPtr->tm_mon + 1); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6944 |
day = __MKSMALLINT(tmPtr->tm_mday); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6945 |
|
1511
823fcfbbb741
weekDay/yearDay start with0 in tm_ struct, but
Claus Gittinger <cg@exept.de>
parents:
1510
diff
changeset
|
6946 |
yDay = __MKSMALLINT(tmPtr->tm_yday + 1); |
1512
d4e6376dce78
weekDay fix (sunday is 0 in tm_wday)
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
6947 |
wDay = __MKSMALLINT(tmPtr->tm_wday == 0 ? 7 : tmPtr->tm_wday); |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6948 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6949 |
if (tmPtr->tm_isdst == 0) { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6950 |
dst = false; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6951 |
utcOffset = __MKSMALLINT(TIMEZONE); |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6952 |
} else { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6953 |
dst = true; |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6954 |
#ifdef HAS_ALTZONE |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6955 |
utcOffset = __MKSMALLINT(altzone); |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6956 |
#else |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6957 |
utcOffset = __MKSMALLINT(TIMEZONE) + 3600; |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6958 |
#endif |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6959 |
} |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6960 |
%}. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6961 |
"I would love to have SELF-like inline objects ..." |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6962 |
ret := Array new:11. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6963 |
ret at:1 put:year. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6964 |
ret at:2 put:month. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6965 |
ret at:3 put:day. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6966 |
ret at:4 put:hours. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6967 |
ret at:5 put:minutes. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6968 |
ret at:6 put:seconds. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6969 |
ret at:7 put:utcOffset. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6970 |
ret at:8 put:dst. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6971 |
ret at:9 put:millis. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6972 |
ret at:10 put:yDay. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6973 |
ret at:11 put:wDay. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6974 |
^ ret |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6975 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6976 |
" |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6977 |
OperatingSystem computeUTCTimeAndDateFrom:0 |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6978 |
" |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6979 |
! |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6980 |
|
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6981 |
computeUTCTimePartsOf:osTime for:aBlock |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6982 |
"compute hours, minutes, seconds and milliseconds from the osTime |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6983 |
and evaluate the argument, a 4-arg block with these. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6984 |
Conversion is to UTC." |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6985 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6986 |
|hours minutes seconds millis osSeconds| |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6987 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6988 |
osSeconds := osTime // 1000. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6989 |
millis := osTime \\ 1000. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6990 |
%{ |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6991 |
struct tm *tmPtr; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6992 |
long t; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6993 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6994 |
t = __longIntVal(osSeconds); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6995 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6996 |
tmPtr = gmtime(&t); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6997 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6998 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6999 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7000 |
%}. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7001 |
aBlock value:hours value:minutes value:seconds value:millis |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7002 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7003 |
" |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
7004 |
OperatingSystem computeUTCTimePartsOf:100 for:[:h :m :s :milli | |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7005 |
h printCR. m printCR. s printCR. milli printCR |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7006 |
] |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7007 |
" |
275 | 7008 |
! |
7009 |
||
1 | 7010 |
getMillisecondTime |
185 | 7011 |
"This returns the millisecond timers value. |
7012 |
The range is limited to 0..1fffffff (i.e. the SmallInteger range) to avoid |
|
7013 |
LargeInteger arithmetic when doing timeouts and delays. |
|
792 | 7014 |
Since this value is wrapping around in regular intervals, this can only be used for |
185 | 7015 |
short relative time deltas. |
7016 |
Use the millisecondTimeXXX:-methods to compare and add time deltas - these know about the wrap. |
|
7017 |
||
7018 |
BAD DESIGN: |
|
7019 |
This should be changed to return some instance of RelativeTime, |
|
7020 |
and these computations moved there. |
|
95 | 7021 |
|
7022 |
Dont use this method in application code since it is an internal (private) |
|
7023 |
interface. For compatibility with ST-80, use Time millisecondClockValue. |
|
7024 |
" |
|
1 | 7025 |
|
7026 |
%{ /* NOCONTEXT */ |
|
7027 |
||
7028 |
long t; |
|
185 | 7029 |
#if !defined(HAS_GETTIMEOFDAY) && defined(SYSV) && defined(HZ) |
7030 |
/* |
|
7031 |
* sys5 time |
|
7032 |
*/ |
|
1 | 7033 |
long ticks; |
7034 |
struct tms tb; |
|
7035 |
||
7036 |
ticks = times(&tb); |
|
7037 |
t = (ticks * 1000) / HZ; |
|
792 | 7038 |
#else |
1632 | 7039 |
# ifdef WIN32 |
7040 |
t = GetTickCount(); |
|
7041 |
# else |
|
7042 |
# ifdef MSDOS_LIKE |
|
792 | 7043 |
struct _timeb timebuffer; |
7044 |
||
7045 |
_ftime(&timebuffer); |
|
7046 |
t = (timebuffer.time * 1000) + timebuffer.millitm; |
|
1632 | 7047 |
# else /* assume HAS_GETTIMEOFDAY */ |
185 | 7048 |
/* |
7049 |
* bsd time |
|
7050 |
*/ |
|
1 | 7051 |
struct timeval tb; |
7052 |
struct timezone tzb; |
|
7053 |
||
7054 |
gettimeofday(&tb, &tzb); |
|
7055 |
t = tb.tv_sec*1000 + tb.tv_usec/1000; |
|
1632 | 7056 |
# endif |
792 | 7057 |
# endif |
68 | 7058 |
#endif |
1135 | 7059 |
RETURN ( __MKSMALLINT(t & 0x1FFFFFFF) ); |
1 | 7060 |
%} |
7061 |
! |
|
7062 |
||
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7063 |
getOSTime |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7064 |
"This returns the millisecond OS time. |
2000 | 7065 |
The base of the returned value is not consistent across |
7066 |
different OS's - some return the number of millis since jan, 1st 1970; |
|
7067 |
others since 1900. The Time classes are prepared for this, and |
|
7068 |
convert as appropriate. |
|
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7069 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7070 |
Dont use this method in application code since it is an internal (private) |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7071 |
interface. For compatibility with ST-80, use Time>>millisecondClockValue. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7072 |
or use instances of Time, Date or AbsoluteTime to work with. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7073 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7074 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7075 |
|seconds millis| |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7076 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7077 |
%{ |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7078 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7079 |
long t; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7080 |
#if !defined(HAS_GETTIMEOFDAY) && defined(SYSV) && defined(HZ) |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7081 |
/* |
2000 | 7082 |
* sys5 time; we have to fake the information |
7083 |
* the returned value is inexact. |
|
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7084 |
*/ |
616 | 7085 |
int now; |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7086 |
long ticks; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7087 |
struct tms tb; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7088 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7089 |
now = time(0); /* seconds since 1970 ... */ |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7090 |
seconds = __MKUINT(now); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7091 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7092 |
ticks = times(&tb); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7093 |
t = (ticks * 1000) / HZ; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7094 |
t = t % 1000; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7095 |
millis = __MKSMALLINT(t); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7096 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7097 |
#else |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7098 |
# ifdef MSDOS_LIKE |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7099 |
struct _timeb timebuffer; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7100 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7101 |
_ftime(&timebuffer); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7102 |
seconds = __MKUINT(timebuffer.time); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7103 |
millis = __MKSMALLINT(timebuffer.millitm); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7104 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7105 |
# else /* assume HAS_GETTIMEOFDAY */ |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7106 |
/* |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7107 |
* bsd time |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7108 |
*/ |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7109 |
struct timeval tb; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7110 |
struct timezone tzb; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7111 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7112 |
gettimeofday(&tb, &tzb); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7113 |
seconds = __MKUINT(tb.tv_sec); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7114 |
millis = __MKSMALLINT(tb.tv_usec / 1000); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7115 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7116 |
# endif |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7117 |
#endif |
831 | 7118 |
%}. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7119 |
^ (seconds * 1000) + millis |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7120 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7121 |
" |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
7122 |
OperatingSystem getOSTime printCR. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
7123 |
Delay waitForSeconds:0.2. |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
7124 |
OperatingSystem getOSTime printCR. |
831 | 7125 |
" |
616 | 7126 |
! |
7127 |
||
7128 |
maximumMillisecondTimeDelta |
|
7129 |
"this returns the maximum delta supported by millisecondCounter |
|
7130 |
based methods. The returned value is half the value at which the |
|
7131 |
timer wraps." |
|
7132 |
||
7133 |
%{ /* NOCONTEXT */ |
|
1135 | 7134 |
RETURN ( __MKSMALLINT(0x0FFFFFFF) ); |
616 | 7135 |
%} |
7136 |
! |
|
7137 |
||
7138 |
millisecondDelay:millis |
|
7139 |
"delay execution for millis milliseconds or until the next event |
|
7140 |
arrives. |
|
7141 |
All lower priority threads will also sleep for the duration, |
|
7142 |
interrupts (and therefore, higher prio processes) are |
|
7143 |
still handled. |
|
7144 |
Better use a Delay, to only delay the calling thread. |
|
7145 |
(however, a delay cannot be used in the event handler or scheduler)" |
|
7146 |
||
7147 |
|now then delta| |
|
7148 |
||
831 | 7149 |
%{ /* NOCONTEXT */ |
7150 |
#ifdef WIN32 |
|
7151 |
int t = __intVal(millis); |
|
7152 |
||
7153 |
if (t) { |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
7154 |
Sleep(t); |
831 | 7155 |
} |
7156 |
RETURN (self); |
|
7157 |
#endif |
|
7158 |
%}. |
|
7159 |
||
616 | 7160 |
now := OperatingSystem getMillisecondTime. |
7161 |
then := OperatingSystem millisecondTimeAdd:now and:millis. |
|
7162 |
||
7163 |
[OperatingSystem millisecondTime:then isAfter:now] whileTrue:[ |
|
7164 |
delta := OperatingSystem millisecondTimeDeltaBetween:then and:now. |
|
7165 |
self selectOnAnyReadable:nil writable:nil exception:nil withTimeOut:delta. |
|
7166 |
now := OperatingSystem getMillisecondTime. |
|
7167 |
] |
|
7168 |
||
7169 |
" |
|
7170 |
OperatingSystem millisecondDelay:2000 |
|
7171 |
" |
|
7172 |
! |
|
7173 |
||
7174 |
millisecondTime:msTime1 isAfter:msTime2 |
|
7175 |
"return true if msTime1 is after msTime2, false if not. |
|
7176 |
The two arguments are supposed to be millisecond times |
|
7177 |
(such as returned getMillisecondTime) which wrap at 16r1FFFFFFF. |
|
7178 |
||
7179 |
This should really be moved to some RelativeTime class." |
|
7180 |
||
7181 |
(msTime1 > msTime2) ifTrue:[ |
|
7182 |
((msTime1 - msTime2) >= 16r10000000) ifTrue:[ |
|
7183 |
^ false |
|
7184 |
]. |
|
7185 |
^ true |
|
7186 |
]. |
|
7187 |
((msTime2 - msTime1) > 16r10000000) ifTrue:[ |
|
7188 |
^ true |
|
7189 |
]. |
|
7190 |
^ false |
|
7191 |
! |
|
7192 |
||
7193 |
millisecondTimeAdd:msTime1 and:msTime2 |
|
7194 |
"Add two millisecond times (such as returned getMillisecondTime). |
|
7195 |
The returned value is msTime1 + msTime2 where a wrap occurs at:16r1FFFFFFF. |
|
7196 |
||
7197 |
This should really be moved to some RelativeTime class." |
|
7198 |
||
7199 |
|sum| |
|
7200 |
||
7201 |
sum := msTime1 + msTime2. |
|
7202 |
(sum > 16r1FFFFFFF) ifTrue:[^ sum - 16r20000000]. |
|
7203 |
(sum < 0) ifTrue:[^ sum + 16r20000000]. |
|
7204 |
^ sum |
|
7205 |
! |
|
7206 |
||
1 | 7207 |
millisecondTimeDeltaBetween:msTime1 and:msTime2 |
95 | 7208 |
"subtract two millisecond times (such as returned getMillisecondTime) |
185 | 7209 |
and return the difference. Since milli-times wrap (at 16r01FFFFFFF), |
95 | 7210 |
some special handling is built-in here. |
185 | 7211 |
The returned value is msTime1 - msTime2. The returned value is invalid |
7212 |
if the delta is >= 0x10000000. |
|
63 | 7213 |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
7214 |
This should really be moved to some RelativeTime class; |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
7215 |
better yet: create a subclass of Integer named LimitedRangeInteger." |
1 | 7216 |
|
7217 |
(msTime1 > msTime2) ifTrue:[ |
|
185 | 7218 |
^ msTime1 - msTime2 |
1 | 7219 |
]. |
7220 |
^ msTime1 + 16r10000000 - msTime2 |
|
95 | 7221 |
|
7222 |
" |
|
7223 |
OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:1 |
|
7224 |
OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:(16 / 3) |
|
7225 |
OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:1000 |
|
7226 |
||
7227 |
OperatingSystem millisecondTimeDeltaBetween:0 and:16r0FFFFFFF |
|
7228 |
OperatingSystem millisecondTimeDeltaBetween:(13/3) and:16r0FFFFFFF |
|
7229 |
OperatingSystem millisecondTimeDeltaBetween:999 and:16r0FFFFFFF |
|
7230 |
||
7231 |
OperatingSystem millisecondTime:0 isAfter:16r0FFFFFFF |
|
7232 |
OperatingSystem millisecondTime:(13/3) isAfter:16r0FFFFFFF |
|
7233 |
OperatingSystem millisecondTime:999 isAfter:16r0FFFFFFF |
|
7234 |
||
7235 |
OperatingSystem millisecondTime:0 isAfter:0 |
|
7236 |
OperatingSystem millisecondTime:(13/3) isAfter:0 |
|
7237 |
OperatingSystem millisecondTime:999 isAfter:0 |
|
7238 |
||
7239 |
OperatingSystem millisecondTime:1 isAfter:0 |
|
7240 |
OperatingSystem millisecondTime:(13/3) isAfter:2 |
|
7241 |
OperatingSystem millisecondTime:999 isAfter:900 |
|
7242 |
||
7243 |
|t1 t2| |
|
7244 |
||
7245 |
t1 := Time millisecondClockValue. |
|
7246 |
(Delay forMilliseconds:1) wait. |
|
7247 |
t2 := Time millisecondClockValue. |
|
7248 |
OperatingSystem millisecondTimeDeltaBetween:t2 and:t1 |
|
7249 |
" |
|
1 | 7250 |
! |
7251 |
||
7252 |
sleep:numberOfSeconds |
|
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7253 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7254 |
|
308 | 7255 |
"cease ANY action for some time. This suspends the whole smalltalk |
7256 |
(unix-) process for some time. |
|
1 | 7257 |
Not really useful since not even low-prio processes and interrupt |
95 | 7258 |
handling will run during the sleep. |
7259 |
Use either OperatingSystem>>millisecondDelay: (which makes all |
|
7260 |
threads sleep, but handles interrupts) or use a Delay (which makes |
|
7261 |
only the calling thread sleep)." |
|
1 | 7262 |
|
7263 |
%{ /* NOCONTEXT */ |
|
7264 |
||
252 | 7265 |
if (__isSmallInteger(numberOfSeconds)) { |
1135 | 7266 |
sleep(__intVal(numberOfSeconds)); |
185 | 7267 |
RETURN ( self ); |
1 | 7268 |
} |
68 | 7269 |
%}. |
7270 |
" |
|
7271 |
argument not integer |
|
7272 |
" |
|
792 | 7273 |
^ self primitiveFailed |
95 | 7274 |
|
7275 |
" |
|
7276 |
OperatingSystem sleep:2 |
|
7277 |
" |
|
10 | 7278 |
! ! |
7279 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
7280 |
!OperatingSystem class methodsFor:'users & groups'! |
616 | 7281 |
|
7282 |
getEffectiveGroupID |
|
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7283 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7284 |
|
616 | 7285 |
"return the current users (thats you) effective numeric group id. |
7286 |
This is only different from getGroupID, if you have ST/X running |
|
7287 |
as a setuid program (of which you should think about twice)." |
|
7288 |
||
7289 |
%{ /* NOCONTEXT */ |
|
7290 |
||
7291 |
#ifdef UNIX_LIKE |
|
7292 |
int uid; |
|
7293 |
||
7294 |
uid = getegid(); |
|
7295 |
RETURN ( __MKSMALLINT(uid) ); |
|
7296 |
#endif |
|
7297 |
/* --- return same as getGroupID --- */ |
|
7298 |
%}. |
|
7299 |
^ self getGroupID |
|
7300 |
||
7301 |
" |
|
7302 |
OperatingSystem getEffectiveGroupID |
|
7303 |
" |
|
7304 |
! |
|
7305 |
||
7306 |
getEffectiveUserID |
|
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7307 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7308 |
|
616 | 7309 |
"return the current users (thats you) effective numeric user id. |
7310 |
This is only different from getUserID, if you have ST/X running |
|
7311 |
as a setuid program (of which you should think about twice)." |
|
10 | 7312 |
|
7313 |
%{ /* NOCONTEXT */ |
|
7314 |
||
616 | 7315 |
#ifdef UNIX_LIKE |
7316 |
int uid; |
|
7317 |
||
7318 |
uid = geteuid(); |
|
7319 |
RETURN ( __MKSMALLINT(uid) ); |
|
7320 |
#endif |
|
7321 |
/* --- return same as getUserID --- */ |
|
7322 |
%}. |
|
7323 |
^ self getUserID |
|
7324 |
||
7325 |
" |
|
7326 |
OperatingSystem getEffectiveUserID |
|
7327 |
" |
|
7328 |
! |
|
7329 |
||
1549
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7330 |
getFullUserNameFromID:userID |
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7331 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7332 |
|
1549
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7333 |
"return a string with the users full name - if available. |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7334 |
If not, return the login name as a fallBack." |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7335 |
|
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7336 |
|info gecos| |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7337 |
|
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7338 |
info := self userInfoOf:userID. |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7339 |
(info notNil |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7340 |
and:[info includesKey:#gecos]) ifTrue:[ |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7341 |
gecos := info at:#gecos. |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7342 |
(gecos includes:$,) ifTrue:[ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7343 |
^ gecos copyTo:(gecos indexOf:$,) - 1 |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7344 |
]. |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7345 |
^ gecos |
1549
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7346 |
]. |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7347 |
^ self getUserNameFromID:userID |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7348 |
|
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7349 |
" |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7350 |
OperatingSystem getFullUserNameFromID:0 |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7351 |
OperatingSystem getFullUserNameFromID:(OperatingSystem getUserID) |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7352 |
|
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7353 |
OperatingSystem getUserNameFromID:(OperatingSystem getUserID) |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7354 |
" |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7355 |
|
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7356 |
"Modified: 15.7.1996 / 12:44:21 / cg" |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7357 |
! |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7358 |
|
616 | 7359 |
getGroupID |
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7360 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7361 |
|
616 | 7362 |
"return the current users (thats you) numeric group id" |
7363 |
||
7364 |
%{ /* NOCONTEXT */ |
|
7365 |
||
7366 |
#ifdef UNIX_LIKE |
|
7367 |
int uid; |
|
7368 |
||
7369 |
uid = getgid(); |
|
7370 |
RETURN ( __MKSMALLINT(uid) ); |
|
7371 |
#else |
|
7372 |
# ifdef SYSTEM_HAS_GROUPS |
|
7373 |
/* ... */ |
|
10 | 7374 |
# endif |
7375 |
#endif |
|
68 | 7376 |
%}. |
616 | 7377 |
^ 1 "just a dummy for systems which do not have userIDs" |
7378 |
||
68 | 7379 |
" |
616 | 7380 |
OperatingSystem getGroupID |
7381 |
" |
|
7382 |
! |
|
7383 |
||
7384 |
getGroupNameFromID:aNumber |
|
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7385 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7386 |
|
616 | 7387 |
"return the group-name-string for a given numeric group-id" |
7388 |
||
7389 |
%{ /* NOCONTEXT */ |
|
7390 |
||
7391 |
#ifdef UNIX_LIKE |
|
7392 |
struct group *g; |
|
7393 |
||
7394 |
if (__isSmallInteger(aNumber)) { |
|
1135 | 7395 |
g = getgrgid(__intVal(aNumber)); |
616 | 7396 |
if (g) { |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7397 |
RETURN ( __MKSTRING(g->gr_name) ); |
616 | 7398 |
} |
7399 |
} |
|
7400 |
#endif |
|
7401 |
%}. |
|
7402 |
^ '???' |
|
7403 |
||
7404 |
" |
|
7405 |
OperatingSystem getGroupNameFromID:0 |
|
7406 |
OperatingSystem getGroupNameFromID:10 |
|
7407 |
" |
|
7408 |
! |
|
7409 |
||
7410 |
getHomeDirectory |
|
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7411 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7412 |
|
616 | 7413 |
"return the name of the users home directory" |
7414 |
||
7415 |
^ OperatingSystem getEnvironment:'HOME' |
|
7416 |
||
7417 |
" |
|
7418 |
OperatingSystem getHomeDirectory |
|
7419 |
" |
|
7420 |
! |
|
7421 |
||
7422 |
getLoginName |
|
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7423 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7424 |
|
1549
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7425 |
"return a string with the users login name" |
616 | 7426 |
|
7427 |
%{ /* NOCONTEXT */ |
|
7428 |
static char cachedName[64]; |
|
7429 |
static firstCall = 1; |
|
7430 |
||
831 | 7431 |
char *name = (char *)0; |
616 | 7432 |
#ifdef UNIX_LIKE |
7433 |
if (firstCall) { |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7434 |
name = (char *)getlogin(); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7435 |
if (! name || (name[0] == 0)) { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7436 |
name = (char *)getenv("LOGNAME"); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7437 |
} |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7438 |
if (name && (strlen(name) < sizeof(cachedName))) { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7439 |
strcpy(cachedName, name); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7440 |
firstCall = 0; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7441 |
} |
616 | 7442 |
} else { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7443 |
name = cachedName; |
616 | 7444 |
} |
831 | 7445 |
#else |
1632 | 7446 |
# ifdef WIN32 |
831 | 7447 |
if (firstCall) { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7448 |
int nameSize = sizeof(cachedName); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7449 |
|
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7450 |
if (GetUserName(cachedName, &nameSize) == TRUE) { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7451 |
name = cachedName; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7452 |
firstCall = 0; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7453 |
} |
831 | 7454 |
} else { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7455 |
name = cachedName; |
831 | 7456 |
} |
7457 |
# endif |
|
7458 |
#endif |
|
7459 |
if (! name || (name[0] == 0) ) { |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7460 |
name = (char *)getenv("LOGNAME"); |
831 | 7461 |
} |
7462 |
if (! name || (name[0] == 0) ) { |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7463 |
name = "you"; |
831 | 7464 |
} |
7465 |
||
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7466 |
RETURN ( __MKSTRING(name) ); |
831 | 7467 |
%}. |
616 | 7468 |
" |
7469 |
OperatingSystem getLoginName |
|
7470 |
" |
|
7471 |
! |
|
7472 |
||
7473 |
getUserID |
|
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7474 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7475 |
|
616 | 7476 |
"return the current users (thats you) numeric user id" |
7477 |
||
7478 |
%{ /* NOCONTEXT */ |
|
7479 |
||
7480 |
#ifdef UNIX_LIKE |
|
7481 |
int uid; |
|
7482 |
||
7483 |
uid = getuid(); |
|
7484 |
RETURN ( __MKSMALLINT(uid) ); |
|
7485 |
#else |
|
7486 |
# ifdef SYSTEM_HAS_USERS |
|
7487 |
/* ... */ |
|
7488 |
# endif |
|
7489 |
#endif |
|
7490 |
%}. |
|
7491 |
^ 1 "just a dummy for systems which do not have userIDs" |
|
7492 |
||
7493 |
" |
|
7494 |
OperatingSystem getUserID |
|
68 | 7495 |
" |
616 | 7496 |
! |
7497 |
||
7498 |
getUserNameFromID:aNumber |
|
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7499 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7500 |
|
1549
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7501 |
"return the user-name-string for a given numeric user-id. |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7502 |
This is the login name, not the fullName." |
616 | 7503 |
|
7504 |
%{ /* NOCONTEXT */ |
|
7505 |
||
7506 |
#ifdef UNIX_LIKE |
|
7507 |
struct passwd *p; |
|
7508 |
||
7509 |
if (__isSmallInteger(aNumber)) { |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7510 |
p = getpwuid(__intVal(aNumber)); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7511 |
if (p) { |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7512 |
RETURN ( __MKSTRING(p->pw_name) ); |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7513 |
} |
616 | 7514 |
} |
7515 |
#endif |
|
7516 |
%}. |
|
7517 |
^ '? (' , aNumber printString , ')' |
|
7518 |
||
7519 |
" |
|
7520 |
OperatingSystem getUserNameFromID:0 |
|
7521 |
OperatingSystem getUserNameFromID:100 |
|
7522 |
OperatingSystem getUserNameFromID:9991 |
|
7523 |
" |
|
1 | 7524 |
! |
7525 |
||
616 | 7526 |
userInfoOf:aNameOrID |
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7527 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7528 |
|
616 | 7529 |
"return a dictionary filled with userinfo. The argument can be either |
7530 |
a string with the users name or its numeric id. |
|
7531 |
Notice, that not all systems provide (all of) this info; |
|
7532 |
DOS systems return nothing; |
|
7533 |
non-SYSV4 systems have no age/comment. |
|
7534 |
Portable applications may want to check the systemType and NOT depend |
|
7535 |
on all keys to be present in the returned dictionary. |
|
7536 |
Another notice: on some systems (SYSV4), the gecos field includes multiple |
|
7537 |
entries (i.e. not just the name), separated by commas. You may want to |
|
7538 |
extract any substring, up to the first comma to get the real life name." |
|
7539 |
||
7540 |
|info name passw uid gid age comment |
|
7541 |
gecos dir shell| |
|
7542 |
||
7543 |
%{ |
|
7544 |
#ifdef UNIX_LIKE |
|
7545 |
struct passwd *buf; |
|
7546 |
int ret; |
|
7547 |
||
7548 |
if (__isString(aNameOrID)) { |
|
7549 |
buf = getpwnam(__stringVal(aNameOrID)); |
|
7550 |
} else if (__isSmallInteger(aNameOrID)) { |
|
7551 |
buf = getpwuid(__intVal(aNameOrID)); |
|
7552 |
} else { |
|
7553 |
buf = (struct passwd *)0; |
|
7554 |
} |
|
7555 |
if (buf) { |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7556 |
name = __MKSTRING(buf->pw_name); |
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7557 |
passw = __MKSTRING(buf->pw_passwd); |
616 | 7558 |
# ifdef SYSV4 |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7559 |
age = __MKSTRING(buf->pw_age); |
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7560 |
comment = __MKSTRING(buf->pw_comment); |
616 | 7561 |
# endif |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7562 |
dir = __MKSTRING(buf->pw_dir); |
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7563 |
gecos = __MKSTRING(buf->pw_gecos); |
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
7564 |
shell = __MKSTRING(buf->pw_shell); |
616 | 7565 |
|
1135 | 7566 |
uid = __MKSMALLINT(buf->pw_uid); |
7567 |
gid = __MKSMALLINT(buf->pw_gid); |
|
616 | 7568 |
} |
7569 |
#endif |
|
7570 |
%}. |
|
7571 |
info := IdentityDictionary new. |
|
7572 |
name notNil ifTrue:[ |
|
7573 |
info at:#name put:name. |
|
7574 |
] ifFalse:[ |
|
7575 |
info at:#name put:'unknown' |
|
7576 |
]. |
|
7577 |
passw notNil ifTrue:[info at:#passwd put:passw]. |
|
7578 |
age notNil ifTrue:[info at:#age put:age]. |
|
7579 |
comment notNil ifTrue:[info at:#comment put:comment]. |
|
7580 |
gecos notNil ifTrue:[info at:#gecos put:gecos]. |
|
7581 |
shell notNil ifTrue:[info at:#shell put:shell]. |
|
7582 |
dir notNil ifTrue:[info at:#dir put:dir]. |
|
7583 |
uid notNil ifTrue:[info at:#uid put:uid]. |
|
7584 |
gid notNil ifTrue:[info at:#gid put:gid]. |
|
7585 |
^ info |
|
7586 |
||
7587 |
" |
|
7588 |
OperatingSystem userInfoOf:'root' |
|
7589 |
OperatingSystem userInfoOf:1 |
|
7590 |
OperatingSystem userInfoOf:'claus' |
|
7591 |
OperatingSystem userInfoOf:'fooBar' |
|
7592 |
OperatingSystem userInfoOf:(OperatingSystem getUserID) |
|
7593 |
" |
|
7594 |
! ! |
|
7595 |
||
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
7596 |
!OperatingSystem class methodsFor:'waiting for events'! |
616 | 7597 |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7598 |
blockingChildProcessWait |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7599 |
"return true, if childProcessWait: blocks, if no childs are ready" |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7600 |
%{ /*NOCONTEXT*/ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7601 |
#if defined(HAS_WAITPID) || defined(HAS_WAIT3) |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7602 |
RETURN(false); |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7603 |
#else |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7604 |
RETURN(true); |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7605 |
#endif |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7606 |
%} |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7607 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7608 |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7609 |
childProcessWait:blocking |
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7610 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7611 |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7612 |
"get status changes from child processes. |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7613 |
Return an OSProcessStatus or nil, if no process has terminated. |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7614 |
If blocking is true, we wait until a process changed state, |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7615 |
otherwise we return immediately." |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7616 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7617 |
|pid status code core| |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7618 |
%{ |
1597 | 7619 |
#ifdef UNIX_LIKE |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7620 |
int p; |
1653 | 7621 |
|
1597 | 7622 |
# if defined(HAS_WAITPID) |
1653 | 7623 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7624 |
int s; |
1653 | 7625 |
# define __WAIT waitpid(-1, &s, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED) |
7626 |
||
1597 | 7627 |
# else |
7628 |
# if defined(HAS_WAIT3) |
|
1653 | 7629 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7630 |
union wait s; |
1653 | 7631 |
# define __WAIT wait3(&s, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED, 0) |
7632 |
||
7633 |
# else /* neithe waitpid, nor wait3; use wait, which is blocking */ |
|
7634 |
||
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7635 |
int s; |
1653 | 7636 |
# define __WAIT wait(&s) |
7637 |
# define __BLOCKING_WAIT__ 1 |
|
1597 | 7638 |
|
1654 | 7639 |
if (blocking != true) { |
7640 |
/* |
|
7641 |
* We do not support nonBlocking waits, so signal an error |
|
7642 |
* Sorry about the goto, but with all these ifdefs ... |
|
7643 |
*/ |
|
7644 |
goto done; |
|
7645 |
} |
|
7646 |
# endif /*!HAS_WAIT3*/ |
|
7647 |
# endif /*!HAS_WAITPID*/ |
|
7648 |
||
2098
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7649 |
# if !defined(WIFEXITED) |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7650 |
# define WIFEXITED(stat) (((int)((stat)&0377))==0) |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7651 |
# define WIFSIGNALED(stat) (((int)((stat)&0377))>0&&((int)(((stat)>>8)&0377))==0) |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7652 |
# define WIFSTOPPED(stat) (((int)((stat)&0377))==0177&&((int)(((stat)>>8)&0377))!=0) |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7653 |
|
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7654 |
# define WEXITSTATUS(stat) ((int)(((stat)>>8)&0377)) |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7655 |
# define WTERMSIG(stat) (((int)((stat)&0377))&0177) |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7656 |
# define WSTOPSIG(stat) ((int)(((stat)>>8)&0377)) |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7657 |
# endif /*!WIFEXITED*/ |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7658 |
|
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7659 |
# if !defined(WCOREDUMP) |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7660 |
# define WCOREDUMP(stat) ((int)(((stat)>>8)&0200)) |
8790a0a6b214
WIFEXIT...WCOREDUMP are always needed
Claus Gittinger <cg@exept.de>
parents:
2080
diff
changeset
|
7661 |
# endif /*!WCOREDUMP*/ |
1597 | 7662 |
|
7663 |
# if __BLOCKING_WAIT__ |
|
1433 | 7664 |
__BEGIN_INTERRUPTABLE__ |
1597 | 7665 |
# endif |
1433 | 7666 |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7667 |
do { |
1487 | 7668 |
p = __WAIT; |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7669 |
} while (p == -1 && errno == EINTR); |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7670 |
|
1597 | 7671 |
# if __BLOCKING_WAIT__ |
1433 | 7672 |
__END_INTERRUPTABLE__ |
1654 | 7673 |
# undef __BLOCKING_WAIT__ |
1597 | 7674 |
# endif |
7675 |
||
7676 |
# undef __WAIT |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7677 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7678 |
if (p == 0) |
1487 | 7679 |
RETURN(nil) |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7680 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7681 |
if (p == -1) { |
1487 | 7682 |
if (errno == ECHILD) |
7683 |
RETURN(nil); |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7684 |
} else { |
1487 | 7685 |
pid = __MKSMALLINT(p); |
7686 |
if (WIFEXITED(s)) { |
|
7687 |
status = @symbol(exit); |
|
7688 |
code = __MKSMALLINT(WEXITSTATUS(s)); |
|
7689 |
core = WCOREDUMP(s) ? true : false; |
|
7690 |
} else if (WIFSIGNALED(s)) { |
|
7691 |
status = @symbol(signal); |
|
7692 |
code = __MKSMALLINT(WTERMSIG(s)); |
|
7693 |
} else if (WIFSTOPPED(s)) { |
|
7694 |
status = @symbol(stop); |
|
7695 |
code = __MKSMALLINT(WSTOPSIG(s)); |
|
7696 |
} |
|
1597 | 7697 |
# if defined(WIFCONTINUED) |
1487 | 7698 |
else if (WIFCONTINUED(s)) { |
7699 |
status = @symbol(continue); |
|
7700 |
} |
|
1597 | 7701 |
# endif |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7702 |
} |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7703 |
done: ; |
1597 | 7704 |
#endif /* UNIX_LIKE */ |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7705 |
%}. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7706 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7707 |
pid isNil ifTrue:[ |
1487 | 7708 |
^ self primitiveFailed |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7709 |
]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7710 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7711 |
^ OSProcessStatus pid:pid status:status code:code core:core |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7712 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7713 |
" |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7714 |
OperatingSystem childProcessWait:false |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7715 |
" |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7716 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7717 |
"Created: 5.1.1996 / 16:39:14 / stefan" |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7718 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7719 |
|
10 | 7720 |
readCheck:fd |
95 | 7721 |
"return true, if data is available on a filedescriptor (i.e. read |
7722 |
is possible without blocking)" |
|
10 | 7723 |
|
7724 |
(self selectOnAnyReadable:(Array with:fd) |
|
185 | 7725 |
writable:nil |
7726 |
exception:nil |
|
7727 |
withTimeOut:0) == fd |
|
7728 |
ifTrue:[^ true]. |
|
10 | 7729 |
^ false |
7730 |
! |
|
7731 |
||
616 | 7732 |
selectOn:fd1 and:fd2 withTimeOut:millis |
7733 |
"wait for any fd to become ready; timeout after t milliseconds. |
|
7734 |
A zero timeout-time will immediately return (i.e. poll). |
|
7735 |
Return fd if i/o ok, nil if timed-out or interrupted. |
|
7736 |
Obsolete: |
|
7737 |
This is a leftover method and will vanish." |
|
7738 |
||
7739 |
^ self selectOnAnyReadable:(Array with:fd1 with:fd2) |
|
7740 |
writable:(Array with:fd1 with:fd2) |
|
7741 |
exception:nil |
|
7742 |
withTimeOut:millis |
|
10 | 7743 |
! |
7744 |
||
7745 |
selectOn:fd withTimeOut:millis |
|
7746 |
"wait for aFileDesriptor to become ready; timeout after t milliseconds. |
|
1 | 7747 |
Return true, if i/o ok, false if timed-out or interrupted. |
7748 |
With 0 as timeout argument, this can be used to check for availability |
|
7749 |
of read-data. |
|
7750 |
Experimental." |
|
7751 |
||
3 | 7752 |
^ self selectOnAnyReadable:(Array with:fd) |
185 | 7753 |
writable:(Array with:fd) |
7754 |
exception:nil |
|
7755 |
withTimeOut:millis |
|
1 | 7756 |
! |
7757 |
||
616 | 7758 |
selectOnAny:fdArray withTimeOut:millis |
7759 |
"wait for any fd in fdArray (an Array of integers) to become ready; |
|
7760 |
timeout after t milliseconds. An empty set will always wait. |
|
7761 |
Return first ready fd if i/o ok, nil if timed-out or interrupted. |
|
7762 |
Experimental." |
|
7763 |
||
7764 |
^ self selectOnAnyReadable:fdArray |
|
7765 |
writable:fdArray |
|
185 | 7766 |
exception:nil |
7767 |
withTimeOut:millis |
|
1 | 7768 |
! |
7769 |
||
10 | 7770 |
selectOnAnyReadable:fdArray withTimeOut:millis |
95 | 7771 |
"wait for any fd in fdArray (an Array of integers) to become ready for |
7772 |
reading. Timeout after t milliseconds. An empty set will always wait. |
|
7773 |
A zero timeout-time will immediately return (i.e. poll). |
|
3 | 7774 |
Return first ready fd if i/o ok, nil if timed-out or interrupted. |
7775 |
Experimental." |
|
7776 |
||
7777 |
^ self selectOnAnyReadable:fdArray |
|
185 | 7778 |
writable:nil |
7779 |
exception:nil |
|
7780 |
withTimeOut:millis |
|
3 | 7781 |
! |
7782 |
||
95 | 7783 |
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray withTimeOut:millis |
7784 |
"wait for any fd in readFdArray (an Array of integers) to become ready for |
|
7785 |
reading, writeFdArray to become ready for writing, or exceptFdArray to |
|
7786 |
arrive exceptional data (i.e. out-of-band data). |
|
7787 |
Timeout after t milliseconds or, if the timeout time is 0, immediately.. |
|
7788 |
Empty fd-sets will always wait. Zero time can be used to poll file- |
|
7789 |
descriptors (i.e. to check if I/O possible without blocking). |
|
7790 |
Return first ready fd if I/O ok, nil if timed-out or interrupted." |
|
3 | 7791 |
|
1 | 7792 |
%{ |
831 | 7793 |
#ifdef MSDOS_LIKE |
7794 |
/* |
|
7795 |
* support a delay-wait only |
|
7796 |
* (i.e. fail if any filedescriptor is selected upon) |
|
7797 |
*/ |
|
7798 |
int count; |
|
7799 |
int i; |
|
7800 |
int t; |
|
7801 |
OBJ fd; |
|
7802 |
||
7803 |
if (! __isSmallInteger(millis)) { |
|
7804 |
goto fail; |
|
7805 |
} |
|
7806 |
||
7807 |
if (readFdArray != nil) { |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
7808 |
if (! __isArray(readFdArray)) { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
7809 |
goto fail; |
831 | 7810 |
} |
7811 |
count = __arraySize(readFdArray); |
|
7812 |
for (i=0; i<count;i++) { |
|
1135 | 7813 |
fd = __ArrayInstPtr(readFdArray)->a_element[i]; |
831 | 7814 |
if (fd != nil) { |
7815 |
goto fail; |
|
7816 |
} |
|
7817 |
} |
|
7818 |
} |
|
7819 |
if (writeFdArray != nil) { |
|
7820 |
if (! __isArray(writeFdArray)) { |
|
7821 |
goto fail; |
|
7822 |
} |
|
7823 |
count = __arraySize(writeFdArray); |
|
7824 |
for (i=0; i<count;i++) { |
|
1135 | 7825 |
fd = __ArrayInstPtr(writeFdArray)->a_element[i]; |
831 | 7826 |
if (fd != nil) { |
7827 |
goto fail; |
|
7828 |
} |
|
7829 |
} |
|
7830 |
} |
|
7831 |
if (exceptFdArray != nil) { |
|
7832 |
if (! __isArray(exceptFdArray)) { |
|
7833 |
goto fail; |
|
7834 |
} |
|
7835 |
count = __arraySize(exceptFdArray); |
|
7836 |
for (i=0; i<count;i++) { |
|
1135 | 7837 |
fd = __ArrayInstPtr(exceptFdArray)->a_element[i]; |
831 | 7838 |
if (fd != nil) { |
7839 |
goto fail; |
|
7840 |
} |
|
7841 |
} |
|
7842 |
} |
|
1135 | 7843 |
t = __intVal(millis); |
831 | 7844 |
if (t != 0) { |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
7845 |
/* |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
7846 |
* delay only |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
7847 |
*/ |
831 | 7848 |
Sleep(t); |
7849 |
} |
|
7850 |
RETURN (nil); |
|
7851 |
||
7852 |
#else /* not MSDOS_LIKE */ |
|
1 | 7853 |
fd_set rset, wset, eset; |
831 | 7854 |
struct timeval wt, et; |
1 | 7855 |
int t, f, maxF, i, lX, bX; |
7856 |
OBJ fd, retFd; |
|
95 | 7857 |
int ret; |
300 | 7858 |
int count; |
1 | 7859 |
|
252 | 7860 |
if (__isSmallInteger(millis)) { |
185 | 7861 |
FD_ZERO(&rset); |
7862 |
FD_ZERO(&wset); |
|
7863 |
FD_ZERO(&eset); |
|
7864 |
||
7865 |
maxF = -1; |
|
308 | 7866 |
if (readFdArray != nil) { |
300 | 7867 |
if (! __isArray(readFdArray)) { |
7868 |
goto fail; |
|
7869 |
} |
|
7870 |
count = __arraySize(readFdArray); |
|
308 | 7871 |
|
7872 |
for (i=0; i<count;i++) { |
|
1135 | 7873 |
fd = __ArrayInstPtr(readFdArray)->a_element[i]; |
308 | 7874 |
if (fd != nil) { |
1135 | 7875 |
f = __intVal(fd); |
308 | 7876 |
if ((f >= 0) && (f < FD_SETSIZE)) { |
7877 |
FD_SET(f, &rset); |
|
7878 |
if (f > maxF) maxF = f; |
|
7879 |
} |
|
185 | 7880 |
} |
7881 |
} |
|
7882 |
} |
|
300 | 7883 |
|
308 | 7884 |
if (writeFdArray != nil) { |
300 | 7885 |
if (! __isArray(writeFdArray)) { |
7886 |
goto fail; |
|
7887 |
} |
|
7888 |
count = __arraySize(writeFdArray); |
|
308 | 7889 |
for (i=0; i<count;i++) { |
1135 | 7890 |
fd = __ArrayInstPtr(writeFdArray)->a_element[i]; |
308 | 7891 |
if (fd != nil) { |
1135 | 7892 |
f = __intVal(fd); |
308 | 7893 |
if ((f >= 0) && (f < FD_SETSIZE)) { |
7894 |
FD_SET(f, &wset); |
|
7895 |
if (f > maxF) maxF = f; |
|
7896 |
} |
|
185 | 7897 |
} |
7898 |
} |
|
7899 |
} |
|
300 | 7900 |
|
308 | 7901 |
if (exceptFdArray != nil) { |
300 | 7902 |
if (! __isArray(exceptFdArray)) { |
7903 |
goto fail; |
|
7904 |
} |
|
7905 |
count = __arraySize(exceptFdArray); |
|
308 | 7906 |
for (i=0; i<count;i++) { |
1135 | 7907 |
fd = __ArrayInstPtr(exceptFdArray)->a_element[i]; |
308 | 7908 |
if (fd != nil) { |
1135 | 7909 |
f = __intVal(fd); |
308 | 7910 |
if ((f >= 0) && (f < FD_SETSIZE)) { |
7911 |
FD_SET(f, &eset); |
|
7912 |
if (f > maxF) maxF = f; |
|
7913 |
} |
|
185 | 7914 |
} |
7915 |
} |
|
7916 |
} |
|
308 | 7917 |
|
1135 | 7918 |
t = __intVal(millis); |
774
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7919 |
if (t) { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7920 |
wt.tv_sec = t / 1000; |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7921 |
wt.tv_usec = (t % 1000) * 1000; |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7922 |
} else { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7923 |
wt.tv_sec = wt.tv_usec = 0; |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7924 |
} |
185 | 7925 |
|
7926 |
/* |
|
7927 |
* make certain, that interrupt gets us out of the select |
|
7928 |
*/ |
|
362 | 7929 |
__BEGIN_INTERRUPTABLE__ |
185 | 7930 |
errno = 0; |
774
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7931 |
|
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7932 |
if (t == 0) { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7933 |
/* |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7934 |
* if there is no timeout time, we can stay here |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7935 |
* interruptable. |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7936 |
*/ |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7937 |
do { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7938 |
ret = select(maxF+1, &rset, &wset, &eset, &wt); |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7939 |
} while ((ret < 0) && (errno == EINTR)); |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7940 |
} else { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7941 |
do { |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7942 |
ret = select(maxF+1, &rset, &wset, &eset, &wt); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7943 |
/* |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7944 |
* for now: dont loop; if we did, we had to adjust the vt-timeval; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7945 |
* could otherwise stay in this loop forever ... |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7946 |
* Premature return (before the time expired) must be handled by the caller. |
774
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7947 |
* A good solution is to update the wt-timeval and redo the select. |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7948 |
*/ |
774
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7949 |
} while (0 /* (ret < 0) && (errno == EINTR) */ ); |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7950 |
} |
362 | 7951 |
__END_INTERRUPTABLE__ |
95 | 7952 |
|
185 | 7953 |
if (ret > 0) { |
7954 |
for (i=0; i <= maxF; i++) { |
|
7955 |
if (FD_ISSET(i, &rset) |
|
7956 |
|| FD_ISSET(i, &wset) |
|
7957 |
|| FD_ISSET(i, &eset)) { |
|
1135 | 7958 |
RETURN ( __MKSMALLINT(i) ); |
185 | 7959 |
} |
7960 |
} |
|
855
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
7961 |
} else { |
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
7962 |
if (ret < 0) { |
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
7963 |
if (errno != EINTR) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
7964 |
fprintf(stderr, "OS: select errno = %d\n", errno); |
1135 | 7965 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
855
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
7966 |
} |
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
7967 |
} |
185 | 7968 |
} |
308 | 7969 |
|
185 | 7970 |
/* |
2117
460b14a6db96
added a query for interrupts being blocked
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
7971 |
* return nil (means time expired or interrupted) |
185 | 7972 |
*/ |
7973 |
RETURN ( nil ); |
|
1 | 7974 |
} |
831 | 7975 |
#endif /* not MSDOS_LIKE */ |
7976 |
||
300 | 7977 |
fail: ; |
68 | 7978 |
%}. |
7979 |
" |
|
300 | 7980 |
timeout argument not integer, |
7981 |
or any fd-array nonNil and not an array |
|
792 | 7982 |
or not supported by OS |
68 | 7983 |
" |
792 | 7984 |
^ self primitiveFailed |
1 | 7985 |
! |
7986 |
||
616 | 7987 |
setBlocking:aBoolean on:fd |
1845
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7988 |
"{ Pragma: +optSpace }" |
9d7e909b61dd
some methods are compiled for space
Claus Gittinger <cg@exept.de>
parents:
1808
diff
changeset
|
7989 |
|
616 | 7990 |
"set/clear the blocking attribute - if set (which is the default) |
7991 |
a read on the fileDescriptor will block until data is available. |
|
7992 |
If cleared, a read operation will immediately return with a value of |
|
7993 |
nil." |
|
10 | 7994 |
|
7995 |
%{ /* NOCONTEXT */ |
|
7996 |
||
616 | 7997 |
int ret, flags; |
7998 |
int savInt; |
|
7999 |
||
8000 |
#if defined(F_GETFL) && defined(F_SETFL) |
|
8001 |
# if defined(FNDELAY) |
|
8002 |
if (__isSmallInteger(fd)) { |
|
1135 | 8003 |
int f = __intVal(fd); |
8004 |
||
8005 |
flags = fcntl(f, F_GETFL, 0); |
|
616 | 8006 |
if (aBoolean == true) { |
1135 | 8007 |
ret = fcntl(f, F_SETFL, flags & ~FNDELAY); |
616 | 8008 |
} else { |
1135 | 8009 |
ret = fcntl(f, F_SETFL, flags | FNDELAY); |
185 | 8010 |
} |
616 | 8011 |
if (ret >= 0) ret = flags; |
1135 | 8012 |
RETURN ( __MKSMALLINT(ret) ); |
77 | 8013 |
} |
616 | 8014 |
# endif |
77 | 8015 |
#endif |
308 | 8016 |
%}. |
77 | 8017 |
" |
616 | 8018 |
fd argument not integer |
185 | 8019 |
" |
792 | 8020 |
^ self primitiveFailed |
1 | 8021 |
! |
8022 |
||
616 | 8023 |
writeCheck:fd |
8024 |
"return true, if filedescriptor can be written without blocking" |
|
8025 |
||
8026 |
(self selectOnAnyReadable:nil |
|
8027 |
writable:(Array with:fd) |
|
8028 |
exception:nil |
|
8029 |
withTimeOut:0) == fd |
|
8030 |
ifTrue:[^ true]. |
|
8031 |
^ false |
|
1 | 8032 |
! ! |
434 | 8033 |
|
1966
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8034 |
!OperatingSystem::OSProcessStatus class methodsFor:'documentation'! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8035 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8036 |
documentation |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8037 |
" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8038 |
This is an auxillary class, that holds information about status changes of |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8039 |
operating system processes (these are no smalltalk processes!!). |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8040 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8041 |
[Instance variables:] |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8042 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8043 |
pid <Integer> OS-Process identifier |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8044 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8045 |
status <Symbol> either #exit #signal #stop #continue |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8046 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8047 |
code <Integer> either exitcode or signalnumber |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8048 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8049 |
core <Boolean> true if core has been dumped |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8050 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8051 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8052 |
[author:] |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8053 |
Stefan Vogel |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8054 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8055 |
[see also:] |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8056 |
OperatingSystem |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8057 |
" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8058 |
! ! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8059 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8060 |
!OperatingSystem::OSProcessStatus class methodsFor:'instance creation'! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8061 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8062 |
pid:pid status:status code:code core:core |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8063 |
"private interface for OperatingSystem" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8064 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8065 |
^ self new pid:pid status:status code:code core:core |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8066 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8067 |
"Created: 28.12.1995 / 14:16:14 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8068 |
"Modified: 30.4.1996 / 18:25:00 / cg" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8069 |
! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8070 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8071 |
processCreationFailure |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8072 |
"private interface for OperatingSystem" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8073 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8074 |
^ self new pid:-1 status:#failure code:-1 core:false |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8075 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8076 |
"Created: 28.12.1995 / 14:35:29 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8077 |
"Modified: 30.4.1996 / 18:25:05 / cg" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8078 |
! ! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8079 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8080 |
!OperatingSystem::OSProcessStatus methodsFor:'accessing'! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8081 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8082 |
code |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8083 |
"return the exitcode / signalNumber" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8084 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8085 |
^ code |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8086 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8087 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8088 |
"Modified: 30.4.1996 / 18:26:23 / cg" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8089 |
! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8090 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8091 |
core |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8092 |
"return true if core has been dumped, false otherwise" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8093 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8094 |
^ core == true |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8095 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8096 |
"Modified: 28.12.1995 / 14:14:38 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8097 |
! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8098 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8099 |
pid |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8100 |
"return the pid" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8101 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8102 |
^ pid |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8103 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8104 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8105 |
"Modified: 30.4.1996 / 18:26:30 / cg" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8106 |
! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8107 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8108 |
status |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8109 |
"return status as a Symbol; |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8110 |
one of #exit #signal #stop #continue" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8111 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8112 |
^ status |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8113 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8114 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8115 |
"Modified: 30.4.1996 / 18:26:54 / cg" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8116 |
! ! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8117 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8118 |
!OperatingSystem::OSProcessStatus methodsFor:'initialization'! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8119 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8120 |
pid:newPid status:newStatus code:newCode core:newCore |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8121 |
pid := newPid. |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8122 |
status := newStatus. |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8123 |
code := newCode. |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8124 |
core := newCore. |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8125 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8126 |
"Created: 28.12.1995 / 14:18:22 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8127 |
! ! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8128 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8129 |
!OperatingSystem::OSProcessStatus methodsFor:'private-OS interface'! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8130 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8131 |
code:something |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8132 |
"set the exitCode" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8133 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8134 |
code := something. |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8135 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8136 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8137 |
"Modified: 30.4.1996 / 18:25:18 / cg" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8138 |
! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8139 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8140 |
core:something |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8141 |
"set core" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8142 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8143 |
core := something. |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8144 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8145 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8146 |
! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8147 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8148 |
pid:something |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8149 |
"set pid" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8150 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8151 |
pid := something. |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8152 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8153 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8154 |
! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8155 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8156 |
status:something |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8157 |
"set status" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8158 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8159 |
status := something. |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8160 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8161 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8162 |
! ! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8163 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8164 |
!OperatingSystem::OSProcessStatus methodsFor:'queries'! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8165 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8166 |
couldNotExecute |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8167 |
"return true when a command could not be executed" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8168 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8169 |
^ status == #exit and:[code = 127]. |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8170 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8171 |
"Created: 28.12.1995 / 15:43:17 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8172 |
"Modified: 30.4.1996 / 18:27:03 / cg" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8173 |
! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8174 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8175 |
stillAlive |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8176 |
"true if process is still alive" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8177 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8178 |
^ status == #stop or:[status == #continue] |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8179 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8180 |
"Created: 28.12.1995 / 14:27:26 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8181 |
! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8182 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8183 |
success |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8184 |
"true if process terminated successfully" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8185 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8186 |
^ status == #exit and:[code = 0] |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8187 |
|
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8188 |
"Created: 28.12.1995 / 14:13:05 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8189 |
"Modified: 28.12.1995 / 14:13:41 / stefan" |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8190 |
! ! |
8b14cce1442b
Make OSProcesStatus private to OperatingSystem.
Stefan Vogel <sv@exept.de>
parents:
1885
diff
changeset
|
8191 |
|
2080
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8192 |
!OperatingSystem::FileStatusInfo class methodsFor:'instance creation'! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8193 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8194 |
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8195 |
^ self basicNew |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8196 |
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8197 |
! ! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8198 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8199 |
!OperatingSystem::FileStatusInfo methodsFor:'accessing'! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8200 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8201 |
accessed |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8202 |
"return accessed" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8203 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8204 |
^ accessed! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8205 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8206 |
gid |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8207 |
"return gid" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8208 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8209 |
^ gid! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8210 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8211 |
id |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8212 |
"return id" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8213 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8214 |
^ id! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8215 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8216 |
mode |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8217 |
"return mode" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8218 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8219 |
^ mode! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8220 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8221 |
modified |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8222 |
"return modified" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8223 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8224 |
^ modified! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8225 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8226 |
path |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8227 |
"for symbolic links only: return the path where the symbolic link points to" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8228 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8229 |
^ path |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8230 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8231 |
! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8232 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8233 |
size |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8234 |
"return size" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8235 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8236 |
^ size! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8237 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8238 |
statusChanged |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8239 |
"return statusChanged" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8240 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8241 |
^ statusChanged! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8242 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8243 |
type |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8244 |
"return type" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8245 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8246 |
^ type! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8247 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8248 |
uid |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8249 |
"return uid" |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8250 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8251 |
^ uid! ! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8252 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8253 |
!OperatingSystem::FileStatusInfo methodsFor:'backward compatibility'! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8254 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8255 |
at:key |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8256 |
"backward compatibility access: in previous releases, IdentityDictionaries |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8257 |
were used to hold my information. Allow access via key messages. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8258 |
This method will vanish - use the proper access protocol." |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8259 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8260 |
^ self perform:key |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8261 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8262 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8263 |
! ! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8264 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8265 |
!OperatingSystem::FileStatusInfo methodsFor:'private accessing'! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8266 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8267 |
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8268 |
type := t. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8269 |
mode := m. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8270 |
uid := u. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8271 |
gid := g. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8272 |
size := s. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8273 |
id := i. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8274 |
accessed := aT. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8275 |
modified := mT. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8276 |
statusChanged := sT. |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8277 |
path := lP |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8278 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8279 |
|
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8280 |
! ! |
d93d4af439d7
Use #executeCommand:onError: to implement #executeCommand:.
Stefan Vogel <sv@exept.de>
parents:
2073
diff
changeset
|
8281 |
|
1799
0a2c5890f4f3
handle 'foo///' in directoryName
Claus Gittinger <cg@exept.de>
parents:
1702
diff
changeset
|
8282 |
!OperatingSystem class methodsFor:'documentation'! |
630 | 8283 |
|
8284 |
version |
|
2126 | 8285 |
^ '$Header: /cvs/stx/stx/libbasic/Attic/Unix.st,v 1.188 1997-01-10 15:23:40 cg Exp $' |
630 | 8286 |
! ! |
616 | 8287 |
OperatingSystem initialize! |