author | Claus Gittinger <cg@exept.de> |
Tue, 25 Jun 1996 21:39:33 +0200 | |
changeset 1487 | 349bf72ca044 |
parent 1470 | 266520246a88 |
child 1497 | 92f5370f3942 |
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 |
||
13 |
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
|
14 |
instanceVariableNames:'' |
90a518c71a7f
recursiveRemoveDirectory does not print garbage to stderr any longer; computeDateAndTimeFrom: now returns the utcOffset
Stefan Vogel <sv@exept.de>
parents:
792
diff
changeset
|
15 |
classVariableNames:'HostName DomainName LastErrorNumber LastExecStatus OSSignals |
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
756
diff
changeset
|
16 |
SlowFork ForkFailed ErrorSignal AccessDeniedErrorSignal |
1034 | 17 |
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
|
18 |
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
|
19 |
category:'System-Support' |
1 | 20 |
! |
21 |
||
437 | 22 |
!OperatingSystem primitiveDefinitions! |
406 | 23 |
%{ |
792 | 24 |
#define UNIX_LIKE |
25 |
||
831 | 26 |
#if defined(MSWINDOWS) || defined(OS2) || defined(MSDOS) || defined(WIN32) |
792 | 27 |
# ifndef MSDOS_LIKE |
28 |
# define MSDOS_LIKE |
|
29 |
# endif |
|
30 |
# undef UNIX_LIKE |
|
831 | 31 |
# ifdef i386 |
32 |
# define _X86_ |
|
33 |
# endif |
|
792 | 34 |
#endif |
35 |
||
36 |
#if defined(transputer) |
|
37 |
# undef MSDOS_LIKE |
|
38 |
# undef UNIX_LIKE |
|
39 |
#endif |
|
40 |
||
443 | 41 |
#if defined(_AIX) |
439 | 42 |
# ifndef WANT_REALPATH |
43 |
# define WANT_REALPATH |
|
44 |
# endif |
|
513
0347f6d11d76
interruptable system() on AIX
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
45 |
# ifndef WANT_SYSTEM |
0347f6d11d76
interruptable system() on AIX
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
46 |
# define WANT_SYSTEM |
0347f6d11d76
interruptable system() on AIX
Claus Gittinger <cg@exept.de>
parents:
512
diff
changeset
|
47 |
# endif |
406 | 48 |
#endif |
49 |
||
433 | 50 |
#ifdef LINUX |
1142 | 51 |
/* use inline string macros */ |
52 |
# define __STRINGDEFS__ |
|
53 |
# include <linuxIntern.h> |
|
54 |
||
439 | 55 |
# ifndef WANT_SYSTEM |
56 |
# define WANT_SYSTEM |
|
57 |
# endif |
|
443 | 58 |
# define WANT_SHM |
433 | 59 |
#endif |
60 |
||
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
61 |
#ifdef IRIX5 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
62 |
# define WANT_SYSTEM |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
63 |
#endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
64 |
|
514
81fa80a953e2
system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents:
513
diff
changeset
|
65 |
#ifdef ultrix |
81fa80a953e2
system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents:
513
diff
changeset
|
66 |
# define WANT_SYSTEM |
81fa80a953e2
system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents:
513
diff
changeset
|
67 |
#endif |
81fa80a953e2
system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents:
513
diff
changeset
|
68 |
|
515
43d76695a662
interruptable system() on hpux
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
69 |
#ifdef hpux |
43d76695a662
interruptable system() on hpux
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
70 |
# define WANT_SYSTEM |
43d76695a662
interruptable system() on hpux
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
71 |
#endif |
43d76695a662
interruptable system() on hpux
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
72 |
|
805 | 73 |
#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
|
74 |
# 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
|
75 |
#endif |
9620f7dc79d2
interruptable system() on unixware - should now move WANT_SYSTEM into xxxIntern files
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
76 |
|
831 | 77 |
/* |
78 |
* notice: although many systems' include files |
|
79 |
* already block against multiple inclusion, some |
|
80 |
* do not. Therefore, this is done here again. |
|
81 |
* (it does not hurt) |
|
82 |
*/ |
|
83 |
||
439 | 84 |
#ifdef WANT_REALPATH |
831 | 85 |
|
439 | 86 |
# include <sys/param.h> |
87 |
# define _SYS_PARAM_H_INCLUDED_ |
|
88 |
||
89 |
# include <errno.h> |
|
90 |
# define _ERRNO_H_INCLUDED_ |
|
91 |
||
92 |
# include <sys/stat.h> |
|
93 |
# define _SYS_STAT_H_INCLUDED_ |
|
443 | 94 |
|
439 | 95 |
#endif /* WANT_REALPATH */ |
96 |
||
831 | 97 |
|
98 |
||
434 | 99 |
#ifdef WANT_SHM |
443 | 100 |
extern int shmctl(), shmget(), shmdt(); |
101 |
extern char * shmat(); |
|
102 |
||
434 | 103 |
# include <sys/types.h> |
437 | 104 |
# define _SYS_TYPES_H_INCLUDED_ |
439 | 105 |
|
434 | 106 |
# include <sys/ipc.h> |
437 | 107 |
# define _SYS_IPC_H_INCLUDED_ |
439 | 108 |
|
434 | 109 |
# include <sys/shm.h> |
437 | 110 |
# define _SYS_SHM_H_INCLUDED_ |
831 | 111 |
|
439 | 112 |
#endif /* WANT_SHM */ |
434 | 113 |
|
831 | 114 |
|
434 | 115 |
#ifdef IRIX5 |
116 |
# include <sys/syssgi.h> |
|
117 |
#endif |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
118 |
|
831 | 119 |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
120 |
#ifdef transputer |
831 | 121 |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
122 |
# define unlink(f) ((remove(f) == 0) ? 0 : -1) |
831 | 123 |
|
124 |
#else /* not transputer */ |
|
125 |
||
126 |
# ifndef _SIGNAL_H_INCLUDED_ |
|
127 |
# include <signal.h> |
|
128 |
# define _SIGNAL_H_INCLUDED_ |
|
129 |
# endif |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
130 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
131 |
# ifdef SYSV |
831 | 132 |
# ifndef _SYS_TYPES_H_INCLUDED_ |
133 |
# include <sys/types.h> |
|
134 |
# define _SYS_TYPES_H_INCLUDED_ |
|
135 |
# endif |
|
136 |
# ifndef _SYS_PARAM_H_INCLUDED_ |
|
137 |
# include <sys/param.h> |
|
138 |
# define _SYS_PARAM_H_INCLUDED_ |
|
139 |
# endif |
|
140 |
# ifndef _SYS_TIMES_H_INCLUDED_ |
|
141 |
# include <sys/times.h> |
|
142 |
# define _SYS_TIMES_H_INCLUDED_ |
|
143 |
# endif |
|
144 |
# ifndef _SYS_FILE_H_INCLUDED_ |
|
145 |
# include <sys/file.h> |
|
146 |
# define _SYS_FILE_H_INCLUDED_ |
|
147 |
# endif |
|
148 |
||
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
149 |
# if ! defined(sco3_2) |
831 | 150 |
# ifndef _UNISTD_H_INCLUDED_ |
151 |
# include <unistd.h> |
|
152 |
# define _UNISTD_H_INCLUDED_ |
|
153 |
# endif |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
154 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
155 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
156 |
# if defined(isc3_2) || defined(sco3_2) |
831 | 157 |
# ifndef _SYS_TIME_H_INCLUDED_ |
158 |
# include <sys/time.h> |
|
159 |
# define _SYS_TIME_H_INCLUDED_ |
|
160 |
# endif |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
161 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
162 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
163 |
# if !defined(isc3_2) |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
164 |
# if defined(PCS) && defined(mips) |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
165 |
# include "/usr/include/bsd/sys/time.h" |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
166 |
# include "/usr/include/sys/time.h" |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
167 |
# else |
831 | 168 |
# ifndef _TIME_H_INCLUDED_ |
169 |
# include <time.h> |
|
170 |
# define _TIME_H_INCLUDED_ |
|
171 |
# endif |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
172 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
173 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
174 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
175 |
# if defined(isc3_2) |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
176 |
# include <sys/bsdtypes.h> |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
177 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
178 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
179 |
# else /* not SYSV */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
180 |
|
802 | 181 |
# ifdef MSDOS_LIKE |
831 | 182 |
|
183 |
# ifndef _SYS_TYPES_H_INCLUDED_ |
|
184 |
# include <sys/types.h> |
|
185 |
# define _SYS_TYPES_H_INCLUDED_ |
|
186 |
# endif |
|
187 |
# ifndef _TIME_H_INCLUDED_ |
|
188 |
# include <time.h> |
|
189 |
# define _TIME_H_INCLUDED_ |
|
190 |
# endif |
|
191 |
# ifndef _SYS_TIMEB_H_INCLUDED_ |
|
192 |
# include <sys/timeb.h> |
|
193 |
# define _SYS_TIMEB_H_INCLUDED_ |
|
194 |
# endif |
|
195 |
||
196 |
# else /* not MSDOS_like */ |
|
197 |
||
198 |
# ifndef _SYS_TIME_H_INCLUDED_ |
|
199 |
# include <sys/time.h> |
|
200 |
# define _SYS_TIME_H_INCLUDED_ |
|
201 |
# endif |
|
202 |
# ifndef _SYS_TYPES_H_INCLUDED_ |
|
203 |
# include <sys/types.h> |
|
204 |
# define _SYS_TYPES_H_INCLUDED_ |
|
205 |
# endif |
|
206 |
||
207 |
# endif /* not MSDOS */ |
|
792 | 208 |
# endif /* not SYSV */ |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
209 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
210 |
# ifdef aix |
831 | 211 |
|
212 |
# ifndef _TIME_H_INCLUDED_ |
|
213 |
# include <time.h> |
|
914
d00401a9450e
Fix syntax error (#defined -> #define).
Stefan Vogel <sv@exept.de>
parents:
855
diff
changeset
|
214 |
# define _TIME_H_INCLUDED_ |
831 | 215 |
# endif |
216 |
# ifndef _SYS_SELECT_H_INCLUDED_ |
|
217 |
# include <sys/select.h> |
|
218 |
# define _SYS_SELECT_H_INCLUDED_ |
|
219 |
# endif |
|
220 |
||
792 | 221 |
# endif /* aix */ |
222 |
||
223 |
# ifndef MSDOS_LIKE |
|
224 |
# include <pwd.h> |
|
225 |
# include <grp.h> |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
226 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
227 |
|
831 | 228 |
# ifndef _SYS_STAT_H_INCLUDED_ |
229 |
# include <sys/stat.h> |
|
230 |
# endif |
|
231 |
||
232 |
# ifndef _ERRNO_H_INCLUDED_ |
|
233 |
# include <errno.h> |
|
234 |
# define _ERRNO_H_INCLUDED_ |
|
235 |
# endif |
|
236 |
||
237 |
# ifndef _STDIO_H_INCLUDED_ |
|
238 |
# include <stdio.h> |
|
239 |
# define _STDIO_H_INCLUDED_ |
|
240 |
# endif |
|
241 |
||
242 |
# ifndef _FCNTL_H_INCLUDED_ |
|
243 |
# include <fcntl.h> |
|
244 |
# define _FCNTL_H_INCLUDED_ |
|
245 |
# endif |
|
246 |
||
247 |
# ifdef WIN32 |
|
248 |
# undef INT |
|
249 |
# undef Array |
|
250 |
# undef Number |
|
251 |
# undef Method |
|
252 |
# undef Point |
|
1487 | 253 |
# undef Rectangle |
831 | 254 |
|
255 |
/* # include <windows.h> /* */ |
|
256 |
# include <stdarg.h> /* */ |
|
257 |
# include <windef.h> /* */ |
|
258 |
# include <winbase.h> /* */ |
|
259 |
# include <wingdi.h> /* */ |
|
260 |
# include <winuser.h> /* */ |
|
261 |
||
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
262 |
# ifdef __DEF_Array |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
263 |
# define Array __DEF_Array |
831 | 264 |
# endif |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
265 |
# ifdef __DEF_Number |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
266 |
# define Number __DEF_Number |
831 | 267 |
# endif |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
268 |
# ifdef __DEF_Method |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
269 |
# define Method __DEF_Method |
831 | 270 |
# endif |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
271 |
# ifdef __DEF_Point |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
272 |
# define Point __DEF_Point |
831 | 273 |
# endif |
1487 | 274 |
|
275 |
# define stat _stat |
|
276 |
||
831 | 277 |
# endif |
278 |
||
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
279 |
|
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
280 |
# if defined(LINUX) |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
281 |
# define HAS_LOCALECONV |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
282 |
# endif |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
283 |
|
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
284 |
# if defined (HAS_LOCALECONV) |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
285 |
# ifndef _LOCALE_H_INCLUDED_ |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
286 |
# include <locale.h> |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
287 |
# define _LOCALE_H_INCLUDED_ |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
288 |
# endif |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
289 |
# endif |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
290 |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
291 |
/* |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
292 |
* posix systems should define these ... |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
293 |
* but on some (older) systems, they are not. |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
294 |
*/ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
295 |
# ifndef S_IXUSR |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
296 |
# ifdef S_IEXEC |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
297 |
# define S_IXUSR S_IEXEC |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
298 |
# define S_IXGRP (S_IEXEC>>3) |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
299 |
# define S_IXOTH (S_IEXEC>>6) |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
300 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
301 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
302 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
303 |
# ifndef S_IXUSR |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
304 |
# define S_IXUSR 0100 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
305 |
# define S_IXGRP 0010 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
306 |
# define S_IXOTH 0001 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
307 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
308 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
309 |
# ifndef S_IRUSR |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
310 |
# define S_IRUSR 0400 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
311 |
# define S_IRGRP 0040 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
312 |
# define S_IROTH 0004 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
313 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
314 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
315 |
# ifndef S_IWUSR |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
316 |
# define S_IWUSR 0200 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
317 |
# define S_IWGRP 0020 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
318 |
# define S_IWOTH 0002 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
319 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
320 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
321 |
# ifndef MAXPATHLEN |
792 | 322 |
# ifndef MSDOS_LIKE |
323 |
# include <sys/param.h> |
|
324 |
# endif |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
325 |
# ifndef MAXPATHLEN |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
326 |
# ifdef FILENAME_MAX /* i.e. MSDOS_LIKE */ |
792 | 327 |
# define MAXPATHLEN FILENAME_MAX |
328 |
# else |
|
329 |
# define MAXPATHLEN 1024 |
|
330 |
# endif |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
331 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
332 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
333 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
334 |
# if defined(HAS_UNAME) |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
335 |
# include <sys/utsname.h> |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
336 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
337 |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
338 |
# if defined(SYSV4) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
339 |
# include <stropts.h> |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
340 |
# endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
341 |
|
763
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
342 |
/* |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
343 |
* 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
|
344 |
*/ |
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
345 |
# ifndef SA_RESTART |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
346 |
# 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
|
347 |
# endif |
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
348 |
# ifndef SA_SIGINFO |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
349 |
# 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
|
350 |
# endif |
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
351 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
352 |
# 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
|
353 |
# include <sys/wait.h> |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
354 |
# endif |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
355 |
|
1433 | 356 |
# if defined(HAS_SYSINFO) |
357 |
# include <sys/systeminfo.h> |
|
358 |
# endif |
|
359 |
||
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
360 |
#endif /* ! transputer */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
361 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
362 |
/* |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
363 |
* 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
|
364 |
*/ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
365 |
#ifndef errno |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
366 |
extern errno; |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
367 |
#endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
368 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
369 |
/* |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
370 |
* some (old ?) systems do not define this ... |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
371 |
*/ |
675 | 372 |
#if !defined(R_OK) && !defined(_AIX) |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
373 |
# define R_OK 4 /* Test for Read permission */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
374 |
# define W_OK 2 /* Test for Write permission */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
375 |
# define X_OK 1 /* Test for eXecute permission */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
376 |
# define F_OK 0 /* Test for existence of File */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
377 |
#endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
378 |
|
832 | 379 |
#ifdef WIN32 |
380 |
# define SIGHANDLER_ARG int |
|
381 |
#else |
|
382 |
# define SIGHANDLER_ARG |
|
383 |
#endif |
|
384 |
||
1441 | 385 |
#ifdef sunos |
386 |
# define NO_WAITPID |
|
387 |
#endif |
|
388 |
||
437 | 389 |
%} |
390 |
! ! |
|
391 |
||
392 |
!OperatingSystem primitiveFunctions! |
|
393 |
%{ |
|
394 |
||
395 |
/* |
|
396 |
* some systems' system() is broken in that it does not correctly |
|
397 |
* handle EINTR and returns failure even though it actually succeeded. |
|
398 |
* (LINUX is one of them) |
|
399 |
* Here is a fixed version. If you encounter EINTR returns from |
|
400 |
* OperatingSystem>>executeCommand, you ought to define WANT_SYSTEM |
|
401 |
* in the xxxIntern.h file to get this fixed version. |
|
402 |
* |
|
403 |
* As an added BONUS, this system() enables interrupts while waiting |
|
404 |
* 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
|
405 |
* (i.e. it is RT safe) |
437 | 406 |
*/ |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
407 |
|
433 | 408 |
#if defined(WANT_SYSTEM) |
409 |
||
434 | 410 |
/* # define DPRINTF(x) printf x */ |
411 |
# define DPRINTF(x) /* nothing */ |
|
433 | 412 |
|
437 | 413 |
# ifndef _STDDEF_H_INCLUDED_ |
414 |
# include <stddef.h> |
|
415 |
# define _STDDEF_H_INCLUDED_ |
|
416 |
# endif |
|
417 |
||
418 |
# ifndef _STDLIB_H_INCLUDED_ |
|
419 |
# include <stdlib.h> |
|
420 |
# define _STDLIB_H_INCLUDED_ |
|
421 |
# endif |
|
422 |
||
423 |
# ifndef _UNISTD_H_INCLUDED_ |
|
424 |
# include <unistd.h> |
|
425 |
# define _UNISTD_H_INCLUDED_ |
|
426 |
# endif |
|
427 |
||
428 |
# ifndef _SYS_WAIT_H_INCLUDED |
|
429 |
# include <sys/wait.h> |
|
430 |
# define _SYS_WAIT_H_INCLUDED |
|
431 |
# endif |
|
432 |
||
433 |
# ifndef _SIGNAL_H_INCLUDED_ |
|
434 |
# include <signal.h> |
|
435 |
# define _SIGNAL_H_INCLUDED_ |
|
436 |
# endif |
|
437 |
||
438 |
# ifndef _SYS_TYPES_H_INCLUDED_ |
|
439 |
# include <sys/types.h> |
|
440 |
# define _SYS_TYPES_H_INCLUDED_ |
|
441 |
# endif |
|
433 | 442 |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
443 |
# if (!defined(HAVE_GNU_LD) && !defined (__ELF__)) || !defined(LINUX) |
433 | 444 |
# define __environ environ |
512 | 445 |
# if !defined(LINUX) |
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
446 |
# define __sigemptyset sigemptyset |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
447 |
# define __sigaction sigaction |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
448 |
# define __sigaddset sigaddset |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
449 |
# define __sigprocmask sigprocmask |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
450 |
# define __execve execve |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
451 |
# define __wait wait |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
452 |
# define __waitpid waitpid |
674 | 453 |
# if defined(HAS_VFORK) |
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
454 |
# define FORK vfork |
514
81fa80a953e2
system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents:
513
diff
changeset
|
455 |
# else |
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
456 |
# define FORK fork |
514
81fa80a953e2
system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents:
513
diff
changeset
|
457 |
# endif |
512 | 458 |
# endif /* ! LINUX */ |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
459 |
extern char **environ; |
433 | 460 |
# endif |
461 |
||
462 |
# define SHELL_PATH "/bin/sh" /* Path of the shell. */ |
|
463 |
# define SHELL_NAME "sh" /* Name to give it. */ |
|
464 |
||
465 |
# ifndef FORK |
|
466 |
# define FORK __fork |
|
467 |
# endif |
|
468 |
||
469 |
# ifndef CONST |
|
470 |
# ifdef __GNUC__ |
|
471 |
# define CONST const |
|
472 |
# else |
|
473 |
# define CONST /* nothing */ |
|
474 |
# endif |
|
475 |
# endif |
|
476 |
||
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
477 |
static int |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
478 |
mySystem(line) |
433 | 479 |
register CONST char *line; |
480 |
{ |
|
481 |
int status, save; |
|
482 |
pid_t pid; |
|
483 |
struct sigaction sa, intr, quit; |
|
484 |
sigset_t block, omask; |
|
485 |
||
486 |
if (line == NULL) |
|
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
487 |
return -1; |
433 | 488 |
|
489 |
sa.sa_handler = SIG_IGN; |
|
490 |
sa.sa_flags = 0; |
|
491 |
__sigemptyset (&sa.sa_mask); |
|
492 |
||
493 |
if (__sigaction (SIGINT, &sa, &intr) < 0) { |
|
494 |
DPRINTF(("1: errno=%d\n", errno)); |
|
495 |
return -1; |
|
496 |
} |
|
497 |
if (__sigaction (SIGQUIT, &sa, &quit) < 0) { |
|
498 |
save = errno; |
|
499 |
(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL); |
|
500 |
errno = save; |
|
501 |
DPRINTF(("2: errno=%d\n", errno)); |
|
502 |
return -1; |
|
503 |
} |
|
504 |
||
505 |
__sigemptyset (&block); |
|
506 |
__sigaddset (&block, SIGCHLD); |
|
507 |
save = errno; |
|
508 |
if (__sigprocmask(SIG_BLOCK, &block, &omask) < 0) { |
|
509 |
if (errno == ENOSYS) |
|
510 |
errno = save; |
|
511 |
else { |
|
512 |
save = errno; |
|
513 |
(void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL); |
|
514 |
(void) __sigaction(SIGQUIT, &quit, (struct sigaction *) NULL); |
|
515 |
errno = save; |
|
516 |
DPRINTF(("3: errno=%d\n", errno)); |
|
517 |
return -1; |
|
518 |
} |
|
519 |
} |
|
520 |
||
521 |
pid = FORK (); |
|
522 |
if (pid == (pid_t) 0) { |
|
523 |
/* Child side. */ |
|
524 |
CONST char *new_argv[4]; |
|
525 |
new_argv[0] = SHELL_NAME; |
|
526 |
new_argv[1] = "-c"; |
|
527 |
new_argv[2] = line; |
|
528 |
new_argv[3] = NULL; |
|
529 |
||
530 |
/* Restore the signals. */ |
|
531 |
(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL); |
|
532 |
(void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL); |
|
533 |
(void) __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL); |
|
534 |
||
535 |
/* Exec the shell. */ |
|
536 |
(void) __execve (SHELL_PATH, (char *CONST *) new_argv, __environ); |
|
537 |
_exit (127); |
|
538 |
} else { |
|
539 |
if (pid < (pid_t) 0) { |
|
540 |
/* The fork failed. */ |
|
541 |
DPRINTF(("4: errno=%d\n", errno)); |
|
542 |
status = -1; |
|
543 |
} else { |
|
544 |
/* Parent side. */ |
|
545 |
#ifdef NO_WAITPID |
|
546 |
pid_t child; |
|
547 |
||
548 |
do { |
|
805 | 549 |
__BEGIN_INTERRUPTABLE__ |
433 | 550 |
child = __wait (&status); |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
551 |
__END_INTERRUPTABLE__ |
805 | 552 |
if (child < 0 && errno != EINTR) { |
433 | 553 |
DPRINTF(("5: errno=%d\n", errno)); |
554 |
status = -1; |
|
555 |
break; |
|
556 |
} |
|
557 |
} while (child != pid); |
|
558 |
#else |
|
559 |
pid_t child; |
|
560 |
||
561 |
/* claus: the original did not care for EINTR here ... */ |
|
562 |
do { |
|
805 | 563 |
__BEGIN_INTERRUPTABLE__ |
433 | 564 |
child = __waitpid (pid, &status, 0); |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
565 |
__END_INTERRUPTABLE__ |
433 | 566 |
} while ((child != pid) && (errno == EINTR)); |
567 |
if (child != pid) { |
|
568 |
DPRINTF(("6: errno=%d\n", errno)); |
|
569 |
status = -1; |
|
570 |
} |
|
571 |
#endif /* NO_WAITPID */ |
|
572 |
} |
|
573 |
} |
|
574 |
save = errno; |
|
575 |
if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL) |
|
576 |
| __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL) |
|
577 |
| __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)) != 0) { |
|
578 |
if (errno == ENOSYS) { |
|
579 |
errno = save; |
|
580 |
} else { |
|
581 |
status = -1; |
|
582 |
DPRINTF(("7: errno=%d\n", errno)); |
|
583 |
} |
|
584 |
} |
|
585 |
||
586 |
return status; |
|
587 |
} |
|
1441 | 588 |
#else |
1487 | 589 |
# define __wait wait |
433 | 590 |
#endif /* WANT_SYSTEM */ |
591 |
||
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
592 |
|
433 | 593 |
/* |
594 |
* some systems do not have realpath(); |
|
595 |
* the alternative of reading from a 'pwp'-pipe |
|
596 |
* is way too slow. Here is a realpath for the rest of us. |
|
440 | 597 |
* define WANT_REALPATH in the xxxIntern-file to get it. |
433 | 598 |
*/ |
443 | 599 |
|
440 | 600 |
#if defined(HAS_REALPATH) |
601 |
# undef WANT_REALPATH |
|
602 |
#endif |
|
603 |
#if !defined(HAS_GETWD) && !defined(HAS_GETCWD) |
|
604 |
# undef WANT_REALPATH |
|
605 |
#endif |
|
606 |
||
607 |
#if defined(WANT_REALPATH) |
|
406 | 608 |
|
609 |
# ifndef NULL |
|
610 |
# define NULL (char *)0 |
|
611 |
# endif |
|
612 |
||
439 | 613 |
# define MAX_READLINKS 32 |
614 |
||
615 |
# ifndef MAXPATHLEN |
|
616 |
# define MAXPATHLEN 1024 |
|
617 |
# endif |
|
406 | 618 |
|
619 |
static |
|
620 |
char *realpath(path, resolved_path) |
|
621 |
char *path; |
|
622 |
char resolved_path []; |
|
623 |
{ |
|
624 |
char copy_path[MAXPATHLEN]; |
|
625 |
char link_path[MAXPATHLEN]; |
|
626 |
char *new_path = resolved_path; |
|
627 |
char *max_path; |
|
628 |
int readlinks = 0; |
|
629 |
int n; |
|
630 |
||
631 |
/* Make a copy of the source path since we may need to modify it. */ |
|
632 |
strcpy(copy_path, path); |
|
633 |
path = copy_path; |
|
634 |
max_path = copy_path + MAXPATHLEN - 2; |
|
635 |
/* If it's a relative pathname use getwd for starters. */ |
|
636 |
if (*path != '/') { |
|
637 |
#ifdef HAS_GETCWD |
|
638 |
getcwd(new_path, MAXPATHLEN - 1); |
|
639 |
#else |
|
640 |
getwd(new_path); |
|
641 |
#endif |
|
642 |
new_path += strlen(new_path); |
|
643 |
if (new_path[-1] != '/') |
|
644 |
*new_path++ = '/'; |
|
645 |
} |
|
646 |
else { |
|
647 |
*new_path++ = '/'; |
|
648 |
path++; |
|
649 |
} |
|
650 |
/* Expand each slash-separated pathname component. */ |
|
651 |
while (*path != '\0') { |
|
652 |
/* Ignore stray "/". */ |
|
653 |
if (*path == '/') { |
|
654 |
path++; |
|
655 |
continue; |
|
656 |
} |
|
657 |
if (*path == '.') { |
|
658 |
/* Ignore ".". */ |
|
659 |
if (path[1] == '\0' || path[1] == '/') { |
|
660 |
path++; |
|
661 |
continue; |
|
662 |
} |
|
663 |
if (path[1] == '.') { |
|
664 |
if (path[2] == '\0' || path[2] == '/') { |
|
665 |
path += 2; |
|
666 |
/* Ignore ".." at root. */ |
|
667 |
if (new_path == resolved_path + 1) |
|
668 |
continue; |
|
669 |
/* Handle ".." by backing up. */ |
|
670 |
while ((--new_path)[-1] != '/') |
|
671 |
; |
|
672 |
continue; |
|
673 |
} |
|
674 |
} |
|
675 |
} |
|
676 |
/* Safely copy the next pathname component. */ |
|
677 |
while (*path != '\0' && *path != '/') { |
|
678 |
if (path > max_path) { |
|
679 |
errno = ENAMETOOLONG; |
|
680 |
return NULL; |
|
681 |
} |
|
682 |
*new_path++ = *path++; |
|
683 |
} |
|
684 |
#ifdef S_IFLNK |
|
685 |
/* Protect against infinite loops. */ |
|
686 |
if (readlinks++ > MAX_READLINKS) { |
|
687 |
errno = ELOOP; |
|
688 |
return NULL; |
|
689 |
} |
|
690 |
/* See if latest pathname component is a symlink. */ |
|
691 |
*new_path = '\0'; |
|
692 |
n = readlink(resolved_path, link_path, MAXPATHLEN - 1); |
|
693 |
if (n < 0) { |
|
694 |
/* EINVAL means the file exists but isn't a symlink. */ |
|
695 |
if (errno != EINVAL) |
|
696 |
return NULL; |
|
697 |
} |
|
698 |
else { |
|
699 |
/* Note: readlink doesn't add the null byte. */ |
|
700 |
link_path[n] = '\0'; |
|
701 |
if (*link_path == '/') |
|
702 |
/* Start over for an absolute symlink. */ |
|
703 |
new_path = resolved_path; |
|
704 |
else |
|
705 |
/* Otherwise back up over this component. */ |
|
706 |
while (*(--new_path) != '/') |
|
707 |
; |
|
708 |
/* Safe sex check. */ |
|
709 |
if (strlen(path) + n >= MAXPATHLEN) { |
|
710 |
errno = ENAMETOOLONG; |
|
711 |
return NULL; |
|
712 |
} |
|
713 |
/* Insert symlink contents into path. */ |
|
714 |
strcat(link_path, path); |
|
715 |
strcpy(copy_path, link_path); |
|
716 |
path = copy_path; |
|
717 |
} |
|
718 |
#endif /* S_IFLNK */ |
|
719 |
*new_path++ = '/'; |
|
720 |
} |
|
721 |
/* Delete trailing slash but don't whomp a lone slash. */ |
|
722 |
if (new_path != resolved_path + 1 && new_path[-1] == '/') |
|
723 |
new_path--; |
|
724 |
/* Make sure it's null terminated. */ |
|
725 |
*new_path = '\0'; |
|
726 |
return resolved_path; |
|
727 |
} |
|
728 |
# define HAS_REALPATH |
|
729 |
#endif /* WANT_REALPATH && not HAS_REALPATH */ |
|
730 |
%} |
|
731 |
! ! |
|
732 |
||
2 | 733 |
!OperatingSystem class methodsFor:'documentation'! |
734 |
||
88 | 735 |
copyright |
736 |
" |
|
737 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
185 | 738 |
All Rights Reserved |
88 | 739 |
|
740 |
This software is furnished under a license and may be used |
|
741 |
only in accordance with the terms of that license and with the |
|
742 |
inclusion of the above copyright notice. This software may not |
|
743 |
be provided or otherwise made available to, or used by, any |
|
744 |
other person. No title to or ownership of the software is |
|
745 |
hereby transferred. |
|
746 |
" |
|
747 |
! |
|
748 |
||
2 | 749 |
documentation |
750 |
" |
|
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
751 |
this class realizes access to most (all ?) required operating system services; |
68 | 752 |
some of it is very specific for unix, so do not depend on |
753 |
things available here in your applications - some may not |
|
370 | 754 |
be found in other OS's or be slightly different ... |
68 | 755 |
|
756 |
(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
|
757 |
from you - in some situations it MAY be interesting to be |
792 | 758 |
able to get down to a select or fork system call easily (at least on Unix systems). |
68 | 759 |
You decide - portability vs. functionality) |
760 |
||
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
761 |
Currently, there is only this class available - once others than |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
762 |
Unix are supported, the corresponding class will be bound to the |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
763 |
global variable OperatingSystem. |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
764 |
|
1286 | 765 |
[Class variables:] |
766 |
||
1487 | 767 |
HostName <String> remembered hostname |
768 |
||
769 |
DomainName <String> remembered domainname |
|
770 |
||
771 |
LastErrorNumber <Integer> the last value of errno |
|
772 |
||
773 |
LastExecStatus <Integer> the returned exec status after |
|
774 |
the last call of system |
|
775 |
||
776 |
OSSignals <Array> Array of signals to be raised for corresponding |
|
777 |
OperatingSystem signals. |
|
778 |
||
779 |
ForkFailed <Boolean> set if a fork (or popen) has failed; |
|
780 |
ST/X will avoid doing more forks/popens |
|
781 |
if this flag is set, for a slightly |
|
782 |
smoother operation. |
|
783 |
||
784 |
SlowFork <Boolean> if set, fork and popen are avoided; |
|
785 |
(more or less obsolete now) |
|
786 |
||
787 |
||
788 |
ErrorSignal <Signal> Parentsignal of all OS error signals. |
|
789 |
not directly raised. |
|
790 |
||
791 |
AccessDeniedErrorSignal |
|
792 |
||
793 |
FileNotFoundErrorSignal |
|
794 |
||
795 |
LocaleInfo <Dictionary> if non nil, that is taken instead of the operating |
|
796 |
systems locale definitions (allows for overwriting |
|
797 |
these, or provide a compatible info on systems which do |
|
798 |
not support locales) |
|
1286 | 799 |
|
800 |
[author:] |
|
1487 | 801 |
Claus Gittinger |
1286 | 802 |
|
803 |
[see also:] |
|
1487 | 804 |
OSProcessStatus |
805 |
Filename Date Time |
|
806 |
ExternalStream FileStream PipeStream Socket |
|
2 | 807 |
" |
808 |
! ! |
|
809 |
||
95 | 810 |
!OperatingSystem class methodsFor:'initialization'! |
811 |
||
812 |
initialize |
|
185 | 813 |
"initialize the class" |
814 |
||
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
815 |
ObjectMemory addDependent:self. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
816 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
817 |
ErrorSignal isNil ifTrue:[ |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
818 |
ErrorSignal := Object errorSignal newSignalMayProceed:true.. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
819 |
ErrorSignal nameClass:self message:#errorSignal. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
820 |
ErrorSignal notifierString:'OS error encountered'. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
821 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
822 |
AccessDeniedErrorSignal := ErrorSignal newSignalMayProceed:true. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
823 |
AccessDeniedErrorSignal nameClass:self message:#accessDeniedError. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
824 |
AccessDeniedErrorSignal notifierString:'OS access denied'. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
825 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
826 |
FileNotFoundErrorSignal := ErrorSignal newSignalMayProceed:true. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
827 |
FileNotFoundErrorSignal nameClass:self message:#fileNotFoundErrorSignal. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
828 |
FileNotFoundErrorSignal notifierString:'OS file not found'. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
829 |
] |
95 | 830 |
! |
831 |
||
1470 | 832 |
update:something with:aParameter from:changedObject |
1247 | 833 |
"catch image restart and flush some cached data" |
834 |
||
95 | 835 |
something == #earlyRestart ifTrue:[ |
1487 | 836 |
" |
837 |
flush cached data |
|
838 |
" |
|
839 |
HostName := nil. |
|
840 |
DomainName := nil. |
|
841 |
LastErrorNumber := nil. |
|
842 |
LastExecStatus := nil |
|
95 | 843 |
] |
1247 | 844 |
|
845 |
"Modified: 22.4.1996 / 13:10:43 / cg" |
|
1470 | 846 |
"Created: 15.6.1996 / 15:22:37 / cg" |
95 | 847 |
! ! |
848 |
||
616 | 849 |
!OperatingSystem class methodsFor:'OS signal constants'! |
850 |
||
851 |
sigABRT |
|
852 |
"return the signal number for SIGABRT - 0 if not supported by OS |
|
853 |
(the numeric value is not the same across unix-systems)" |
|
854 |
||
855 |
%{ /* NOCONTEXT */ |
|
856 |
#ifdef SIGABRT |
|
1135 | 857 |
RETURN ( __MKSMALLINT(SIGABRT) ); |
616 | 858 |
#else |
1135 | 859 |
RETURN ( __MKSMALLINT(0) ); |
616 | 860 |
#endif |
861 |
%} |
|
862 |
! |
|
863 |
||
864 |
sigALRM |
|
865 |
"return the signal number for SIGALRM - 0 if not supported |
|
866 |
(the numeric value is not the same across unix-systems)" |
|
867 |
||
868 |
%{ /* NOCONTEXT */ |
|
869 |
#ifdef SIGALRM |
|
1135 | 870 |
RETURN ( __MKSMALLINT(SIGALRM) ); |
616 | 871 |
#else |
1135 | 872 |
RETURN ( __MKSMALLINT(0) ); |
616 | 873 |
#endif |
874 |
%} |
|
875 |
! |
|
876 |
||
831 | 877 |
sigBREAK |
878 |
"return the signal number for SIGBREAK - 0 if not supported. |
|
879 |
This is an MSDOS specific signal" |
|
880 |
||
881 |
%{ /* NOCONTEXT */ |
|
882 |
#ifdef SIGBREAK |
|
1135 | 883 |
RETURN ( __MKSMALLINT(SIGBREAK) ); |
831 | 884 |
#else |
1135 | 885 |
RETURN ( __MKSMALLINT(0) ); |
831 | 886 |
#endif |
887 |
%} |
|
888 |
! |
|
889 |
||
616 | 890 |
sigBUS |
891 |
"return the signal number for SIGBUS - 0 if not supported |
|
892 |
(the numeric value is not the same across unix-systems)" |
|
893 |
||
894 |
%{ /* NOCONTEXT */ |
|
895 |
#ifdef SIGBUS |
|
1135 | 896 |
RETURN ( __MKSMALLINT(SIGBUS) ); |
616 | 897 |
#else |
1135 | 898 |
RETURN ( __MKSMALLINT(0) ); |
616 | 899 |
#endif |
900 |
%} |
|
901 |
! |
|
902 |
||
903 |
sigCHLD |
|
904 |
"return the signal number for SIGCHLD - 0 if not supported |
|
905 |
(the numeric value is not the same across unix-systems)" |
|
906 |
||
907 |
%{ /* NOCONTEXT */ |
|
908 |
#if defined(SIGCHLD) |
|
1135 | 909 |
RETURN ( __MKSMALLINT(SIGCHLD) ); |
616 | 910 |
#else |
911 |
# if defined(SIGCLD) |
|
1135 | 912 |
RETURN ( __MKSMALLINT(SIGCLD) ); |
616 | 913 |
# else |
1135 | 914 |
RETURN ( __MKSMALLINT(0) ); |
616 | 915 |
# endif |
916 |
#endif |
|
917 |
%} |
|
918 |
! |
|
919 |
||
920 |
sigCONT |
|
921 |
"return the signal number for SIGCONT - 0 if not supported |
|
922 |
(the numeric value is not the same across unix-systems)" |
|
923 |
||
924 |
%{ /* NOCONTEXT */ |
|
925 |
#if defined(SIGCONT) |
|
1135 | 926 |
RETURN ( __MKSMALLINT(SIGCONT) ); |
616 | 927 |
#else |
1135 | 928 |
RETURN ( __MKSMALLINT(0) ); |
616 | 929 |
#endif |
930 |
%} |
|
931 |
! |
|
932 |
||
933 |
sigDANGER |
|
934 |
"return the signal number for SIGDANGER - 0 if not supported |
|
935 |
(seems to be an AIX special)" |
|
936 |
||
937 |
%{ /* NOCONTEXT */ |
|
710 | 938 |
#if defined(SIGDANGER) |
1135 | 939 |
RETURN ( __MKSMALLINT(SIGDANGER) ); |
616 | 940 |
#else |
1135 | 941 |
RETURN ( __MKSMALLINT(0) ); |
616 | 942 |
#endif |
943 |
%} |
|
944 |
! |
|
945 |
||
946 |
sigEMT |
|
947 |
"return the signal number for SIGEMT - 0 if not supported by OS |
|
948 |
(the numeric value is not the same across unix-systems)" |
|
949 |
||
950 |
%{ /* NOCONTEXT */ |
|
951 |
#ifdef SIGEMT |
|
1135 | 952 |
RETURN ( __MKSMALLINT(SIGEMT) ); |
616 | 953 |
#else |
1135 | 954 |
RETURN ( __MKSMALLINT(0) ); |
616 | 955 |
#endif |
956 |
%} |
|
957 |
! |
|
958 |
||
959 |
sigFP |
|
960 |
"return the signal number for SIGFP - 0 if not supported by OS |
|
961 |
(the numeric value is not the same across unix-systems)" |
|
962 |
||
963 |
%{ /* NOCONTEXT */ |
|
964 |
#ifdef SIGFPE |
|
1135 | 965 |
RETURN ( __MKSMALLINT(SIGFPE) ); |
616 | 966 |
#else |
1135 | 967 |
RETURN ( __MKSMALLINT(0) ); |
616 | 968 |
#endif |
969 |
%} |
|
970 |
! |
|
971 |
||
972 |
sigGRANT |
|
973 |
"return the signal number for SIGGRANT - 0 if not supported |
|
974 |
(seems to be an AIX special)" |
|
975 |
||
976 |
%{ /* NOCONTEXT */ |
|
977 |
#if defined(SIGGRANT) |
|
1135 | 978 |
RETURN ( __MKSMALLINT(SIGGRANT) ); |
616 | 979 |
#else |
1135 | 980 |
RETURN ( __MKSMALLINT(0) ); |
616 | 981 |
#endif |
982 |
%} |
|
983 |
! |
|
984 |
||
985 |
sigHUP |
|
986 |
"return the signal number for SIGHUP |
|
987 |
(the numeric value is not the same across unix-systems)" |
|
988 |
||
989 |
%{ /* NOCONTEXT */ |
|
990 |
#ifdef SIGHUP |
|
1135 | 991 |
RETURN ( __MKSMALLINT(SIGHUP) ); |
616 | 992 |
#else |
1135 | 993 |
RETURN ( __MKSMALLINT(0) ); |
616 | 994 |
#endif |
995 |
%} |
|
996 |
! |
|
997 |
||
998 |
sigILL |
|
999 |
"return the signal number for SIGILL - 0 if not supported by OS |
|
1000 |
(the numeric value is not the same across unix-systems)" |
|
1001 |
||
1002 |
%{ /* NOCONTEXT */ |
|
1003 |
#ifdef SIGILL |
|
1135 | 1004 |
RETURN ( __MKSMALLINT(SIGILL) ); |
616 | 1005 |
#else |
1135 | 1006 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1007 |
#endif |
1008 |
%} |
|
1009 |
! |
|
1010 |
||
1011 |
sigINT |
|
1012 |
"return the signal number for SIGINT |
|
1013 |
(the numeric value is not the same across unix-systems)" |
|
1014 |
||
1015 |
%{ /* NOCONTEXT */ |
|
1016 |
#ifdef SIGINT |
|
1135 | 1017 |
RETURN ( __MKSMALLINT(SIGINT) ); |
616 | 1018 |
#else |
1135 | 1019 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1020 |
#endif |
1021 |
%} |
|
1022 |
! |
|
1023 |
||
1024 |
sigIO |
|
1025 |
"return the signal number for SIGIO - 0 if not supported |
|
1026 |
(the numeric value is not the same across unix-systems)" |
|
1027 |
||
1028 |
%{ /* NOCONTEXT */ |
|
1029 |
#if defined(SIGIO) |
|
1135 | 1030 |
RETURN ( __MKSMALLINT(SIGIO) ); |
616 | 1031 |
#else |
1135 | 1032 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1033 |
#endif |
1034 |
%} |
|
1035 |
! |
|
1036 |
||
1037 |
sigIOT |
|
1038 |
"return the signal number for SIGIOT - 0 if not supported by OS |
|
1039 |
(the numeric value is not the same across unix-systems)" |
|
1040 |
||
1041 |
%{ /* NOCONTEXT */ |
|
1042 |
#ifdef SIGIOT |
|
1135 | 1043 |
RETURN ( __MKSMALLINT(SIGIOT) ); |
616 | 1044 |
#else |
1135 | 1045 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1046 |
#endif |
1047 |
%} |
|
1048 |
! |
|
1049 |
||
1050 |
sigKILL |
|
1051 |
"return the signal number for SIGKILL |
|
1052 |
(the numeric value is not the same across unix-systems)" |
|
1053 |
||
1054 |
%{ /* NOCONTEXT */ |
|
1055 |
#ifdef SIGKILL |
|
1135 | 1056 |
RETURN ( __MKSMALLINT(SIGKILL) ); |
616 | 1057 |
#else |
1135 | 1058 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1059 |
#endif |
1060 |
%} |
|
1061 |
! |
|
1062 |
||
1063 |
sigLOST |
|
1064 |
"return the signal number for SIGLOST - 0 if not supported |
|
1065 |
(the numeric value is not the same across unix-systems)" |
|
1066 |
||
1067 |
%{ /* NOCONTEXT */ |
|
1068 |
#if defined(SIGLOST) |
|
1135 | 1069 |
RETURN ( __MKSMALLINT(SIGLOST) ); |
616 | 1070 |
#else |
1135 | 1071 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1072 |
#endif |
1073 |
%} |
|
1074 |
! |
|
1075 |
||
1076 |
sigMIGRATE |
|
1077 |
"return the signal number for SIGMIGRATE - 0 if not supported |
|
1078 |
(seems to be an AIX special)" |
|
1079 |
||
1080 |
%{ /* NOCONTEXT */ |
|
1081 |
#if defined(SIGMIGRATE) |
|
1135 | 1082 |
RETURN ( __MKSMALLINT(SIGMIGRATE) ); |
616 | 1083 |
#else |
1135 | 1084 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1085 |
#endif |
1086 |
%} |
|
1087 |
! |
|
1088 |
||
1089 |
sigMSG |
|
1090 |
"return the signal number for SIGMSG - 0 if not supported |
|
1091 |
(seems to be an AIX special)" |
|
1092 |
||
1093 |
%{ /* NOCONTEXT */ |
|
1094 |
#if defined(SIGMSG) |
|
1135 | 1095 |
RETURN ( __MKSMALLINT(SIGMSG) ); |
616 | 1096 |
#else |
1135 | 1097 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1098 |
#endif |
1099 |
%} |
|
1100 |
! |
|
1101 |
||
1102 |
sigPIPE |
|
1103 |
"return the signal number for SIGPIPE - 0 if not supported |
|
1104 |
(the numeric value is not the same across unix-systems)" |
|
1105 |
||
1106 |
%{ /* NOCONTEXT */ |
|
1107 |
#ifdef SIGPIPE |
|
1135 | 1108 |
RETURN ( __MKSMALLINT(SIGPIPE) ); |
616 | 1109 |
#else |
1135 | 1110 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1111 |
#endif |
1112 |
%} |
|
1113 |
! |
|
1114 |
||
1115 |
sigPOLL |
|
1116 |
"return the signal number for SIGPOLL - 0 if not supported |
|
1117 |
(the numeric value is not the same across unix-systems)" |
|
1118 |
||
1119 |
%{ /* NOCONTEXT */ |
|
1120 |
#if defined(SIGPOLL) |
|
1135 | 1121 |
RETURN ( __MKSMALLINT(SIGPOLL) ); |
616 | 1122 |
#else |
1135 | 1123 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1124 |
#endif |
1125 |
%} |
|
1126 |
! |
|
1127 |
||
1128 |
sigPRE |
|
1129 |
"return the signal number for SIGPRE - 0 if not supported |
|
1130 |
(seems to be an AIX special)" |
|
1131 |
||
1132 |
%{ /* NOCONTEXT */ |
|
1133 |
#if defined(SIGPRE) |
|
1135 | 1134 |
RETURN ( __MKSMALLINT(SIGPRE) ); |
616 | 1135 |
#else |
1135 | 1136 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1137 |
#endif |
1138 |
%} |
|
1139 |
! |
|
1140 |
||
1141 |
sigPROF |
|
1142 |
"return the signal number for SIGPROF - 0 if not supported |
|
1143 |
(the numeric value is not the same across unix-systems)" |
|
1144 |
||
1145 |
%{ /* NOCONTEXT */ |
|
1146 |
#if defined(SIGPROF) |
|
1135 | 1147 |
RETURN ( __MKSMALLINT(SIGPROF) ); |
616 | 1148 |
#else |
1135 | 1149 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1150 |
#endif |
1151 |
%} |
|
1152 |
! |
|
1153 |
||
1154 |
sigPWR |
|
1155 |
"return the signal number for SIGPWR - 0 if not supported |
|
1156 |
(not available on all systems)" |
|
1157 |
||
1158 |
%{ /* NOCONTEXT */ |
|
1159 |
#if defined(SIGPWR) |
|
1135 | 1160 |
RETURN ( __MKSMALLINT(SIGPWR) ); |
616 | 1161 |
#else |
1135 | 1162 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1163 |
#endif |
1164 |
%} |
|
1165 |
! |
|
1166 |
||
1167 |
sigQUIT |
|
1168 |
"return the signal number for SIGQUIT |
|
1169 |
(the numeric value is not the same across unix-systems)" |
|
1170 |
||
1171 |
%{ /* NOCONTEXT */ |
|
1172 |
#ifdef SIGQUIT |
|
1135 | 1173 |
RETURN ( __MKSMALLINT(SIGQUIT) ); |
616 | 1174 |
#else |
1135 | 1175 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1176 |
#endif |
1177 |
%} |
|
1178 |
! |
|
1179 |
||
1180 |
sigRETRACT |
|
1181 |
"return the signal number for SIGRETRACT - 0 if not supported |
|
1182 |
(seems to be an AIX special)" |
|
1183 |
||
1184 |
%{ /* NOCONTEXT */ |
|
1185 |
#if defined(SIGRETRACT) |
|
1135 | 1186 |
RETURN ( __MKSMALLINT(SIGRETRACT) ); |
616 | 1187 |
#else |
1135 | 1188 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1189 |
#endif |
1190 |
%} |
|
1191 |
! |
|
1192 |
||
1193 |
sigSAK |
|
1194 |
"return the signal number for SIGSAK - 0 if not supported |
|
1195 |
(seems to be an AIX special)" |
|
1196 |
||
1197 |
%{ /* NOCONTEXT */ |
|
1198 |
#if defined(SIGSAK) |
|
1135 | 1199 |
RETURN ( __MKSMALLINT(SIGSAK) ); |
616 | 1200 |
#else |
1135 | 1201 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1202 |
#endif |
1203 |
%} |
|
1204 |
! |
|
1205 |
||
1206 |
sigSEGV |
|
1207 |
"return the signal number for SIGSEGV - 0 if not supported |
|
1208 |
(the numeric value is not the same across unix-systems)" |
|
1209 |
||
1210 |
%{ /* NOCONTEXT */ |
|
1211 |
#ifdef SIGSEGV |
|
1135 | 1212 |
RETURN ( __MKSMALLINT(SIGSEGV) ); |
616 | 1213 |
#else |
1135 | 1214 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1215 |
#endif |
1216 |
%} |
|
1217 |
! |
|
1218 |
||
1219 |
sigSOUND |
|
1220 |
"return the signal number for SIGSOUND - 0 if not supported |
|
1221 |
(seems to be an AIX special)" |
|
1222 |
||
1223 |
%{ /* NOCONTEXT */ |
|
1224 |
#if defined(SIGSOUND) |
|
1135 | 1225 |
RETURN ( __MKSMALLINT(SIGSOUND) ); |
616 | 1226 |
#else |
1135 | 1227 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1228 |
#endif |
1229 |
%} |
|
1230 |
! |
|
1231 |
||
1232 |
sigSTOP |
|
1233 |
"return the signal number for SIGSTOP - 0 if not supported |
|
1234 |
(the numeric value is not the same across unix-systems)" |
|
1235 |
||
1236 |
%{ /* NOCONTEXT */ |
|
1237 |
#if defined(SIGSTOP) |
|
1135 | 1238 |
RETURN ( __MKSMALLINT(SIGSTOP) ); |
616 | 1239 |
#else |
1135 | 1240 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1241 |
#endif |
1242 |
%} |
|
1243 |
! |
|
1244 |
||
1245 |
sigSYS |
|
1246 |
"return the signal number for SIGSYS - 0 if not supported |
|
1247 |
(the numeric value is not the same across unix-systems)" |
|
1248 |
||
1249 |
%{ /* NOCONTEXT */ |
|
1250 |
#ifdef SIGSYS |
|
1135 | 1251 |
RETURN ( __MKSMALLINT(SIGSYS) ); |
616 | 1252 |
#else |
1135 | 1253 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1254 |
#endif |
1255 |
%} |
|
1256 |
! |
|
1257 |
||
1258 |
sigTERM |
|
1259 |
"return the signal number for SIGTERM - 0 if not supported |
|
1260 |
(the numeric value is not the same across unix-systems)" |
|
1261 |
||
1262 |
%{ /* NOCONTEXT */ |
|
1263 |
#ifdef SIGTERM |
|
1135 | 1264 |
RETURN ( __MKSMALLINT(SIGTERM) ); |
616 | 1265 |
#else |
1135 | 1266 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1267 |
#endif |
1268 |
%} |
|
1269 |
! |
|
1270 |
||
1271 |
sigTRAP |
|
1272 |
"return the signal number for SIGTRAP - 0 if not supported by OS |
|
1273 |
(the numeric value is not the same across unix-systems)" |
|
1274 |
||
1275 |
%{ /* NOCONTEXT */ |
|
1276 |
#ifdef SIGTRAP |
|
1135 | 1277 |
RETURN ( __MKSMALLINT(SIGTRAP) ); |
616 | 1278 |
#else |
1135 | 1279 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1280 |
#endif |
1281 |
%} |
|
1282 |
! |
|
1283 |
||
1284 |
sigTSTP |
|
1285 |
"return the signal number for SIGTSTP - 0 if not supported |
|
1286 |
(the numeric value is not the same across unix-systems)" |
|
1287 |
||
1288 |
%{ /* NOCONTEXT */ |
|
1289 |
#if defined(SIGTSTP) |
|
1135 | 1290 |
RETURN ( __MKSMALLINT(SIGTSTP) ); |
616 | 1291 |
#else |
1135 | 1292 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1293 |
#endif |
1294 |
%} |
|
1295 |
! |
|
1296 |
||
1297 |
sigTTIN |
|
1298 |
"return the signal number for SIGTTIN - 0 if not supported |
|
1299 |
(the numeric value is not the same across unix-systems)" |
|
1300 |
||
1301 |
%{ /* NOCONTEXT */ |
|
1302 |
#if defined(SIGTTIN) |
|
1135 | 1303 |
RETURN ( __MKSMALLINT(SIGTTIN) ); |
616 | 1304 |
#else |
1135 | 1305 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1306 |
#endif |
1307 |
%} |
|
1308 |
! |
|
1309 |
||
1310 |
sigTTOU |
|
1311 |
"return the signal number for SIGTTOU - 0 if not supported |
|
1312 |
(the numeric value is not the same across unix-systems)" |
|
1313 |
||
1314 |
%{ /* NOCONTEXT */ |
|
1315 |
#if defined(SIGTTOU) |
|
1135 | 1316 |
RETURN ( __MKSMALLINT(SIGTTOU) ); |
616 | 1317 |
#else |
1135 | 1318 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1319 |
#endif |
1320 |
%} |
|
1321 |
! |
|
1322 |
||
1323 |
sigURG |
|
1324 |
"return the signal number for SIGURG - 0 if not supported |
|
1325 |
(the numeric value is not the same across unix-systems)" |
|
1326 |
||
1327 |
%{ /* NOCONTEXT */ |
|
1328 |
#if defined(SIGURG) |
|
1135 | 1329 |
RETURN ( __MKSMALLINT(SIGURG) ); |
616 | 1330 |
#else |
1135 | 1331 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1332 |
#endif |
1333 |
%} |
|
1334 |
! |
|
1335 |
||
1336 |
sigUSR1 |
|
1337 |
"return the signal number for SIGUSR1 - 0 if not supported |
|
1338 |
(the numeric value is not the same across unix-systems)" |
|
1339 |
||
1340 |
%{ /* NOCONTEXT */ |
|
1341 |
#if defined(SIGUSR1) |
|
1135 | 1342 |
RETURN ( __MKSMALLINT(SIGUSR1) ); |
616 | 1343 |
#else |
1135 | 1344 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1345 |
#endif |
1346 |
%} |
|
1347 |
! |
|
1348 |
||
1349 |
sigUSR2 |
|
1350 |
"return the signal number for SIGUSR2 - 0 if not supported |
|
1351 |
(the numeric value is not the same across unix-systems)" |
|
1352 |
||
1353 |
%{ /* NOCONTEXT */ |
|
1354 |
#if defined(SIGUSR2) |
|
1135 | 1355 |
RETURN ( __MKSMALLINT(SIGUSR2) ); |
616 | 1356 |
#else |
1135 | 1357 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1358 |
#endif |
1359 |
%} |
|
1360 |
! |
|
1361 |
||
1362 |
sigVTALRM |
|
1363 |
"return the signal number for SIGVTALRM - 0 if not supported |
|
1364 |
(the numeric value is not the same across unix-systems)" |
|
1365 |
||
1366 |
%{ /* NOCONTEXT */ |
|
1367 |
#if defined(SIGVTALRM) |
|
1135 | 1368 |
RETURN ( __MKSMALLINT(SIGVTALRM) ); |
616 | 1369 |
#else |
1135 | 1370 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1371 |
#endif |
1372 |
%} |
|
1373 |
! |
|
1374 |
||
1375 |
sigWINCH |
|
1376 |
"return the signal number for SIGWINCH - 0 if not supported |
|
1377 |
(the numeric value is not the same across unix-systems)" |
|
1378 |
||
1379 |
%{ /* NOCONTEXT */ |
|
1380 |
#if defined(SIGWINCH) |
|
1135 | 1381 |
RETURN ( __MKSMALLINT(SIGWINCH) ); |
616 | 1382 |
#else |
1135 | 1383 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1384 |
#endif |
1385 |
%} |
|
1386 |
! |
|
1387 |
||
1388 |
sigXCPU |
|
1389 |
"return the signal number for SIGXCPU - 0 if not supported |
|
1390 |
(the numeric value is not the same across unix-systems)" |
|
1391 |
||
1392 |
%{ /* NOCONTEXT */ |
|
1393 |
#if defined(SIGXCPU) |
|
1135 | 1394 |
RETURN ( __MKSMALLINT(SIGXCPU) ); |
616 | 1395 |
#else |
1135 | 1396 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1397 |
#endif |
1398 |
%} |
|
1399 |
! |
|
1400 |
||
1401 |
sigXFSZ |
|
1402 |
"return the signal number for SIGXFSZ - 0 if not supported |
|
1403 |
(the numeric value is not the same across unix-systems)" |
|
1404 |
||
1405 |
%{ /* NOCONTEXT */ |
|
1406 |
#if defined(SIGXFSZ) |
|
1135 | 1407 |
RETURN ( __MKSMALLINT(SIGXFSZ) ); |
616 | 1408 |
#else |
1135 | 1409 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1410 |
#endif |
1411 |
%} |
|
1412 |
! ! |
|
1413 |
||
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1414 |
!OperatingSystem class methodsFor:'Signal constants'! |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1415 |
|
616 | 1416 |
accessDeniedErrorSignal |
1417 |
"return the signal raised when a (file-) access is denied." |
|
1418 |
||
1419 |
^ AccessDeniedErrorSignal |
|
1420 |
! |
|
1421 |
||
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1422 |
errorSignal |
1247 | 1423 |
"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
|
1424 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1425 |
^ ErrorSignal |
1247 | 1426 |
|
1427 |
"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
|
1428 |
! |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1429 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1430 |
fileNotFoundErrorSignal |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1431 |
"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
|
1432 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1433 |
^ FileNotFoundErrorSignal |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1434 |
! ! |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1435 |
|
1 | 1436 |
!OperatingSystem class methodsFor:'error messages'! |
1437 |
||
1153
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1438 |
clearLastErrorNumber |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1439 |
"return the last errors number. |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1440 |
See also: #lastErrorSymbol and #lastErrorString. |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1441 |
Notice: having a single error number is a bad idea in a multithreaded |
1487 | 1442 |
environment - this interface will change." |
1153
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1443 |
|
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1444 |
LastErrorNumber := nil. |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1445 |
|
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1446 |
" |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1447 |
OperatingSystem clearLastErrorNumber |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1448 |
" |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1449 |
|
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1450 |
"Created: 12.4.1996 / 09:28:58 / stefan" |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1451 |
"Modified: 12.4.1996 / 09:38:51 / stefan" |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1452 |
! |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1453 |
|
85 | 1454 |
currentErrorNumber |
68 | 1455 |
"returns the OS's last error nr (i.e. the value of errno). |
1456 |
Notice, that the value of this flag is only valid immediately |
|
1457 |
after the error occurred - it gets updated with every other |
|
85 | 1458 |
request to the OS. |
1459 |
Use lastErrorNumber - currentErrorNumber is invalidated by |
|
1460 |
many, many internal calls." |
|
68 | 1461 |
|
1462 |
%{ /* NOCONTEXT */ |
|
1463 |
||
1135 | 1464 |
RETURN ( __MKSMALLINT(errno) ); |
68 | 1465 |
%} |
1466 |
" |
|
85 | 1467 |
OperatingSystem currentErrorNumber |
1468 |
" |
|
1469 |
! |
|
1470 |
||
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1471 |
errorNumberFor:aSymbol |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1472 |
"given a symbolic error, return the numeric; |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1473 |
(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
|
1474 |
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
|
1475 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1476 |
%{ /* NOCONTEXT */ |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1477 |
OBJ sym = aSymbol; |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1478 |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1479 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1480 |
* POSIX errnos - these should be defined |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1481 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1482 |
#ifdef EPERM |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1483 |
if (sym == @symbol(EPERM)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1484 |
RETURN ( __MKSMALLINT(EPERM) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1485 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1486 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1487 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1488 |
#ifdef ENOENT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1489 |
if (sym == @symbol(ENOENT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1490 |
RETURN ( __MKSMALLINT(ENOENT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1491 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1492 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1493 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1494 |
#ifdef ESRCH |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1495 |
if (sym == @symbol(ESRCH)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1496 |
RETURN ( __MKSMALLINT(ESRCH) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1497 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1498 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1499 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1500 |
#ifdef EINTR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1501 |
if (sym == @symbol(EINTR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1502 |
RETURN ( __MKSMALLINT(EINTR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1503 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1504 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1505 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1506 |
#ifdef EIO |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1507 |
if (sym == @symbol(EIO)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1508 |
RETURN ( __MKSMALLINT(EIO) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1509 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1510 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1511 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1512 |
#ifdef ENXIO |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1513 |
if (sym == @symbol(ENXIO)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1514 |
RETURN ( __MKSMALLINT(ENXIO) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1515 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1516 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1517 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1518 |
#ifdef E2BIG |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1519 |
if (sym == @symbol(E2BIG)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1520 |
RETURN ( __MKSMALLINT(E2BIG) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1521 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1522 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1523 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1524 |
#ifdef ENOEXEC |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1525 |
if (sym == @symbol(ENOEXEC)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1526 |
RETURN ( __MKSMALLINT(ENOEXEC) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1527 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1528 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1529 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1530 |
#ifdef EBADF |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1531 |
if (sym == @symbol(EBADF)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1532 |
RETURN ( __MKSMALLINT(EBADF) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1533 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1534 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1535 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1536 |
#ifdef ECHILD |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1537 |
if (sym == @symbol(ECHILD)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1538 |
RETURN ( __MKSMALLINT(ECHILD) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1539 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1540 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1541 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1542 |
#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
|
1543 |
if (sym == @symbol(EAGAIN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1544 |
RETURN ( __MKSMALLINT(EAGAIN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1545 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1546 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1547 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1548 |
#ifdef ENOMEM |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1549 |
if (sym == @symbol(ENOMEM)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1550 |
RETURN ( __MKSMALLINT(ENOMEM) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1551 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1552 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1553 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1554 |
#ifdef EACCES |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1555 |
if (sym == @symbol(EACCES)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1556 |
RETURN ( __MKSMALLINT(EACCES) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1557 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1558 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1559 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1560 |
#ifdef EFAULT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1561 |
if (sym == @symbol(EFAULT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1562 |
RETURN ( __MKSMALLINT(EFAULT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1563 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1564 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1565 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1566 |
#ifdef EBUSY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1567 |
if (sym == @symbol(EBUSY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1568 |
RETURN ( __MKSMALLINT(EBUSY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1569 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1570 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1571 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1572 |
#ifdef EXDEV |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1573 |
if (sym == @symbol(EXDEV)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1574 |
RETURN ( __MKSMALLINT(EXDEV) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1575 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1576 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1577 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1578 |
#ifdef ENODEV |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1579 |
if (sym == @symbol(ENODEV)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1580 |
RETURN ( __MKSMALLINT(ENODEV) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1581 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1582 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1583 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1584 |
#ifdef ENOTDIR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1585 |
if (sym == @symbol(ENOTDIR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1586 |
RETURN ( __MKSMALLINT(ENOTDIR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1587 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1588 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1589 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1590 |
#ifdef EISDIR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1591 |
if (sym == @symbol(EISDIR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1592 |
RETURN ( __MKSMALLINT(EISDIR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1593 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1594 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1595 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1596 |
#ifdef EINVAL |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1597 |
if (sym == @symbol(EINVAL)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1598 |
RETURN ( __MKSMALLINT(EINVAL) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1599 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1600 |
#endif |
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 |
#ifdef ENFILE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1603 |
if (sym == @symbol(ENFILE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1604 |
RETURN ( __MKSMALLINT(ENFILE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1605 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1606 |
#endif |
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 |
#ifdef EMFILE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1609 |
if (sym == @symbol(EMFILE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1610 |
RETURN ( __MKSMALLINT(EMFILE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1611 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1612 |
#endif |
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 |
#ifdef ENOTTY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1615 |
if (sym == @symbol(ENOTTY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1616 |
RETURN ( __MKSMALLINT(ENOTTY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1617 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1618 |
#endif |
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 |
#ifdef EFBIG |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1621 |
if (sym == @symbol(EFBIG)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1622 |
RETURN ( __MKSMALLINT(EFBIG) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1623 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1624 |
#endif |
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 |
#ifdef ENOSPC |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1627 |
if (sym == @symbol(ENOSPC)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1628 |
RETURN ( __MKSMALLINT(ENOSPC) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1629 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1630 |
#endif |
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 |
#ifdef ESPIPE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1633 |
if (sym == @symbol(ESPIPE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1634 |
RETURN ( __MKSMALLINT(ESPIPE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1635 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1636 |
#endif |
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 |
#ifdef EROFS |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1639 |
if (sym == @symbol(EROFS)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1640 |
RETURN ( __MKSMALLINT(EROFS) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1641 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1642 |
#endif |
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 |
#ifdef EMLINK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1645 |
if (sym == @symbol(EMLINK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1646 |
RETURN ( __MKSMALLINT(EMLINK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1647 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1648 |
#endif |
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 |
#ifdef EPIPE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1651 |
if (sym == @symbol(EPIPE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1652 |
RETURN ( __MKSMALLINT(EPIPE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1653 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1654 |
#endif |
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 |
#ifdef EDOM |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1657 |
if (sym == @symbol(EDOM)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1658 |
RETURN ( __MKSMALLINT(EDOM) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1659 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1660 |
#endif |
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 |
#ifdef ERANGE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1663 |
if (sym == @symbol(ERANGE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1664 |
RETURN ( __MKSMALLINT(ERANGE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1665 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1666 |
#endif |
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 |
#ifdef EDEADLK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1669 |
if (sym == @symbol(EDEADLK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1670 |
RETURN ( __MKSMALLINT(EDEADLK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1671 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1672 |
#endif |
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 |
#ifdef ENAMETOOLONG |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1675 |
if (sym == @symbol(ENAMETOOLONG)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1676 |
RETURN ( __MKSMALLINT(ENAMETOOLONG) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1677 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1678 |
#endif |
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 |
#ifdef ENOLCK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1681 |
if (sym == @symbol(ENOLCK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1682 |
RETURN ( __MKSMALLINT(ENOLCK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1683 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1684 |
#endif |
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 |
#ifdef ENOSYS |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1687 |
if (sym == @symbol(ENOSYS)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1688 |
RETURN ( __MKSMALLINT(ENOSYS) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1689 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1690 |
#endif |
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 |
#ifdef ENOTEMPTY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1693 |
if (sym == @symbol(ENOTEMPTY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1694 |
RETURN ( __MKSMALLINT(ENOTEMPTY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1695 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1696 |
#endif |
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 |
#ifdef EEXIST |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1699 |
if (sym == @symbol(EEXIST)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1700 |
RETURN ( __MKSMALLINT(EEXIST) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1701 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1702 |
#endif |
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 |
#ifdef EILSEQ |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1705 |
if (sym == @symbol(EILSEQ)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1706 |
RETURN ( __MKSMALLINT(EILSEQ) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1707 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1708 |
#endif |
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 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1711 |
* XPG3 errnos - defined on most systems |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1712 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1713 |
#ifdef ENOTBLK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1714 |
if (sym == @symbol(ENOTBLK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1715 |
RETURN ( __MKSMALLINT(ENOTBLK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1716 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1717 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1718 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1719 |
#ifdef ETXTBSY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1720 |
if (sym == @symbol(ETXTBSY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1721 |
RETURN ( __MKSMALLINT(ETXTBSY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1722 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1723 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1724 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1725 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1726 |
* some others |
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 |
#ifdef EWOULDBLOCK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1729 |
if (sym == @symbol(EWOULDBLOCK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1730 |
RETURN ( __MKSMALLINT(EWOULDBLOCK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1731 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1732 |
#endif |
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 |
#ifdef ENOMSG |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1735 |
if (sym == @symbol(ENOMSG)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1736 |
RETURN ( __MKSMALLINT(ENOMSG) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1737 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1738 |
#endif |
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 |
#ifdef ELOOP |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1741 |
if (sym == @symbol(ELOOP)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1742 |
RETURN ( __MKSMALLINT(ELOOP) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1743 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1744 |
#endif |
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 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1747 |
* some stream errors |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1748 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1749 |
#ifdef ETIME |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1750 |
if (sym == @symbol(ETIME)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1751 |
RETURN ( __MKSMALLINT(ETIME) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1752 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1753 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1754 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1755 |
#ifdef ENOSR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1756 |
if (sym == @symbol(ENOSR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1757 |
RETURN ( __MKSMALLINT(ENOSR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1758 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1759 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1760 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1761 |
#ifdef ENOSTR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1762 |
if (sym == @symbol(ENOSTR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1763 |
RETURN ( __MKSMALLINT(ENOSTR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1764 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1765 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1766 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1767 |
#ifdef ECOMM |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1768 |
if (sym == @symbol(ECOMM)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1769 |
RETURN ( __MKSMALLINT(ECOMM) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1770 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1771 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1772 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1773 |
#ifdef EPROTO |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1774 |
if (sym == @symbol(EPROTO)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1775 |
RETURN ( __MKSMALLINT(EPROTO) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1776 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1777 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1778 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1779 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1780 |
* nfs errors |
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 |
#ifdef ESTALE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1783 |
if (sym == @symbol(ESTALE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1784 |
RETURN ( __MKSMALLINT(ESTALE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1785 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1786 |
#endif |
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 |
#ifdef EREMOTE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1789 |
if (sym == @symbol(EREMOTE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1790 |
RETURN ( __MKSMALLINT(EREMOTE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1791 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1792 |
#endif |
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 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1795 |
* some networking errors |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1796 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1797 |
#ifdef EINPROGRESS |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1798 |
if (sym == @symbol(EINPROGRESS)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1799 |
RETURN ( __MKSMALLINT(EINPROGRESS) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1800 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1801 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1802 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1803 |
#ifdef EALREADY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1804 |
if (sym == @symbol(EALREADY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1805 |
RETURN ( __MKSMALLINT(EALREADY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1806 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1807 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1808 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1809 |
#ifdef ENOTSOCK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1810 |
if (sym == @symbol(ENOTSOCK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1811 |
RETURN ( __MKSMALLINT(ENOTSOCK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1812 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1813 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1814 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1815 |
#ifdef EDESTADDRREQ |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1816 |
if (sym == @symbol(EDESTADDRREQ)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1817 |
RETURN ( __MKSMALLINT(EDESTADDRREQ) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1818 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1819 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1820 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1821 |
#ifdef EMSGSIZE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1822 |
if (sym == @symbol(EMSGSIZE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1823 |
RETURN ( __MKSMALLINT(EMSGSIZE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1824 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1825 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1826 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1827 |
#ifdef EPROTOTYPE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1828 |
if (sym == @symbol(EPROTOTYPE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1829 |
RETURN ( __MKSMALLINT(EPROTOTYPE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1830 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1831 |
#endif |
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 |
#ifdef ENOPROTOOPT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1834 |
if (sym == @symbol(ENOPROTOOPT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1835 |
RETURN ( __MKSMALLINT(ENOPROTOOPT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1836 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1837 |
#endif |
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 |
#ifdef EPROTONOSUPPORT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1840 |
if (sym == @symbol(EPROTONOSUPPORT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1841 |
RETURN ( __MKSMALLINT(EPROTONOSUPPORT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1842 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1843 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1844 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1845 |
#ifdef ESOCKTNOSUPPORT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1846 |
if (sym == @symbol(ESOCKTNOSUPPORT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1847 |
RETURN ( __MKSMALLINT(ESOCKTNOSUPPORT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1848 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1849 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1850 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1851 |
#ifdef EOPNOTSUPP |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1852 |
if (sym == @symbol(EOPNOTSUPP)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1853 |
RETURN ( __MKSMALLINT(EOPNOTSUPP) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1854 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1855 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1856 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1857 |
#ifdef EPFNOSUPPORT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1858 |
if (sym == @symbol(EPFNOSUPPORT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1859 |
RETURN ( __MKSMALLINT(EPFNOSUPPORT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1860 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1861 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1862 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1863 |
#ifdef EAFNOSUPPORT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1864 |
if (sym == @symbol(EAFNOSUPPORT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1865 |
RETURN ( __MKSMALLINT(EAFNOSUPPORT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1866 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1867 |
#endif |
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 |
#ifdef EADDRINUSE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1870 |
if (sym == @symbol(EADDRINUSE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1871 |
RETURN ( __MKSMALLINT(EADDRINUSE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1872 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1873 |
#endif |
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 |
#ifdef EADDRNOTAVAIL |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1876 |
if (sym == @symbol(EADDRNOTAVAIL)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1877 |
RETURN ( __MKSMALLINT(EADDRNOTAVAIL) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1878 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1879 |
#endif |
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 |
#ifdef ETIMEDOUT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1882 |
if (sym == @symbol(ETIMEDOUT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1883 |
RETURN ( __MKSMALLINT(ETIMEDOUT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1884 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1885 |
#endif |
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 |
#ifdef ECONNREFUSED |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1888 |
if (sym == @symbol(ECONNREFUSED)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1889 |
RETURN ( __MKSMALLINT(ECONNREFUSED) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1890 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1891 |
#endif |
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 |
#ifdef ENETDOWN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1894 |
if (sym == @symbol(ENETDOWN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1895 |
RETURN ( __MKSMALLINT(ENETDOWN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1896 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1897 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1898 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1899 |
#ifdef ENETUNREACH |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1900 |
if (sym == @symbol(ENETUNREACH)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1901 |
RETURN ( __MKSMALLINT(ENETUNREACH) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1902 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1903 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1904 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1905 |
#ifdef ENETRESET |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1906 |
if (sym == @symbol(ENETRESET)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1907 |
RETURN ( __MKSMALLINT(ENETRESET) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1908 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1909 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1910 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1911 |
#ifdef ECONNABORTED |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1912 |
if (sym == @symbol(ECONNABORTED)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1913 |
RETURN ( __MKSMALLINT(ECONNABORTED) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1914 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1915 |
#endif |
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 |
#ifdef ECONNRESET |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1918 |
if (sym == @symbol(ECONNRESET)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1919 |
RETURN ( __MKSMALLINT(ECONNRESET) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1920 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1921 |
#endif |
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 |
#ifdef EISCONN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1924 |
if (sym == @symbol(EISCONN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1925 |
RETURN ( __MKSMALLINT(EISCONN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1926 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1927 |
#endif |
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 |
#ifdef ENOTCONN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1930 |
if (sym == @symbol(ENOTCONN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1931 |
RETURN ( __MKSMALLINT(ENOTCONN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1932 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1933 |
#endif |
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 |
#ifdef ESHUTDOWN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1936 |
if (sym == @symbol(ESHUTDOWN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1937 |
RETURN ( __MKSMALLINT(ESHUTDOWN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1938 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1939 |
#endif |
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 |
#ifdef EHOSTDOWN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1942 |
if (sym == @symbol(EHOSTDOWN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1943 |
RETURN ( __MKSMALLINT(EHOSTDOWN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1944 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1945 |
#endif |
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 |
#ifdef EHOSTUNREACH |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1948 |
if (sym == @symbol(EHOSTUNREACH)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1949 |
RETURN ( __MKSMALLINT(EHOSTUNREACH) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1950 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1951 |
#endif |
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 |
^ -1 |
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 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1956 |
errorSymbolAndTextForNumber:errNr |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1957 |
"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
|
1958 |
(as returned by a system call). |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1959 |
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
|
1960 |
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
|
1961 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1962 |
|sym text| |
1 | 1963 |
|
77 | 1964 |
%{ |
1965 |
/* claus: |
|
1966 |
* I made this some primitive code, since errnos are not |
|
1967 |
* standard across unixes |
|
1968 |
*/ |
|
1969 |
char *msg = "unknown error"; |
|
1970 |
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
|
1971 |
OBJ eno = errNr; |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1972 |
|
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1973 |
if (__isSmallInteger(eno)) { |
1135 | 1974 |
switch (__intVal(eno)) { |
185 | 1975 |
/* |
1976 |
* POSIX errnos - these should be defined |
|
1977 |
*/ |
|
443 | 1978 |
#ifdef EPERM |
185 | 1979 |
case EPERM: |
1980 |
msg = "Operation not permitted"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1981 |
sym = @symbol(EPERM); |
185 | 1982 |
break; |
443 | 1983 |
#endif |
1984 |
#ifdef ENOENT |
|
185 | 1985 |
case ENOENT: |
1986 |
msg = "No such file or directory"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1987 |
sym = @symbol(ENOENT); |
185 | 1988 |
break; |
443 | 1989 |
#endif |
1990 |
#ifdef ESRCH |
|
185 | 1991 |
case ESRCH: |
1992 |
msg = "No such process"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1993 |
sym = @symbol(ESRCH); |
185 | 1994 |
break; |
443 | 1995 |
#endif |
1996 |
#ifdef EINTR |
|
185 | 1997 |
case EINTR: |
1998 |
msg = "Interrupted system call"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1999 |
sym = @symbol(EINTR); |
185 | 2000 |
break; |
443 | 2001 |
#endif |
2002 |
#ifdef EIO |
|
185 | 2003 |
case EIO: |
2004 |
msg = "I/O error"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2005 |
sym = @symbol(EIO); |
185 | 2006 |
break; |
443 | 2007 |
#endif |
2008 |
#ifdef ENXIO |
|
185 | 2009 |
case ENXIO: |
2010 |
msg = "No such device or address"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2011 |
sym = @symbol(ENXIO); |
185 | 2012 |
break; |
443 | 2013 |
#endif |
2014 |
#ifdef E2BIG |
|
185 | 2015 |
case E2BIG: |
2016 |
msg = "Arg list too long"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2017 |
sym = @symbol(E2BIG); |
185 | 2018 |
break; |
443 | 2019 |
#endif |
2020 |
#ifdef ENOEXEC |
|
185 | 2021 |
case ENOEXEC: |
2022 |
msg = "Exec format error"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2023 |
sym = @symbol(ENOEXEC); |
185 | 2024 |
break; |
443 | 2025 |
#endif |
2026 |
#ifdef EBADF |
|
185 | 2027 |
case EBADF: |
2028 |
msg = "Bad file number"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2029 |
sym = @symbol(EBADF); |
185 | 2030 |
break; |
443 | 2031 |
#endif |
2032 |
#ifdef ECHILD |
|
185 | 2033 |
case ECHILD: |
2034 |
msg = "No child processes"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2035 |
sym = @symbol(ECHILD); |
185 | 2036 |
break; |
443 | 2037 |
#endif |
77 | 2038 |
#if !defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN) |
185 | 2039 |
case EAGAIN: |
2040 |
msg = "Try again"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2041 |
sym = @symbol(EAGAIN); |
185 | 2042 |
break; |
77 | 2043 |
#endif |
443 | 2044 |
#ifdef ENOMEM |
185 | 2045 |
case ENOMEM: |
2046 |
msg = "Out of memory"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2047 |
sym = @symbol(ENOMEM); |
185 | 2048 |
break; |
443 | 2049 |
#endif |
2050 |
#ifdef EACCES |
|
185 | 2051 |
case EACCES: |
2052 |
msg = "Permission denied"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2053 |
sym = @symbol(EACCES); |
185 | 2054 |
break; |
443 | 2055 |
#endif |
2056 |
#ifdef EFAULT |
|
185 | 2057 |
case EFAULT: |
2058 |
msg = "Bad address"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2059 |
sym = @symbol(EFAULT); |
185 | 2060 |
break; |
443 | 2061 |
#endif |
2062 |
#ifdef EBUSY |
|
185 | 2063 |
case EBUSY: |
2064 |
msg = "Device or resource busy"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2065 |
sym = @symbol(EBUSY); |
185 | 2066 |
break; |
443 | 2067 |
#endif |
2068 |
#ifdef EEXIST |
|
185 | 2069 |
case EEXIST: |
2070 |
msg = "File exists"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2071 |
sym = @symbol(EEXIST); |
185 | 2072 |
break; |
443 | 2073 |
#endif |
2074 |
#ifdef EXDEV |
|
185 | 2075 |
case EXDEV: |
2076 |
msg = "Cross-device link"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2077 |
sym = @symbol(EXDEV); |
185 | 2078 |
break; |
443 | 2079 |
#endif |
2080 |
#ifdef ENODEV |
|
185 | 2081 |
case ENODEV: |
2082 |
msg = "No such device"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2083 |
sym = @symbol(ENODEV); |
185 | 2084 |
break; |
443 | 2085 |
#endif |
2086 |
#ifdef ENOTDIR |
|
185 | 2087 |
case ENOTDIR: |
2088 |
msg = "Not a directory"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2089 |
sym = @symbol(ENOTDIR); |
185 | 2090 |
break; |
443 | 2091 |
#endif |
2092 |
#ifdef EISDIR |
|
185 | 2093 |
case EISDIR: |
2094 |
msg = "Is a directory"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2095 |
sym = @symbol(EISDIR); |
185 | 2096 |
break; |
443 | 2097 |
#endif |
2098 |
#ifdef EINVAL |
|
185 | 2099 |
case EINVAL: |
2100 |
msg = "Invalid argument"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2101 |
sym = @symbol(EINVAL); |
185 | 2102 |
break; |
443 | 2103 |
#endif |
2104 |
#ifdef ENFILE |
|
185 | 2105 |
case ENFILE: |
2106 |
msg = "File table overflow"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2107 |
sym = @symbol(ENFILE); |
185 | 2108 |
break; |
443 | 2109 |
#endif |
2110 |
#ifdef EMFILE |
|
185 | 2111 |
case EMFILE: |
2112 |
msg = "Too many open files"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2113 |
sym = @symbol(EMFILE); |
185 | 2114 |
break; |
443 | 2115 |
#endif |
2116 |
#ifdef ENOTTY |
|
185 | 2117 |
case ENOTTY: |
2118 |
msg = "Not a typewriter"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2119 |
sym = @symbol(ENOTTY); |
185 | 2120 |
break; |
443 | 2121 |
#endif |
2122 |
#ifdef EFBIG |
|
185 | 2123 |
case EFBIG: |
2124 |
msg = "File too large"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2125 |
sym = @symbol(EFBIG); |
185 | 2126 |
break; |
443 | 2127 |
#endif |
2128 |
#ifdef ENOSPC |
|
185 | 2129 |
case ENOSPC: |
2130 |
msg = "No space left on device"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2131 |
sym = @symbol(ENOSPC); |
185 | 2132 |
break; |
443 | 2133 |
#endif |
2134 |
#ifdef ESPIPE |
|
185 | 2135 |
case ESPIPE: |
2136 |
msg = "Illegal seek"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2137 |
sym = @symbol(ESPIPE); |
185 | 2138 |
break; |
443 | 2139 |
#endif |
2140 |
#ifdef EROFS |
|
185 | 2141 |
case EROFS: |
2142 |
msg = "Read-only file system"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2143 |
sym = @symbol(EROFS); |
185 | 2144 |
break; |
443 | 2145 |
#endif |
2146 |
#ifdef EMLINK |
|
185 | 2147 |
case EMLINK: |
2148 |
msg = "Too many links"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2149 |
sym = @symbol(EMLINK); |
185 | 2150 |
break; |
443 | 2151 |
#endif |
2152 |
#ifdef EPIPE |
|
185 | 2153 |
case EPIPE: |
2154 |
msg = "Broken pipe"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2155 |
sym = @symbol(EPIPE); |
185 | 2156 |
break; |
443 | 2157 |
#endif |
2158 |
#ifdef EDOM |
|
185 | 2159 |
case EDOM: |
2160 |
msg = "Math argument out of domain"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2161 |
sym = @symbol(EDOM); |
185 | 2162 |
break; |
443 | 2163 |
#endif |
2164 |
#ifdef ERANGE |
|
185 | 2165 |
case ERANGE: |
2166 |
msg = "Math result not representable"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2167 |
sym = @symbol(ERANGE); |
185 | 2168 |
break; |
443 | 2169 |
#endif |
77 | 2170 |
#ifdef EDEADLK |
308 | 2171 |
# if EDEADLK != EWOULDBLOCK |
185 | 2172 |
case EDEADLK: |
2173 |
msg = "Resource deadlock would occur"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2174 |
sym = @symbol(EDEADLK); |
185 | 2175 |
break; |
308 | 2176 |
# endif |
77 | 2177 |
#endif |
2178 |
#ifdef ENAMETOOLONG |
|
185 | 2179 |
case ENAMETOOLONG: |
2180 |
msg = "File name too long"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2181 |
sym = @symbol(ENAMETOOLONG); |
185 | 2182 |
break; |
77 | 2183 |
#endif |
2184 |
#ifdef ENOLCK |
|
185 | 2185 |
case ENOLCK: |
2186 |
msg = "No record locks available"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2187 |
sym = @symbol(ENOLCK); |
185 | 2188 |
break; |
77 | 2189 |
#endif |
2190 |
#ifdef ENOSYS |
|
185 | 2191 |
case ENOSYS: |
2192 |
msg = "Function not implemented"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2193 |
sym = @symbol(ENOSYS); |
185 | 2194 |
break; |
77 | 2195 |
#endif |
359 | 2196 |
#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST) |
185 | 2197 |
case ENOTEMPTY: |
2198 |
msg = "Directory not empty"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2199 |
sym = @symbol(ENOTEMPTY); |
185 | 2200 |
break; |
77 | 2201 |
#endif |
2202 |
#ifdef EILSEQ |
|
185 | 2203 |
case EILSEQ: |
2204 |
msg = "Illegal byte sequence"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2205 |
sym = @symbol(EILSEQ); |
185 | 2206 |
break; |
77 | 2207 |
#endif |
185 | 2208 |
/* |
2209 |
* XPG3 errnos - defined on most systems |
|
2210 |
*/ |
|
77 | 2211 |
#ifdef ENOTBLK |
185 | 2212 |
case ENOTBLK: |
2213 |
msg = "Block device required"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2214 |
sym = @symbol(ENOTBLK); |
185 | 2215 |
break; |
77 | 2216 |
#endif |
2217 |
#ifdef ETXTBSY |
|
185 | 2218 |
case ETXTBSY: |
2219 |
msg = "Text file busy"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2220 |
sym = @symbol(ETXTBSY); |
185 | 2221 |
break; |
77 | 2222 |
#endif |
185 | 2223 |
/* |
2224 |
* some others |
|
2225 |
*/ |
|
77 | 2226 |
#ifdef EWOULDBLOCK |
185 | 2227 |
case EWOULDBLOCK: |
2228 |
msg = "Operation would block"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2229 |
sym = @symbol(EWOULDBLOCK); |
185 | 2230 |
break; |
77 | 2231 |
#endif |
2232 |
#ifdef ENOMSG |
|
185 | 2233 |
case ENOMSG: |
2234 |
msg = "No message of desired type"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2235 |
sym = @symbol(ENOMSG); |
185 | 2236 |
break; |
77 | 2237 |
#endif |
2238 |
#ifdef ELOOP |
|
185 | 2239 |
case ELOOP: |
2240 |
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
|
2241 |
sym = @symbol(ELOOP); |
185 | 2242 |
break; |
77 | 2243 |
#endif |
2244 |
||
185 | 2245 |
/* |
2246 |
* some stream errors |
|
2247 |
*/ |
|
77 | 2248 |
#ifdef ETIME |
185 | 2249 |
case ETIME: |
2250 |
msg = "Timer expired"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2251 |
sym = @symbol(ETIME); |
185 | 2252 |
break; |
77 | 2253 |
#endif |
2254 |
#ifdef ENOSR |
|
185 | 2255 |
case ENOSR: |
2256 |
msg = "Out of streams resources"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2257 |
sym = @symbol(ENOSR); |
185 | 2258 |
break; |
77 | 2259 |
#endif |
2260 |
#ifdef ENOSTR |
|
185 | 2261 |
case ENOSTR: |
2262 |
msg = "Device not a stream"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2263 |
sym = @symbol(ENOSTR); |
185 | 2264 |
break; |
77 | 2265 |
#endif |
2266 |
#ifdef ECOMM |
|
185 | 2267 |
case ECOMM: |
2268 |
msg = "Communication error on send"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2269 |
sym = @symbol(ECOMM); |
185 | 2270 |
break; |
77 | 2271 |
#endif |
2272 |
#ifdef EPROTO |
|
185 | 2273 |
case EPROTO: |
2274 |
msg = "Protocol error"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2275 |
sym = @symbol(EPROTO); |
185 | 2276 |
break; |
77 | 2277 |
#endif |
185 | 2278 |
/* |
2279 |
* nfs errors |
|
2280 |
*/ |
|
77 | 2281 |
#ifdef ESTALE |
185 | 2282 |
case ESTALE: |
2283 |
msg = "Stale NFS file handle"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2284 |
sym = @symbol(ESTALE); |
185 | 2285 |
break; |
77 | 2286 |
#endif |
2287 |
#ifdef EREMOTE |
|
185 | 2288 |
case EREMOTE: |
2289 |
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
|
2290 |
sym = @symbol(EREMOTE); |
185 | 2291 |
break; |
77 | 2292 |
#endif |
185 | 2293 |
/* |
2294 |
* some networking errors |
|
2295 |
*/ |
|
77 | 2296 |
#ifdef EINPROGRESS |
185 | 2297 |
case EINPROGRESS: |
2298 |
msg = "Operation now in progress"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2299 |
sym = @symbol(EINPROGRESS); |
185 | 2300 |
break; |
77 | 2301 |
#endif |
2302 |
#ifdef EALREADY |
|
185 | 2303 |
case EALREADY: |
2304 |
msg = "Operation already in progress"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2305 |
sym = @symbol(EALREADY); |
185 | 2306 |
break; |
77 | 2307 |
#endif |
2308 |
#ifdef ENOTSOCK |
|
185 | 2309 |
case ENOTSOCK: |
2310 |
msg = "Socket operation on non-socket"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2311 |
sym = @symbol(ENOTSOCK); |
185 | 2312 |
break; |
77 | 2313 |
#endif |
2314 |
#ifdef EDESTADDRREQ |
|
185 | 2315 |
case EDESTADDRREQ: |
2316 |
msg = "Destination address required"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2317 |
sym = @symbol(EDESTADDRREQ); |
185 | 2318 |
break; |
77 | 2319 |
#endif |
2320 |
#ifdef EMSGSIZE |
|
185 | 2321 |
case EMSGSIZE: |
2322 |
msg = "Message too long"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2323 |
sym = @symbol(EMSGSIZE); |
185 | 2324 |
break; |
77 | 2325 |
#endif |
2326 |
#ifdef EPROTOTYPE |
|
185 | 2327 |
case EPROTOTYPE: |
2328 |
msg = "Protocol wrong type for socket"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2329 |
sym = @symbol(EPROTOTYPE); |
185 | 2330 |
break; |
77 | 2331 |
#endif |
2332 |
#ifdef ENOPROTOOPT |
|
185 | 2333 |
case ENOPROTOOPT: |
2334 |
msg = "Protocol not available"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2335 |
sym = @symbol(ENOPROTOOPT); |
185 | 2336 |
break; |
77 | 2337 |
#endif |
2338 |
#ifdef EPROTONOSUPPORT |
|
185 | 2339 |
case EPROTONOSUPPORT: |
2340 |
msg = "Protocol not supported"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2341 |
sym = @symbol(EPROTONOSUPPORT); |
185 | 2342 |
break; |
77 | 2343 |
#endif |
2344 |
#ifdef ESOCKTNOSUPPORT |
|
185 | 2345 |
case ESOCKTNOSUPPORT: |
2346 |
msg = "Socket type not supported"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2347 |
sym = @symbol(ESOCKTNOSUPPORT); |
185 | 2348 |
break; |
77 | 2349 |
#endif |
2350 |
#ifdef EOPNOTSUPP |
|
185 | 2351 |
case EOPNOTSUPP: |
2352 |
msg = "Operation not supported on socket"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2353 |
sym = @symbol(EOPNOTSUPP); |
185 | 2354 |
break; |
77 | 2355 |
#endif |
2356 |
#ifdef EPFNOSUPPORT |
|
185 | 2357 |
case EPFNOSUPPORT: |
2358 |
msg = "Protocol family not supported"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2359 |
sym = @symbol(EPFNOSUPPORT); |
185 | 2360 |
break; |
77 | 2361 |
#endif |
2362 |
#ifdef EAFNOSUPPORT |
|
185 | 2363 |
case EAFNOSUPPORT: |
2364 |
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
|
2365 |
sym = @symbol(EAFNOSUPPORT); |
185 | 2366 |
break; |
77 | 2367 |
#endif |
2368 |
#ifdef EADDRINUSE |
|
185 | 2369 |
case EADDRINUSE: |
2370 |
msg = "Address already in use"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2371 |
sym = @symbol(EADDRINUSE); |
185 | 2372 |
break; |
77 | 2373 |
#endif |
2374 |
#ifdef EADDRNOTAVAIL |
|
185 | 2375 |
case EADDRNOTAVAIL: |
2376 |
msg = "Can\'t assign requested address"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2377 |
sym = @symbol(EADDRNOTAVAIL); |
185 | 2378 |
break; |
77 | 2379 |
#endif |
2380 |
#ifdef ETIMEDOUT |
|
185 | 2381 |
case ETIMEDOUT: |
2382 |
msg = "Connection timed out"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2383 |
sym = @symbol(ETIMEDOUT); |
185 | 2384 |
break; |
77 | 2385 |
#endif |
2386 |
#ifdef ECONNREFUSED |
|
185 | 2387 |
case ECONNREFUSED: |
2388 |
msg = "Connection refused"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2389 |
sym = @symbol(ECONNREFUSED); |
185 | 2390 |
break; |
77 | 2391 |
#endif |
362 | 2392 |
#ifdef ENETDOWN |
2393 |
case ENETDOWN: |
|
2394 |
msg = "Network is down"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2395 |
sym = @symbol(ENETDOWN); |
362 | 2396 |
break; |
2397 |
#endif |
|
2398 |
#ifdef ENETUNREACH |
|
2399 |
case ENETUNREACH: |
|
2400 |
msg = "Network is unreachable"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2401 |
sym = @symbol(ENETUNREACH); |
362 | 2402 |
break; |
2403 |
#endif |
|
2404 |
#ifdef ENETRESET |
|
2405 |
case ENETRESET: |
|
2406 |
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
|
2407 |
sym = @symbol(ENETRESET); |
362 | 2408 |
break; |
2409 |
#endif |
|
2410 |
#ifdef ECONNABORTED |
|
2411 |
case ECONNABORTED: |
|
2412 |
msg = "Software caused connection abort"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2413 |
sym = @symbol(ECONNABORTED); |
362 | 2414 |
break; |
2415 |
#endif |
|
2416 |
#ifdef ECONNRESET |
|
2417 |
case ECONNRESET: |
|
2418 |
msg = "Connection reset by peer"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2419 |
sym = @symbol(ECONNRESET); |
362 | 2420 |
break; |
2421 |
#endif |
|
2422 |
#ifdef EISCONN |
|
2423 |
case EISCONN: |
|
2424 |
msg = "Socket is already connected"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2425 |
sym = @symbol(EISCONN); |
362 | 2426 |
break; |
2427 |
#endif |
|
2428 |
#ifdef ENOTCONN |
|
2429 |
case ENOTCONN: |
|
2430 |
msg = "Socket is not connected"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2431 |
sym = @symbol(ENOTCONN); |
362 | 2432 |
break; |
2433 |
#endif |
|
2434 |
#ifdef ESHUTDOWN |
|
2435 |
case ESHUTDOWN: |
|
2436 |
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
|
2437 |
sym = @symbol(ESHUTDOWN); |
362 | 2438 |
break; |
2439 |
#endif |
|
2440 |
#ifdef EHOSTDOWN |
|
2441 |
case EHOSTDOWN: |
|
2442 |
msg = "Host is down"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2443 |
sym = @symbol(EHOSTDOWN); |
362 | 2444 |
break; |
2445 |
#endif |
|
2446 |
#ifdef EHOSTUNREACH |
|
2447 |
case EHOSTUNREACH: |
|
2448 |
msg = "No route to host"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2449 |
sym = @symbol(EHOSTUNREACH); |
362 | 2450 |
break; |
2451 |
#endif |
|
2452 |
||
185 | 2453 |
default: |
368 | 2454 |
{ |
809
5eef87c2907b
e convenient macro for register saving (sparc only)
Claus Gittinger <cg@exept.de>
parents:
805
diff
changeset
|
2455 |
__BEGIN_PROTECT_REGISTERS__ |
1135 | 2456 |
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
|
2457 |
__END_PROTECT_REGISTERS__ |
368 | 2458 |
} |
185 | 2459 |
msg = buffer; |
2460 |
break; |
|
2461 |
} |
|
77 | 2462 |
} |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2463 |
text = __MKSTRING(msg); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2464 |
%}. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2465 |
^ Array with:sym with:text |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2466 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2467 |
" |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2468 |
OperatingSystem errorSymbolAndTextForNumber:4 |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2469 |
" |
616 | 2470 |
! |
2471 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2472 |
errorSymbolForNumber:errNr |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2473 |
"return a symbol for a unix errorNumber |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2474 |
(as returned by a system call)." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2475 |
|
1153
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
2476 |
^ (self errorSymbolAndTextForNumber:errNr) at:1 |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2477 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2478 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2479 |
OperatingSystem errorTextForNumber:4 |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2480 |
" |
1153
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
2481 |
|
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
2482 |
"Modified: 12.4.1996 / 09:16:29 / stefan" |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2483 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2484 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2485 |
errorTextForNumber:errNr |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2486 |
"return a message string from a unix errorNumber |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2487 |
(as returned by a system call). |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2488 |
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
|
2489 |
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
|
2490 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2491 |
^ (self errorSymbolAndTextForNumber:errNr) at:2 |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2492 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2493 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2494 |
OperatingSystem errorTextForNumber:4 |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2495 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2496 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2497 |
|
616 | 2498 |
lastErrorNumber |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2499 |
"return the last errors number. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2500 |
See also: #lastErrorSymbol and #lastErrorString. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2501 |
Notice: having a single error number is a bad idea in a multithreaded |
1487 | 2502 |
environment - this interface will change." |
616 | 2503 |
|
2504 |
^ LastErrorNumber |
|
2505 |
||
2506 |
" |
|
2507 |
OperatingSystem lastErrorNumber |
|
2508 |
" |
|
2509 |
! |
|
2510 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2511 |
lastErrorString |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2512 |
"return a message string describing the last error. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2513 |
See also: #lastErrorNumber and #lastErrorSymbol. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2514 |
Notice: having a single error number is a bad idea in a multithreaded |
1487 | 2515 |
environment - this interface will change." |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2516 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2517 |
^ self errorTextForNumber:LastErrorNumber |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2518 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2519 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2520 |
OperatingSystem lastErrorString |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2521 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2522 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2523 |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2524 |
lastErrorSymbol |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2525 |
"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
|
2526 |
See also: #lastErrorNumber and #lastErrorString. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2527 |
Notice: having a single error number is a bad idea in a multithreaded |
1487 | 2528 |
environment - this interface will change." |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2529 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2530 |
^ self errorSymbolForNumber:LastErrorNumber |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2531 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2532 |
" |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2533 |
OperatingSystem lastErrorSymbol |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2534 |
" |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2535 |
! |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2536 |
|
616 | 2537 |
lastExecStatus |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2538 |
"return the last execution status. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2539 |
Notice: having a single error number is a bad idea in a multithreaded |
1487 | 2540 |
environment - this interface will change." |
616 | 2541 |
|
2542 |
^ LastExecStatus |
|
2543 |
||
2544 |
" |
|
2545 |
OperatingSystem lastExecStatus |
|
2546 |
" |
|
1 | 2547 |
! ! |
2548 |
||
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
2549 |
!OperatingSystem class methodsFor:'executing OS commands'! |
616 | 2550 |
|
2551 |
canExecuteCommand:aCommandString |
|
2552 |
"return true, if the OS can execute aCommand." |
|
2553 |
||
2554 |
|cmd| |
|
2555 |
||
2556 |
cmd := aCommandString asCollectionOfWords first. |
|
2557 |
^ (self pathOfCommand:cmd) notNil |
|
2558 |
||
2559 |
" |
|
2560 |
OperatingSystem canExecuteCommand:'fooBar' |
|
2561 |
OperatingSystem canExecuteCommand:'ls' |
|
2562 |
OperatingSystem canExecuteCommand:'cvs' |
|
2563 |
" |
|
2564 |
||
2565 |
"Created: 4.11.1995 / 19:13:54 / cg" |
|
68 | 2566 |
! |
2567 |
||
616 | 2568 |
exec:aPath withArguments:argArray |
2569 |
"execute the unix command specified by the argument, aPath, with |
|
2570 |
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
|
2571 |
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
|
2572 |
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
|
2573 |
to another program." |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2574 |
|
792 | 2575 |
^ 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
|
2576 |
! |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2577 |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2578 |
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
|
2579 |
"Internal combined fork & exec; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2580 |
If fork is false: |
1487 | 2581 |
execute the unix command specified by the argument, aPath, with |
2582 |
arguments in argArray (no arguments, if nil). |
|
2583 |
If successful, this method does not return and smalltalk is gone. |
|
2584 |
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
|
2585 |
if its true: |
1487 | 2586 |
for a child to do the above. |
2587 |
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
|
2588 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2589 |
fdArray contains the filedescriptors, to be used for the child (if fork is true). |
1487 | 2590 |
fdArray[1] = 15 -> use fd 15 as stdin. |
2591 |
If an element of the array is set to nil, the corresponding filedescriptor |
|
2592 |
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
|
2593 |
|
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2594 |
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
|
2595 |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2596 |
If newPgrp is true, the subprocess will be established in a new process group. |
1487 | 2597 |
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
|
2598 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2599 |
Notice: this used to be two separate ST-methods; however, in order to use |
1487 | 2600 |
vfork on some machines, it had to be merged into one, to avoid write |
2601 |
accesses to ST/X memory from the vforked-child. The code below only does |
|
2602 |
read accesses." |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2603 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2604 |
%{ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2605 |
#ifndef MSDOS_LIKE |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2606 |
char **argv; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2607 |
int nargs, i, id; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2608 |
OBJ arg; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2609 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2610 |
if (__isString(aPath) && |
1487 | 2611 |
((argArray == nil) || __isArray(argArray)) && |
2612 |
((fdArray == nil) || __isArray(fdArray)) && |
|
2613 |
((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
|
2614 |
) { |
1487 | 2615 |
nargs = argArray == nil ? 0 : _arraySize(argArray); |
2616 |
argv = (char **) malloc(sizeof(char *) * (nargs + 1)); |
|
2617 |
if (argv) { |
|
2618 |
for (i=0; i < nargs; i++) { |
|
2619 |
arg = __ArrayInstPtr(argArray)->a_element[i]; |
|
2620 |
if (__isString(arg)) { |
|
2621 |
argv[i] = (char *) __stringVal(arg); |
|
2622 |
} else { |
|
2623 |
argv[i] = ""; |
|
2624 |
} |
|
2625 |
} |
|
2626 |
argv[i] = NULL; |
|
2627 |
||
2628 |
if (doFork == true) { |
|
2629 |
int nfd, nclose; |
|
2630 |
||
2631 |
nfd = fdArray == nil ? 0 : _arraySize(fdArray); |
|
2632 |
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
|
2633 |
#ifdef HAS_VFORK |
1487 | 2634 |
id = vfork(); |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2635 |
#else |
1487 | 2636 |
id = fork(); |
2637 |
#endif |
|
2638 |
if (id == 0) { |
|
2639 |
/* |
|
2640 |
** In child. |
|
2641 |
** first: dup filedescriptors |
|
2642 |
*/ |
|
2643 |
for (i = 0; i < nfd; i++) { |
|
2644 |
if (__isSmallInteger(__ArrayInstPtr(fdArray)->a_element[i]) && |
|
2645 |
__intVal(__ArrayInstPtr(fdArray)->a_element[i]) != i |
|
2646 |
) { |
|
2647 |
dup2(__intVal(__ArrayInstPtr(fdArray)->a_element[i]), i); |
|
2648 |
} |
|
2649 |
} |
|
2650 |
/* |
|
2651 |
** second: close unused filedescriptors |
|
2652 |
*/ |
|
2653 |
for (i = 0; i < nfd; i++) { |
|
2654 |
if (__ArrayInstPtr(fdArray)->a_element[i] == nil) { |
|
2655 |
close(i); |
|
2656 |
} |
|
2657 |
} |
|
2658 |
/* |
|
2659 |
** third: close filedescriptors |
|
2660 |
*/ |
|
2661 |
for (i = 0; i < nclose; i++) { |
|
2662 |
if (__isSmallInteger(__ArrayInstPtr(closeFdArray)->a_element[i])) { |
|
2663 |
close(__intVal(__ArrayInstPtr(closeFdArray)->a_element[i])); |
|
2664 |
} |
|
2665 |
} |
|
2666 |
if (newPgrp == true) { |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2667 |
#if defined(_POSIX_JOB_CONTROL) |
1487 | 2668 |
(void) setpgid(0, 0); |
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2669 |
#else |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2670 |
#if defined(BSD) |
1487 | 2671 |
(void) setpgrp(0); |
2672 |
#endif |
|
2673 |
#endif |
|
2674 |
} |
|
2675 |
||
2676 |
execv(__stringVal(aPath), argv); |
|
2677 |
/* should not be reached */ |
|
2678 |
_exit(127); /* POSIX 2 compatible exit value */ |
|
2679 |
} |
|
2680 |
/* |
|
2681 |
** In parent: succes or failure |
|
2682 |
*/ |
|
2683 |
free(argv); |
|
2684 |
RETURN (__MKSMALLINT(id)); |
|
2685 |
} else { |
|
2686 |
execv(__stringVal(aPath), argv); |
|
2687 |
/* |
|
2688 |
* should not be reached |
|
2689 |
* (well, it is, if you pass a wrong command-path) |
|
2690 |
*/ |
|
2691 |
free(argv); |
|
2692 |
RETURN ( false ); |
|
2693 |
} |
|
2694 |
} |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2695 |
} |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2696 |
#endif |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2697 |
%}. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2698 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2699 |
path-argument not string |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2700 |
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
|
2701 |
or malloc failed |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2702 |
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
|
2703 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2704 |
^ self primitiveFailed |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2705 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2706 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2707 |
|id| |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2708 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2709 |
id := OperatingSystem fork. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2710 |
id == 0 ifTrue:[ |
1487 | 2711 |
"I am the child" |
2712 |
OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp'). |
|
2713 |
"not reached" |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2714 |
] |
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 |
|id| |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2718 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2719 |
id := OperatingSystem fork. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2720 |
id == 0 ifTrue:[ |
1487 | 2721 |
"I am the child" |
2722 |
OperatingSystem exec:'/bin/sh' withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2'). |
|
2723 |
"not reached" |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2724 |
]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2725 |
id printNL. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2726 |
(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
|
2727 |
'killing ...' printNL. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2728 |
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
|
2729 |
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
|
2730 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2731 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2732 |
|
1076
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2733 |
exec:aPath withArguments:argArray fileDescriptors:fdArray fork:doFork |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2734 |
"Internal combined fork & exec; |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2735 |
If fork is false: |
1487 | 2736 |
execute the unix command specified by the argument, aPath, with |
2737 |
arguments in argArray (no arguments, if nil). |
|
2738 |
If successful, this method does not return and smalltalk is gone. |
|
2739 |
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
|
2740 |
if its true: |
1487 | 2741 |
for a child to do the above. |
2742 |
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
|
2743 |
|
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2744 |
fdArray contains the filedescriptors, to be used for the child (if fork is true). |
1487 | 2745 |
fdArray[1] = 15 -> use fd 15 as stdin. |
2746 |
If an element of the array is set to nil, the corresponding filedescriptor |
|
2747 |
will be closed for the child. |
|
1076
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2748 |
|
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2749 |
Notice: this used to be two separate ST-methods; however, in order to use |
1487 | 2750 |
vfork on some machines, it had to be merged into one, to avoid write |
2751 |
accesses to ST/X memory from the vforked-child. The code below only does |
|
2752 |
read accesses." |
|
1076
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2753 |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2754 |
^ 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
|
2755 |
|
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2756 |
"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
|
2757 |
! |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2758 |
|
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2759 |
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
|
2760 |
"Internal combined fork & exec; |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2761 |
If fork is false: |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2762 |
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
|
2763 |
arguments in argArray (no arguments, if nil). |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2764 |
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
|
2765 |
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
|
2766 |
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
|
2767 |
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
|
2768 |
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
|
2769 |
|
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2770 |
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
|
2771 |
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
|
2772 |
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
|
2773 |
read accesses." |
616 | 2774 |
|
2775 |
%{ |
|
792 | 2776 |
#ifndef MSDOS_LIKE |
616 | 2777 |
char **argv; |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2778 |
int nargs, i, id; |
616 | 2779 |
OBJ arg; |
2780 |
||
2781 |
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
|
2782 |
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
|
2783 |
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
|
2784 |
if (argv) { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2785 |
for (i=0; i < nargs; i++) { |
1135 | 2786 |
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
|
2787 |
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
|
2788 |
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
|
2789 |
} else { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2790 |
argv[i] = ""; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2791 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2792 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2793 |
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
|
2794 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2795 |
if (doFork == true) { |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2796 |
#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
|
2797 |
id = vfork(); |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2798 |
#else |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2799 |
id = fork(); |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2800 |
#endif |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2801 |
if (id == 0) { |
1135 | 2802 |
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
|
2803 |
/* 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
|
2804 |
_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
|
2805 |
} |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2806 |
free(argv); |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2807 |
RETURN (__MKSMALLINT(id)); |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2808 |
} else { |
1135 | 2809 |
execv(__stringVal(aPath), argv); |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2810 |
/* |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2811 |
* should not be reached |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2812 |
* (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
|
2813 |
*/ |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2814 |
free(argv); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2815 |
RETURN ( false ); |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2816 |
} |
616 | 2817 |
} |
2818 |
} |
|
792 | 2819 |
#endif |
616 | 2820 |
%}. |
2821 |
" |
|
792 | 2822 |
path-argument not string |
2823 |
or argArray not an array/nil |
|
2824 |
or malloc failed |
|
2825 |
or not supported by OS |
|
616 | 2826 |
" |
2827 |
^ self primitiveFailed |
|
2828 |
||
2829 |
" |
|
2830 |
|id| |
|
2831 |
||
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2832 |
id := OperatingSystem fork. |
616 | 2833 |
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
|
2834 |
"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
|
2835 |
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
|
2836 |
"not reached" |
616 | 2837 |
] |
2838 |
" |
|
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2839 |
" |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2840 |
|id| |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2841 |
|
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2842 |
id := OperatingSystem fork. |
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2843 |
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
|
2844 |
"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
|
2845 |
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
|
2846 |
"not reached" |
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2847 |
]. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2848 |
id printNL. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2849 |
(Delay forSeconds:3.5) wait. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2850 |
'killing ...' printNL. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2851 |
OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2852 |
OperatingSystem sendSignal:(OperatingSystem sigKILL) to:id |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2853 |
" |
616 | 2854 |
! |
2855 |
||
2856 |
executeCommand:aCommandString |
|
2857 |
"execute the unix command specified by the argument, aCommandString. |
|
676 | 2858 |
The commandString is passed to a shell for execution - see the description of |
2859 |
'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
|
2860 |
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
|
2861 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2862 |
" when all machines have been checked, this will be defined as: |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2863 |
^ self executeCommand:aCommandString onError:[:status| false] |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2864 |
until then:" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2865 |
|
616 | 2866 |
%{ |
2867 |
int status; |
|
2868 |
||
2869 |
if (__isString(aCommandString)) { |
|
2870 |
/* |
|
2871 |
* ST/X provides a modified (fixed) implementation of the |
|
2872 |
* system() libc-function, which is interruptable ... |
|
2873 |
*/ |
|
2874 |
# ifdef WANT_SYSTEM |
|
1135 | 2875 |
status = mySystem((char *) __stringVal(aCommandString)); |
616 | 2876 |
# else |
1135 | 2877 |
status = system((char *) __stringVal(aCommandString)); |
616 | 2878 |
# endif |
1135 | 2879 |
OperatingSystem_LastExecStatus = __MKSMALLINT(status); |
616 | 2880 |
if (status == 0) { |
2881 |
RETURN ( true ); |
|
2882 |
} |
|
1135 | 2883 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 2884 |
RETURN ( false ); |
2885 |
} |
|
2886 |
%}. |
|
792 | 2887 |
"/ |
2888 |
"/ invalid argument (non-string) |
|
2889 |
"/ |
|
2890 |
^ self primitiveFailed |
|
616 | 2891 |
|
2892 |
" |
|
805 | 2893 |
OperatingSystem executeCommand:'sleep 30'. |
616 | 2894 |
OperatingSystem executeCommand:'pwd'. |
2895 |
OperatingSystem executeCommand:'ls -l'. |
|
2896 |
OperatingSystem executeCommand:'invalidCommand'. |
|
2897 |
OperatingSystem executeCommand:'rm /tmp/foofoofoofoo'. |
|
2898 |
" |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2899 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2900 |
"Modified: 27.12.1995 / 23:40:35 / stefan" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2901 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2902 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2903 |
executeCommand:aCommandString onError:aBlock |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2904 |
"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
|
2905 |
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
|
2906 |
'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
|
2907 |
Return true if successful. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2908 |
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
|
2909 |
as argument." |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2910 |
|
1034 | 2911 |
|pid exitStatus sema| |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2912 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2913 |
sema := Semaphore new. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2914 |
|
1034 | 2915 |
[ |
1487 | 2916 |
pid := self startProcess:aCommandString. |
2917 |
pid > 0 ifTrue:[ |
|
2918 |
Processor monitorPid:pid action:[:status | |
|
2919 |
status stillAlive ifFalse:[ |
|
2920 |
exitStatus := status. |
|
2921 |
sema signal |
|
2922 |
]. |
|
2923 |
]. |
|
2924 |
sema wait. |
|
2925 |
] ifFalse:[ |
|
2926 |
exitStatus := OSProcessStatus processCreationFailure. |
|
2927 |
]. |
|
1034 | 2928 |
] valueUninterruptably. |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2929 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2930 |
exitStatus success ifFalse:[ |
1487 | 2931 |
^ aBlock value:exitStatus |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2932 |
]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2933 |
^ true. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2934 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2935 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2936 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2937 |
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
|
2938 |
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
|
2939 |
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
|
2940 |
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
|
2941 |
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
|
2942 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2943 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2944 |
"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
|
2945 |
"Modified: 28.12.1995 / 15:25:48 / stefan" |
1034 | 2946 |
"Modified: 28.2.1996 / 21:41:23 / cg" |
616 | 2947 |
! |
2948 |
||
2949 |
fork |
|
2950 |
"fork a new (HEAVY-weight) unix process. |
|
2951 |
Dont confuse this with Block>>fork, which creates |
|
2952 |
lightweight smalltalk processes. This method will return |
|
676 | 2953 |
0 to the child process, and a non-zero number (which is the childs |
2954 |
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
|
2955 |
|
676 | 2956 |
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
|
2957 |
#startProcess: and #executCommand: for higher level interfaces." |
68 | 2958 |
|
2959 |
%{ /* NOCONTEXT */ |
|
792 | 2960 |
#ifndef MSDOS_LIKE |
616 | 2961 |
|
2962 |
int pid; |
|
2963 |
||
2964 |
pid = fork(); |
|
1135 | 2965 |
RETURN ( __MKSMALLINT(pid) ); |
792 | 2966 |
#endif |
2967 |
%}. |
|
2968 |
"/ |
|
2969 |
"/ not supported by OS |
|
2970 |
"/ |
|
2971 |
^ self primitiveFailed |
|
2972 |
||
616 | 2973 |
" |
2974 |
|id| |
|
2975 |
||
2976 |
id := OperatingSystem fork. |
|
2977 |
id == 0 ifTrue:[ |
|
2978 |
OperatingSystem exit |
|
2979 |
] |
|
2980 |
" |
|
68 | 2981 |
! |
2982 |
||
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2983 |
getStatusOfProcess:aProcessId |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2984 |
"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
|
2985 |
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
|
2986 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2987 |
%{ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2988 |
#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
|
2989 |
int status; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2990 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2991 |
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
|
2992 |
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
|
2993 |
{ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2994 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2995 |
# 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
|
2996 |
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
|
2997 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2998 |
do { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2999 |
__BEGIN_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3000 |
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
|
3001 |
__END_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3002 |
if (child < 0 && errno != EINTR) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
3003 |
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
|
3004 |
status = -1; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3005 |
break; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3006 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3007 |
} 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
|
3008 |
# else |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3009 |
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
|
3010 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3011 |
/* 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
|
3012 |
do { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3013 |
__BEGIN_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3014 |
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
|
3015 |
__END_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3016 |
} 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
|
3017 |
if (child != pid) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
3018 |
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
|
3019 |
status = -1; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3020 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3021 |
# 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
|
3022 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3023 |
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
|
3024 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3025 |
#endif |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3026 |
%}. |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3027 |
self primitiveFailed |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3028 |
|
1034 | 3029 |
! |
3030 |
||
3031 |
pathOfCommand:aCommand |
|
3032 |
"find where aCommand's executable file is" |
|
3033 |
||
3034 |
|path f| |
|
3035 |
||
3036 |
path := self getEnvironment:'PATH'. |
|
3037 |
path notNil ifTrue:[ |
|
3038 |
(path asCollectionOfSubstringsSeparatedBy:$:) do:[:path | |
|
3039 |
(f := (path asFilename construct:aCommand)) isExecutable ifTrue:[ |
|
3040 |
^ f pathName |
|
3041 |
] |
|
3042 |
]. |
|
3043 |
]. |
|
3044 |
^ nil |
|
3045 |
||
3046 |
" |
|
3047 |
OperatingSystem pathOfCommand:'fooBar' |
|
3048 |
OperatingSystem pathOfCommand:'ls' |
|
3049 |
OperatingSystem pathOfCommand:'cvs' |
|
3050 |
" |
|
3051 |
! |
|
3052 |
||
3053 |
startProcess:aCommandString |
|
3054 |
"start executing the unix command as specified by the argument, aCommandString |
|
3055 |
as a separate process; do not wait for the command to finish. |
|
3056 |
The commandString is passed to a shell for execution - see the description of |
|
3057 |
'sh -c' in your UNIX manual. |
|
3058 |
Return the processId if successful, nil otherwise. |
|
3059 |
Use #waitForProcess: for synchronization and exec status return, |
|
3060 |
or #killProcess: to stop it." |
|
3061 |
||
3062 |
^ self |
|
3063 |
exec:'/bin/sh' |
|
3064 |
withArguments:(Array with:'sh' with:'-c' with:aCommandString) |
|
3065 |
fork:true. |
|
3066 |
||
3067 |
" |
|
3068 |
|pid| |
|
3069 |
||
3070 |
pid := OperatingSystem startProcess:'sleep 2; echo 1; sleep 2; echo 2'. |
|
3071 |
(Delay forSeconds:3) wait. |
|
3072 |
OperatingSystem killProcess:pid. |
|
3073 |
" |
|
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3074 |
! |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3075 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3076 |
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
|
3077 |
"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
|
3078 |
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
|
3079 |
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
|
3080 |
'sh -c' in your UNIX manual. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3081 |
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
|
3082 |
each may be nil. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3083 |
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
|
3084 |
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
|
3085 |
or #killProcess: to stop it." |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3086 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3087 |
|in out err| |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3088 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3089 |
anExternalInStream notNil ifTrue:[ |
1487 | 3090 |
in := anExternalInStream fileDescriptor. |
1046 | 3091 |
] ifFalse:[ |
1487 | 3092 |
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
|
3093 |
]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3094 |
anExternalOutStream notNil ifTrue:[ |
1487 | 3095 |
out := anExternalOutStream fileDescriptor. |
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3096 |
]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3097 |
anExternalErrStream notNil ifTrue:[ |
1487 | 3098 |
err := anExternalErrStream fileDescriptor. |
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3099 |
]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3100 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3101 |
^ self |
1487 | 3102 |
exec:'/bin/sh' |
3103 |
withArguments:(Array with:'sh' with:'-c' with:aCommandString) |
|
3104 |
fileDescriptors:(Array with:in with:out with:err) |
|
3105 |
fork:true. |
|
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3106 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3107 |
"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
|
3108 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3109 |
OperatingSystem executeCommand:'ls -l > out'. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3110 |
" |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3111 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3112 |
"non-blocking (lower prio threads continue): |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3113 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3114 |
|in out err pid sema| |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3115 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3116 |
in := 'out' asFilename readStream. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3117 |
out := 'out2' asFilename writeStream. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3118 |
err := 'err' asFilename writeStream. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3119 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3120 |
sema := Semaphore new. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3121 |
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
|
3122 |
pid notNil ifTrue:[ |
1487 | 3123 |
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
|
3124 |
]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3125 |
in close. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3126 |
out close. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3127 |
err close. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3128 |
sema wait. |
1422 | 3129 |
Transcript showCR:'finished' |
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3130 |
" |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3131 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3132 |
"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
|
3133 |
"Modified: 29.2.1996 / 12:49:14 / cg" |
616 | 3134 |
! ! |
3135 |
||
3136 |
!OperatingSystem class methodsFor:'file access'! |
|
3137 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3138 |
closeFd:anInteger |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3139 |
"low level close of a filedescriptor" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3140 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3141 |
%{ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3142 |
#if !defined(transputer) && !defined(MSDOS_LIKE) |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3143 |
if (__isSmallInteger(anInteger)) { |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3144 |
close(__intVal(anInteger)); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3145 |
RETURN(self); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3146 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3147 |
#endif |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3148 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3149 |
^ self primitiveFailed. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3150 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3151 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3152 |
createDirectory:newPathName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3153 |
"create a new directory with name 'newPathName'. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3154 |
Return true if successful, false if failed. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3155 |
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
|
3156 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3157 |
"since createDirectory is not used too often, |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3158 |
you'll forgive me using mkdir ..." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3159 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3160 |
^ self executeCommand:('mkdir 2>/dev/null ', newPathName) |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3161 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3162 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3163 |
OperatingSystem createDirectory:'foo' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3164 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3165 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3166 |
"Modified: 20.12.1995 / 11:24:13 / stefan" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3167 |
"Modified: 7.3.1996 / 15:28:19 / cg" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3168 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3169 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3170 |
linkFile:oldPath to:newPath |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3171 |
"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
|
3172 |
Return true if successful, false if not." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3173 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3174 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3175 |
#ifndef MSDOS_LIKE |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3176 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3177 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3178 |
if (__isString(oldPath) && __isString(newPath)) { |
1487 | 3179 |
__BEGIN_INTERRUPTABLE__ |
3180 |
do { |
|
3181 |
ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath)); |
|
3182 |
} while (ret < 0 && errno == EINTR); |
|
3183 |
__END_INTERRUPTABLE__ |
|
3184 |
if (ret < 0) { |
|
3185 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3186 |
RETURN ( false ); |
|
3187 |
} |
|
3188 |
RETURN (true); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3189 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3190 |
#endif |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3191 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3192 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3193 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3194 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3195 |
OperatingSystem linkFile:'foo' to:'bar' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3196 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3197 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3198 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3199 |
makePipe |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3200 |
"make a pipe, return array with two filedescriptors on success, |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3201 |
nil on failure. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3202 |
This is a lowLevel entry, not for public use. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3203 |
See ExternalStream>>makePipe for a more user-friendly, public interface." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3204 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3205 |
|fd1 fd2| |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3206 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3207 |
%{ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3208 |
int fds[2]; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3209 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3210 |
if (pipe(fds) < 0) { |
1487 | 3211 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
3212 |
RETURN ( nil ); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3213 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3214 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3215 |
fd1 = __MKSMALLINT(fds[0]); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3216 |
fd2 = __MKSMALLINT(fds[1]); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3217 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3218 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3219 |
^ Array with:fd1 with:fd2. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3220 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3221 |
|
1132 | 3222 |
recursiveCopyDirectory:sourcePathName to:destination |
3223 |
"copy the directory named 'sourcePathName' and all contained files/directories to 'destination'. |
|
3224 |
Return true if successful." |
|
3225 |
||
3226 |
^ self executeCommand:('cp -rf ' , sourcePathName, ' ', destination) |
|
3227 |
||
3228 |
"Modified: 7.3.1996 / 15:26:30 / cg" |
|
3229 |
! |
|
3230 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3231 |
recursiveCreateDirectory:dirName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3232 |
"create a directory - with all parent dirs if needed. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3233 |
Return true if successful, false otherwise. If false |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3234 |
is returned, a partial created tree may be left, |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3235 |
which is not cleaned-up here." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3236 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3237 |
self createDirectory:dirName. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3238 |
(self isDirectory:dirName) ifFalse:[ |
1487 | 3239 |
(self recursiveCreateDirectory:(self directoryNameOf:dirName)) ifFalse:[^ false]. |
3240 |
^ self createDirectory:dirName |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3241 |
]. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3242 |
^ true |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3243 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3244 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3245 |
OperatingSystem recursiveCreateDirectory:'foo/bar/baz' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3246 |
OperatingSystem recursiveRemoveDirectory:'foo' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3247 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3248 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3249 |
"Modified: 7.3.1996 / 15:26:22 / cg" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3250 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3251 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3252 |
recursiveRemoveDirectory:fullPathName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3253 |
"remove the directory named 'fullPathName' and all contained files/directories. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3254 |
Return true if successful." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3255 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3256 |
^ self executeCommand:('rm -rf ' , fullPathName) |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3257 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3258 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3259 |
OperatingSystem recursiveCreateDirectory:'foo/bar/baz' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3260 |
OperatingSystem recursiveRemoveDirectory:'foo' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3261 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3262 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3263 |
"Modified: 7.3.1996 / 15:26:30 / cg" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3264 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3265 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3266 |
removeDirectory:fullPathName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3267 |
"remove the directory named 'fullPathName'. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3268 |
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
|
3269 |
This is a lowLevel entry - use Filename protocol for compatibility." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3270 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3271 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3272 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3273 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3274 |
if (__isString(fullPathName)) { |
1487 | 3275 |
__BEGIN_INTERRUPTABLE__ |
3276 |
do { |
|
3277 |
ret = rmdir((char *) __stringVal(fullPathName)); |
|
3278 |
} while (ret < 0 && errno == EINTR); |
|
3279 |
__END_INTERRUPTABLE__ |
|
3280 |
if (ret < 0) { |
|
3281 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3282 |
RETURN ( false ); |
|
3283 |
} |
|
3284 |
RETURN (true); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3285 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3286 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3287 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3288 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3289 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3290 |
OperatingSystem createDirectory:'foo' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3291 |
OperatingSystem removeDirectory:'foo' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3292 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3293 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3294 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3295 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3296 |
removeFile:fullPathName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3297 |
"remove the file named 'fullPathName'; return true if successful. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3298 |
This is a lowLevel entry - use Filename protocol for compatibility." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3299 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3300 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3301 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3302 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3303 |
if (__isString(fullPathName)) { |
1487 | 3304 |
__BEGIN_INTERRUPTABLE__ |
3305 |
do { |
|
3306 |
ret = unlink((char *) __stringVal(fullPathName)); |
|
3307 |
} while (ret < 0 && errno == EINTR); |
|
3308 |
__END_INTERRUPTABLE__ |
|
3309 |
if (ret < 0) { |
|
3310 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3311 |
RETURN ( false ); |
|
3312 |
} |
|
3313 |
RETURN (true); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3314 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3315 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3316 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3317 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3318 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3319 |
renameFile:oldPath to:newPath |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3320 |
"rename the file 'oldPath' to 'newPath'. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3321 |
Return true if successful, false if not" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3322 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3323 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3324 |
int ret, eno; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3325 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3326 |
if (__isString(oldPath) && __isString(newPath)) { |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3327 |
#if defined(HAS_RENAME) |
1487 | 3328 |
__BEGIN_INTERRUPTABLE__ |
3329 |
do { |
|
3330 |
ret = rename((char *) __stringVal(oldPath), (char *) __stringVal(newPath)); |
|
3331 |
} while (ret < 0 && errno == EINTR); |
|
3332 |
__END_INTERRUPTABLE__ |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3333 |
#else |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3334 |
# ifndef MSDOS_LIKE |
1487 | 3335 |
ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath)); |
3336 |
if (ret >= 0) { |
|
3337 |
ret = unlink((char *) __stringVal(oldPath)); |
|
3338 |
if (ret < 0) { |
|
3339 |
eno = errno; |
|
3340 |
unlink((char *) __stringVal(newPath)); |
|
3341 |
errno = eno; |
|
3342 |
} |
|
3343 |
} |
|
1084
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 |
#endif |
1487 | 3346 |
if (ret < 0) { |
3347 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3348 |
RETURN ( false ); |
|
3349 |
} |
|
3350 |
RETURN (true); |
|
1084
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 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3354 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3355 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3356 |
OperatingSystem renameFile:'foo' to:'bar' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3357 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3358 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3359 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3360 |
truncateFile:aPathName to:newSize |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3361 |
"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
|
3362 |
This may not be supported on all architectures. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3363 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3364 |
This is a low-level entry - use Filename protocol." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3365 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3366 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3367 |
#ifdef HAS_FTRUNCATE |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3368 |
int ret; |
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 |
if (__isString(aPathName) |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3371 |
&& __isSmallInteger(newSize)) { |
1487 | 3372 |
__BEGIN_INTERRUPTABLE__ |
3373 |
do { |
|
3374 |
ret = truncate((char *) __stringVal(aPathName), __intVal(newSize)); |
|
3375 |
} while (ret < 0 && errno == EINTR); |
|
3376 |
__END_INTERRUPTABLE__ |
|
3377 |
if (ret < 0) { |
|
3378 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3379 |
RETURN ( false ); |
|
3380 |
} |
|
3381 |
RETURN (true); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3382 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3383 |
#endif |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3384 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3385 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3386 |
! ! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3387 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3388 |
!OperatingSystem class methodsFor:'file access rights'! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3389 |
|
616 | 3390 |
accessMaskFor:aSymbol |
3391 |
"return the access bits mask for numbers as returned by |
|
3392 |
OperatingSystem>>accessModeOf: |
|
3393 |
and expected by OperatingSystem>>changeAccessModeOf:to:. |
|
3394 |
Since these numbers are OS dependent, always use the mask |
|
3395 |
(never hardcode 8rxxx into your code)." |
|
68 | 3396 |
|
3397 |
%{ /* NOCONTEXT */ |
|
616 | 3398 |
# ifndef S_IRUSR |
3399 |
/* posix systems should define these ... */ |
|
3400 |
# define S_IRUSR 0400 |
|
3401 |
# define S_IWUSR 0200 |
|
3402 |
# define S_IXUSR 0100 |
|
3403 |
# define S_IRGRP 0040 |
|
3404 |
# define S_IWGRP 0020 |
|
3405 |
# define S_IXGRP 0010 |
|
3406 |
# define S_IROTH 0004 |
|
3407 |
# define S_IWOTH 0002 |
|
3408 |
# define S_IXOTH 0001 |
|
3409 |
||
3410 |
# endif |
|
3411 |
||
3412 |
if (aSymbol == @symbol(readUser)) { |
|
1135 | 3413 |
RETURN ( __MKSMALLINT(S_IRUSR) ); |
616 | 3414 |
} |
3415 |
if (aSymbol == @symbol(writeUser)) { |
|
1135 | 3416 |
RETURN ( __MKSMALLINT(S_IWUSR) ); |
616 | 3417 |
} |
3418 |
if (aSymbol == @symbol(executeUser)) { |
|
1135 | 3419 |
RETURN ( __MKSMALLINT(S_IXUSR) ); |
616 | 3420 |
} |
3421 |
if (aSymbol == @symbol(readGroup)) { |
|
1135 | 3422 |
RETURN ( __MKSMALLINT(S_IRGRP) ); |
616 | 3423 |
} |
3424 |
if (aSymbol == @symbol(writeGroup)) { |
|
1135 | 3425 |
RETURN ( __MKSMALLINT(S_IWGRP) ); |
616 | 3426 |
} |
3427 |
if (aSymbol == @symbol(executeGroup)) { |
|
1135 | 3428 |
RETURN ( __MKSMALLINT(S_IXGRP) ); |
616 | 3429 |
} |
3430 |
if (aSymbol == @symbol(readOthers)) { |
|
1135 | 3431 |
RETURN ( __MKSMALLINT(S_IROTH) ); |
616 | 3432 |
} |
3433 |
if (aSymbol == @symbol(writeOthers)) { |
|
1135 | 3434 |
RETURN ( __MKSMALLINT(S_IWOTH) ); |
616 | 3435 |
} |
3436 |
if (aSymbol == @symbol(executeOthers)) { |
|
1135 | 3437 |
RETURN ( __MKSMALLINT(S_IXOTH) ); |
616 | 3438 |
} |
3439 |
%}. |
|
792 | 3440 |
^ self primitiveFailed |
616 | 3441 |
|
3442 |
" |
|
3443 |
OperatingSystem accessMaskFor:#readUser |
|
3444 |
" |
|
68 | 3445 |
! |
3446 |
||
616 | 3447 |
accessModeOf:aPathName |
3448 |
"return a number representing access rights rwxrwxrwx for owner, |
|
3449 |
group and others. Return nil if such a file does not exist. |
|
3450 |
Notice that the returned number is OS dependent - use the |
|
3451 |
modeMasks as returned by OperatingSystem>>accessMaskFor:" |
|
3452 |
||
3453 |
" |
|
3454 |
this could have been implemented as: |
|
1487 | 3455 |
(self infoOf:aPathName) at:#mode |
616 | 3456 |
but for huge directory searches the code below is faster |
3457 |
" |
|
345 | 3458 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3459 |
%{ |
616 | 3460 |
struct stat buf; |
3461 |
int ret; |
|
3462 |
||
3463 |
if (__isString(aPathName)) { |
|
1487 | 3464 |
__BEGIN_INTERRUPTABLE__ |
3465 |
do { |
|
3466 |
ret = stat((char *) __stringVal(aPathName), &buf); |
|
3467 |
} while ((ret < 0) && (errno == EINTR)); |
|
3468 |
__END_INTERRUPTABLE__ |
|
3469 |
||
3470 |
if (ret < 0) { |
|
3471 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3472 |
RETURN ( nil ); |
|
3473 |
} |
|
3474 |
RETURN ( __MKSMALLINT(buf.st_mode & 0777) ); |
|
616 | 3475 |
} |
3476 |
%}. |
|
792 | 3477 |
^ self primitiveFailed |
616 | 3478 |
|
3479 |
" |
|
3480 |
(OperatingSystem accessModeOf:'/') printStringRadix:8 |
|
3481 |
" |
|
345 | 3482 |
! |
3483 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3484 |
changeAccessModeOf:aPathName to:modeBits |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3485 |
"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
|
3486 |
You should construct this mask using accessMaskFor, to be OS |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3487 |
independent. Return true if changed, |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3488 |
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
|
3489 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3490 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3491 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3492 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3493 |
if (__isString(aPathName) && __isSmallInteger(modeBits)) { |
1487 | 3494 |
__BEGIN_INTERRUPTABLE__ |
3495 |
do { |
|
3496 |
ret = chmod((char *)__stringVal(aPathName), __intVal(modeBits)); |
|
3497 |
} while (ret < 0 && errno == EINTR); |
|
3498 |
__END_INTERRUPTABLE__ |
|
3499 |
if (ret < 0) { |
|
3500 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3501 |
RETURN ( false ); |
|
3502 |
} |
|
3503 |
RETURN ( true ); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3504 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3505 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3506 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3507 |
! ! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3508 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3509 |
!OperatingSystem class methodsFor:'file queries'! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3510 |
|
616 | 3511 |
baseNameOf:aPathString |
3512 |
"return the baseName of the argument, aPathString |
|
3513 |
- thats the file/directory name without leading parent-dirs |
|
3514 |
(i.e. OperatingSystem baseNameOf:'/usr/lib/st/file' -> 'file' |
|
3515 |
and OperatingSystem baseNameOf:'/usr/lib' -> lib). |
|
3516 |
This method does not check if the path is valid |
|
3517 |
(i.e. if these directories really exist & is readable)." |
|
3518 |
||
3519 |
|prev index sep| |
|
3520 |
||
3521 |
sep := self fileSeparator. |
|
3522 |
((aPathString size == 1) and:[(aPathString at:1) == sep]) ifTrue:[ |
|
3523 |
^ aPathString |
|
3524 |
]. |
|
3525 |
prev := 1. |
|
3526 |
[true] whileTrue:[ |
|
3527 |
index := aPathString indexOf:sep startingAt:prev. |
|
3528 |
index == 0 ifTrue:[ |
|
3529 |
^ aPathString copyFrom:prev |
|
3530 |
]. |
|
3531 |
prev := index + 1 |
|
3532 |
] |
|
3533 |
||
3534 |
" |
|
3535 |
OperatingSystem baseNameOf:'/fee/foo/bar' |
|
3536 |
OperatingSystem baseNameOf:'foo/bar' |
|
3537 |
OperatingSystem baseNameOf:'../../foo/bar' |
|
3538 |
OperatingSystem baseNameOf:'hello' |
|
3539 |
" |
|
3540 |
! |
|
3541 |
||
3542 |
caseSensitiveFilenames |
|
3543 |
"return true, if the OS has caseSensitive file naming. |
|
3544 |
On MSDOS, this will return false. Since this is for Unix, we |
|
3545 |
return true." |
|
3546 |
||
3547 |
^ true |
|
3548 |
! |
|
3549 |
||
3550 |
compressPath:pathName |
|
3551 |
"return the pathName compressed - that is, remove all ..-entries |
|
3552 |
and . entries. This does not always (in case of symbolic links) |
|
3553 |
return the true pathName and is therefore used as a fallback |
|
3554 |
if realPath and popen failed." |
|
3555 |
||
3556 |
|names| |
|
3557 |
||
3558 |
names := pathName |
|
3559 |
asCollectionOfSubstringsSeparatedBy:self fileSeparator. |
|
3560 |
names := names asOrderedCollection. |
|
3561 |
" |
|
3562 |
cut off initial double-slashes |
|
3563 |
" |
|
3564 |
[names startsWith:#('' '')] whileTrue:[ |
|
3565 |
names removeFirst. |
|
3566 |
]. |
|
3567 |
" |
|
3568 |
cut off double-slashes at end |
|
3569 |
" |
|
3570 |
[names endsWith:#('')] whileTrue:[ |
|
3571 |
names removeLast. |
|
3572 |
]. |
|
3573 |
" |
|
3574 |
cut off current-dir at beginning |
|
3575 |
" |
|
3576 |
[(names size >= 2) and:[names startsWith:#('.')]] whileTrue:[ |
|
3577 |
names removeFirst. |
|
3578 |
]. |
|
3579 |
||
3580 |
" |
|
3581 |
cut off parent-dirs at end |
|
3582 |
" |
|
3583 |
[(names size > 2) |
|
3584 |
and:[(names endsWith:#('..')) |
|
3585 |
and:[((names at:(names size - 1)) startsWith:'.') not ]]] whileTrue:[ |
|
3586 |
names removeLast; removeLast |
|
3587 |
]. |
|
3588 |
||
3589 |
^ names asStringWith:self fileSeparator |
|
3590 |
from:1 |
|
3591 |
to:names size |
|
3592 |
compressTabs:false final:nil |
|
3593 |
||
3594 |
" |
|
3595 |
OperatingSystem compressPath:'./..' |
|
3596 |
OperatingSystem compressPath:'/foo/bar/baz/..' |
|
3597 |
OperatingSystem compressPath:'foo/bar/baz/..' |
|
3598 |
OperatingSystem compressPath:'foo/bar/baz/../' |
|
3599 |
OperatingSystem compressPath:'foo/bar/baz/..///' |
|
3600 |
OperatingSystem compressPath:'///foo/bar/baz/..///' |
|
3601 |
" |
|
68 | 3602 |
! |
3603 |
||
616 | 3604 |
directoryNameOf:aPathString |
3605 |
"return the directoryName of the argument, aPath |
|
3606 |
- thats the name of the directory where aPath is |
|
3607 |
(i.e. OperatingSystem directoryNameOf:'/usr/lib/st/file' -> '/usr/lib/st' |
|
3608 |
and OperatingSystem directoryNameOf:'/usr/lib' -> /usr'). |
|
3609 |
This method does not check if the path is valid |
|
3610 |
(i.e. if these directories really exist & are readable)." |
|
3611 |
||
3612 |
|last index sep sepString| |
|
3613 |
||
3614 |
sep := self fileSeparator. |
|
3615 |
sepString := sep asString. |
|
3616 |
(aPathString = sepString) ifTrue:[ |
|
3617 |
" |
|
3618 |
the trivial '/' case |
|
3619 |
" |
|
3620 |
^ aPathString |
|
3621 |
]. |
|
3622 |
(aPathString startsWith:sepString) ifFalse:[ |
|
3623 |
(aPathString endsWith:sepString) ifTrue:[ |
|
3624 |
^ aPathString copyTo:(aPathString size - 1) |
|
3625 |
]. |
|
3626 |
]. |
|
3627 |
last := 1. |
|
3628 |
[true] whileTrue:[ |
|
3629 |
index := aPathString indexOf:sep startingAt:(last + 1). |
|
3630 |
index == 0 ifTrue:[ |
|
3631 |
(last == 1) ifTrue:[ |
|
3632 |
(aPathString startsWith:sepString) ifTrue:[ |
|
3633 |
^ sepString |
|
3634 |
]. |
|
3635 |
^ '.' |
|
3636 |
]. |
|
3637 |
" |
|
3638 |
(aPathString startsWith:sepString) ifFalse:[ |
|
3639 |
(aPathString startsWith:('..' , sepString)) ifFalse:[ |
|
3640 |
^ './' , (aPathString copyTo:(last - 1)) |
|
3641 |
] |
|
3642 |
]. |
|
3643 |
" |
|
3644 |
^ aPathString copyTo:(last - 1) |
|
3645 |
]. |
|
3646 |
last := index. |
|
3647 |
] |
|
3648 |
||
3649 |
" |
|
3650 |
OperatingSystem directoryNameOf:'/fee/foo/bar' |
|
3651 |
OperatingSystem directoryNameOf:'foo/bar' |
|
3652 |
OperatingSystem directoryNameOf:'../../foo/bar' |
|
3653 |
OperatingSystem directoryNameOf:'bar' |
|
3654 |
OperatingSystem directoryNameOf:'/bar' |
|
3655 |
" |
|
3656 |
! |
|
3657 |
||
3658 |
fileSeparator |
|
3659 |
"return the character used to separate names in a path. |
|
3660 |
This character differs for MSDOS and other systems, |
|
3661 |
(but those are currently not supported - so this is some |
|
3662 |
preparation for the future)" |
|
3663 |
||
3664 |
^ $/ |
|
3665 |
! |
|
3666 |
||
3667 |
idOf:aPathName |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3668 |
"return the fileNumber (i.e. inode number) of a file. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3669 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3670 |
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
|
3671 |
some dummy id will be returned. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3672 |
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
|
3673 |
physically identical, even if found in different directories |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3674 |
(i.e. if they are hardLinked)." |
616 | 3675 |
|
3676 |
" |
|
3677 |
this could have been implemented as: |
|
1487 | 3678 |
(self infoOf:aPathName) at:#id |
616 | 3679 |
but for huge directory searches the code below is faster |
3680 |
" |
|
68 | 3681 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3682 |
%{ |
616 | 3683 |
struct stat buf; |
3684 |
int ret; |
|
3685 |
||
3686 |
if (__isString(aPathName)) { |
|
1487 | 3687 |
__BEGIN_INTERRUPTABLE__ |
3688 |
do { |
|
3689 |
ret = stat((char *) __stringVal(aPathName), &buf); |
|
3690 |
} while (ret < 0 && errno == EINTR); |
|
3691 |
__END_INTERRUPTABLE__ |
|
3692 |
if (ret >= 0) { |
|
3693 |
RETURN (__MKSMALLINT(buf.st_ino)); |
|
3694 |
} |
|
3695 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3696 |
RETURN (nil); |
|
616 | 3697 |
} |
68 | 3698 |
%} |
616 | 3699 |
. |
792 | 3700 |
^ self primitiveFailed |
616 | 3701 |
|
3702 |
"OperatingSystem idOf:'/'" |
|
68 | 3703 |
! |
3704 |
||
616 | 3705 |
infoOf:aPathName |
3706 |
"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
|
3707 |
the info is: (#type->t #mode->n #uid->u #gid->g #size->s #id->ino). |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3708 |
Return nil if such a file does not exist. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3709 |
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
|
3710 |
use #linkInfoOf: to get info about the link itself. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3711 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3712 |
A dictionary is returned, since we might need to add more info in the |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3713 |
future without affecting existing applications." |
616 | 3714 |
|
3715 |
|info type mode uid gid size id |
|
3716 |
atimeLow atimeHi mtimeLow mtimeHi ctimeLow ctimeHi| |
|
3717 |
||
3718 |
%{ |
|
3719 |
struct stat buf; |
|
3720 |
int ret; |
|
3721 |
||
3722 |
if (__isString(aPathName)) { |
|
1487 | 3723 |
__BEGIN_INTERRUPTABLE__ |
3724 |
do { |
|
3725 |
ret = stat((char *) __stringVal(aPathName), &buf); |
|
3726 |
} while ((ret < 0) && (errno == EINTR)); |
|
3727 |
__END_INTERRUPTABLE__ |
|
3728 |
||
3729 |
if (ret < 0) { |
|
3730 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3731 |
RETURN ( nil ); |
|
3732 |
} |
|
3733 |
switch (buf.st_mode & S_IFMT) { |
|
3734 |
case S_IFDIR: |
|
3735 |
type = @symbol(directory); |
|
3736 |
break; |
|
3737 |
case S_IFREG: |
|
3738 |
type = @symbol(regular); |
|
3739 |
break; |
|
616 | 3740 |
#ifdef S_IFCHR |
1487 | 3741 |
case S_IFCHR: |
3742 |
type = @symbol(characterSpecial); |
|
3743 |
break; |
|
616 | 3744 |
#endif |
3745 |
#ifdef S_IFBLK |
|
1487 | 3746 |
case S_IFBLK: |
3747 |
type = @symbol(blockSpecial); |
|
3748 |
break; |
|
616 | 3749 |
#endif |
3750 |
#ifdef S_IFLNK |
|
1487 | 3751 |
case S_IFLNK: |
3752 |
type = @symbol(symbolicLink); |
|
3753 |
break; |
|
616 | 3754 |
#endif |
3755 |
#ifdef S_IFSOCK |
|
1487 | 3756 |
case S_IFSOCK: |
3757 |
type = @symbol(socket); |
|
3758 |
break; |
|
616 | 3759 |
#endif |
3760 |
#ifdef S_IFIFO |
|
1487 | 3761 |
case S_IFIFO: |
3762 |
type = @symbol(fifo); |
|
3763 |
break; |
|
3764 |
#endif |
|
3765 |
default: |
|
3766 |
type = @symbol(unknown); |
|
3767 |
break; |
|
3768 |
} |
|
3769 |
mode = __MKSMALLINT(buf.st_mode & 0777); |
|
3770 |
uid = __MKSMALLINT(buf.st_uid); |
|
3771 |
gid = __MKSMALLINT(buf.st_gid); |
|
3772 |
size = __MKSMALLINT(buf.st_size); |
|
3773 |
id = __MKSMALLINT(buf.st_ino); |
|
3774 |
atimeLow = __MKSMALLINT(buf.st_atime & 0xFFFF); |
|
3775 |
atimeHi = __MKSMALLINT((buf.st_atime >> 16) & 0xFFFF); |
|
3776 |
mtimeLow = __MKSMALLINT(buf.st_mtime & 0xFFFF); |
|
3777 |
mtimeHi = __MKSMALLINT((buf.st_mtime >> 16) & 0xFFFF); |
|
3778 |
ctimeLow = __MKSMALLINT(buf.st_ctime & 0xFFFF); |
|
3779 |
ctimeHi = __MKSMALLINT((buf.st_ctime >> 16) & 0xFFFF); |
|
616 | 3780 |
} |
3781 |
%}. |
|
3782 |
mode notNil ifTrue:[ |
|
1487 | 3783 |
info := IdentityDictionary new. |
3784 |
info at:#type put:type. |
|
3785 |
info at:#mode put:mode. |
|
3786 |
info at:#uid put:uid. |
|
3787 |
info at:#gid put:gid. |
|
3788 |
info at:#size put:size. |
|
3789 |
info at:#id put:id. |
|
3790 |
info at:#accessed put:(AbsoluteTime fromOSTimeLow:atimeLow and:atimeHi). |
|
3791 |
info at:#modified put:(AbsoluteTime fromOSTimeLow:mtimeLow and:mtimeHi). |
|
3792 |
info at:#statusChanged put:(AbsoluteTime fromOSTimeLow:ctimeLow and:ctimeHi). |
|
3793 |
^ info |
|
616 | 3794 |
]. |
792 | 3795 |
^ self primitiveFailed |
616 | 3796 |
|
3797 |
" |
|
3798 |
OperatingSystem infoOf:'/' |
|
3799 |
(OperatingSystem infoOf:'/') at:#uid |
|
3800 |
(OperatingSystem infoOf:'/') at:#accessed |
|
3801 |
" |
|
68 | 3802 |
! |
3803 |
||
616 | 3804 |
isDirectory:aPathName |
3805 |
"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
|
3806 |
(i.e. exists and is a directory). |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3807 |
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
|
3808 |
if you need to check for this, use #linkInfo:." |
68 | 3809 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3810 |
%{ |
616 | 3811 |
struct stat buf; |
3812 |
int ret; |
|
3813 |
||
3814 |
if (__isString(aPathName)) { |
|
1487 | 3815 |
__BEGIN_INTERRUPTABLE__ |
3816 |
do { |
|
3817 |
ret = stat((char *) __stringVal(aPathName), &buf); |
|
3818 |
} while ((ret < 0) && (errno == EINTR)); |
|
3819 |
__END_INTERRUPTABLE__ |
|
3820 |
if (ret < 0) { |
|
3821 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3822 |
RETURN ( false ); |
|
3823 |
} |
|
3824 |
RETURN ( ((buf.st_mode & S_IFMT) == S_IFDIR) ? true : false); |
|
616 | 3825 |
} |
3826 |
%}. |
|
792 | 3827 |
^ self primitiveFailed |
616 | 3828 |
|
3829 |
"an alternative implementation would be: |
|
1487 | 3830 |
^ (self infoOf:aPathName) at:#type == #directory |
616 | 3831 |
" |
68 | 3832 |
! |
3833 |
||
616 | 3834 |
isExecutable:aPathName |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3835 |
"return true, if the given file is executable. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3836 |
For symbolic links, the pointed-to-file is checked." |
68 | 3837 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3838 |
%{ |
616 | 3839 |
int ret; |
3840 |
||
3841 |
if (__isString(aPathName)) { |
|
1487 | 3842 |
__BEGIN_INTERRUPTABLE__ |
3843 |
do { |
|
3844 |
ret = access(__stringVal(aPathName), X_OK); |
|
3845 |
} while ((ret < 0) && (errno == EINTR)); |
|
3846 |
__END_INTERRUPTABLE__ |
|
3847 |
if (ret < 0) { |
|
3848 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3849 |
} |
|
3850 |
RETURN ( ((ret == 0) ? true : false) ); |
|
616 | 3851 |
} |
3852 |
%}. |
|
792 | 3853 |
^ self primitiveFailed |
68 | 3854 |
! |
3855 |
||
616 | 3856 |
isReadable:aPathName |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3857 |
"return true, if the file/dir 'aPathName' is readable. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3858 |
For symbolic links, the pointed-to-file is checked." |
68 | 3859 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3860 |
%{ |
616 | 3861 |
int ret; |
3862 |
||
3863 |
if (__isString(aPathName)) { |
|
1487 | 3864 |
__BEGIN_INTERRUPTABLE__ |
3865 |
do { |
|
3866 |
ret = access(__stringVal(aPathName), R_OK); |
|
3867 |
} while ((ret < 0) && (errno == EINTR)); |
|
3868 |
__END_INTERRUPTABLE__ |
|
3869 |
if (ret < 0) { |
|
3870 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3871 |
} |
|
3872 |
RETURN ( ((ret == 0) ? true : false) ); |
|
616 | 3873 |
} |
3874 |
%}. |
|
792 | 3875 |
^ self primitiveFailed |
68 | 3876 |
! |
3877 |
||
616 | 3878 |
isSymbolicLink:aPathName |
3879 |
"return true, if the given file is a symbolic link" |
|
3880 |
||
3881 |
^ (self linkInfoOf:aPathName) notNil |
|
3882 |
||
3883 |
" |
|
3884 |
OperatingSystem isSymbolicLink:'Make.proto' |
|
3885 |
OperatingSystem isSymbolicLink:'Makefile' |
|
3886 |
" |
|
3887 |
! |
|
3888 |
||
3889 |
isValidPath:aPathName |
|
3890 |
"return true, if 'aPathName' is a valid path name |
|
3891 |
(i.e. the file or directory exists)" |
|
68 | 3892 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3893 |
%{ |
616 | 3894 |
struct stat buf; |
3895 |
int ret; |
|
3896 |
||
3897 |
if (__isString(aPathName) || __isSymbol(aPathName) ) { |
|
3898 |
__BEGIN_INTERRUPTABLE__ |
|
3899 |
do { |
|
1135 | 3900 |
ret = stat((char *) __stringVal(aPathName), &buf); |
616 | 3901 |
} while ((ret < 0) && (errno == EINTR)); |
3902 |
__END_INTERRUPTABLE__ |
|
3903 |
if (ret < 0) { |
|
1135 | 3904 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 3905 |
RETURN (false); |
3906 |
} |
|
3907 |
RETURN ( ret ? false : true ); |
|
3908 |
} |
|
792 | 3909 |
%}. |
3910 |
^ self primitiveFailed |
|
68 | 3911 |
! |
3912 |
||
616 | 3913 |
isWritable:aPathName |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3914 |
"return true, if the given file is writable. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3915 |
For symbolic links, the pointed-to-file is checked." |
68 | 3916 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3917 |
%{ |
616 | 3918 |
int ret; |
3919 |
||
3920 |
if (__isString(aPathName)) { |
|
1487 | 3921 |
__BEGIN_INTERRUPTABLE__ |
3922 |
do { |
|
3923 |
ret = access(__stringVal(aPathName), W_OK); |
|
3924 |
} while ((ret < 0) && (errno == EINTR)); |
|
3925 |
__END_INTERRUPTABLE__ |
|
3926 |
if (ret < 0) { |
|
3927 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3928 |
} |
|
3929 |
RETURN ( ((ret == 0) ? true : false) ); |
|
616 | 3930 |
} |
3931 |
%}. |
|
792 | 3932 |
^ self primitiveFailed |
68 | 3933 |
! |
3934 |
||
616 | 3935 |
linkInfoOf:aPathName |
3936 |
"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
|
3937 |
IFF aPathName is a symbolic link. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3938 |
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
|
3939 |
|
616 | 3940 |
The contents of the dictionary gives info about the link itself, |
3941 |
on contrast to #infoOf:, which returns the info of the pointed to file |
|
3942 |
in case of a symbolic link." |
|
3943 |
||
3944 |
|info type mode uid gid size id atimeLow atimeHi mtimeLow mtimeHi ctimeLow ctimeHi |
|
3945 |
path| |
|
3946 |
||
3947 |
%{ /* STACK: 1200 */ |
|
792 | 3948 |
#ifdef S_IFLNK |
616 | 3949 |
struct stat buf; |
3950 |
int ret; |
|
3951 |
char pathBuffer[1024]; |
|
3952 |
||
3953 |
if (__isString(aPathName)) { |
|
1487 | 3954 |
__BEGIN_INTERRUPTABLE__ |
3955 |
do { |
|
3956 |
ret = lstat((char *) __stringVal(aPathName), &buf); |
|
3957 |
} while ((ret < 0) && (errno == EINTR)); |
|
3958 |
__END_INTERRUPTABLE__ |
|
3959 |
||
3960 |
if (ret < 0) { |
|
3961 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3962 |
RETURN ( nil ); |
|
3963 |
} |
|
3964 |
switch (buf.st_mode & S_IFMT) { |
|
3965 |
default: |
|
3966 |
RETURN ( nil ); /* not a symbolic link */ |
|
3967 |
||
3968 |
case S_IFLNK: |
|
3969 |
type = @symbol(symbolicLink); |
|
3970 |
break; |
|
3971 |
} |
|
3972 |
||
3973 |
mode = __MKSMALLINT(buf.st_mode & 0777); |
|
3974 |
uid = __MKSMALLINT(buf.st_uid); |
|
3975 |
gid = __MKSMALLINT(buf.st_gid); |
|
3976 |
size = __MKSMALLINT(buf.st_size); |
|
3977 |
id = __MKSMALLINT(buf.st_ino); |
|
3978 |
atimeLow = __MKSMALLINT(buf.st_atime & 0xFFFF); |
|
3979 |
atimeHi = __MKSMALLINT((buf.st_atime >> 16) & 0xFFFF); |
|
3980 |
mtimeLow = __MKSMALLINT(buf.st_mtime & 0xFFFF); |
|
3981 |
mtimeHi = __MKSMALLINT((buf.st_mtime >> 16) & 0xFFFF); |
|
3982 |
ctimeLow = __MKSMALLINT(buf.st_ctime & 0xFFFF); |
|
3983 |
ctimeHi = __MKSMALLINT((buf.st_ctime >> 16) & 0xFFFF); |
|
3984 |
if ((ret = readlink((char *) __stringVal(aPathName), pathBuffer, sizeof(pathBuffer))) < 0) { |
|
3985 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
|
3986 |
RETURN ( nil ); |
|
3987 |
} |
|
3988 |
pathBuffer[ret] = '\0'; /* readlink does not 0-terminate */ |
|
3989 |
path = __MKSTRING(pathBuffer COMMA_CON); |
|
616 | 3990 |
} |
792 | 3991 |
#else |
3992 |
RETURN ( nil ); |
|
3993 |
#endif |
|
616 | 3994 |
%}. |
3995 |
mode notNil ifTrue:[ |
|
1487 | 3996 |
info := IdentityDictionary new. |
3997 |
info at:#type put:type. |
|
3998 |
info at:#mode put:mode. |
|
3999 |
info at:#uid put:uid. |
|
4000 |
info at:#gid put:gid. |
|
4001 |
info at:#size put:size. |
|
4002 |
info at:#id put:id. |
|
4003 |
info at:#path put:path. |
|
4004 |
info at:#accessed put:(AbsoluteTime fromOSTimeLow:atimeLow and:atimeHi). |
|
4005 |
info at:#modified put:(AbsoluteTime fromOSTimeLow:mtimeLow and:mtimeHi). |
|
4006 |
info at:#statusChanged put:(AbsoluteTime fromOSTimeLow:ctimeLow and:ctimeHi). |
|
4007 |
^ info |
|
616 | 4008 |
]. |
792 | 4009 |
^ self primitiveFailed |
616 | 4010 |
|
4011 |
" |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4012 |
OperatingSystem infoOf:'Make.proto' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4013 |
OperatingSystem linkInfoOf:'Make.proto' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4014 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4015 |
OperatingSystem infoOf:'resources/motif.style' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4016 |
OperatingSystem linkInfoOf:'resources/motif.style' |
616 | 4017 |
" |
4018 |
! |
|
4019 |
||
4020 |
parentDirectoryName |
|
4021 |
"return the name used to refer to parent directories. |
|
4022 |
In MSDOS, Unix and other systems this is '..', but maybe different |
|
4023 |
for other systems. |
|
4024 |
(but those are currently not supported - so this is some |
|
4025 |
preparation for the future)" |
|
4026 |
||
4027 |
^ '..' |
|
68 | 4028 |
! |
4029 |
||
616 | 4030 |
pathNameOf:pathName |
4031 |
"return the pathName of the argument, aPathString, |
|
4032 |
- thats the full pathname of the directory, starting at '/'. |
|
4033 |
This method needs the path to be valid |
|
4034 |
(i.e. all directories must exist, be readable and executable). |
|
4035 |
Notice: if symbolic links are involved, the result may look different |
|
4036 |
from what you expect." |
|
4037 |
||
4038 |
|p path command| |
|
4039 |
||
4040 |
"some systems have a convenient function for this ..." |
|
4041 |
path := self primPathNameOf:pathName. |
|
4042 |
||
4043 |
path isNil ifTrue:[ |
|
4044 |
(self isValidPath:pathName) ifFalse:[^ pathName]. |
|
4045 |
||
4046 |
(SlowFork==true or:[ForkFailed]) ifFalse:[ |
|
4047 |
PipeStream openErrorSignal handle:[:ex | |
|
4048 |
ForkFailed := true. |
|
4049 |
'OS: cannot fork/popen' errorPrintNL. |
|
4050 |
ex return. |
|
4051 |
] do:[ |
|
4052 |
"have to fall back ..." |
|
4053 |
command := 'cd ' , pathName , '; pwd'. |
|
4054 |
p := PipeStream readingFrom:command. |
|
4055 |
]. |
|
4056 |
||
4057 |
(p isNil or:[p atEnd]) ifTrue:[ |
|
4058 |
('OS: PipeStream for <' , command , '> failed') errorPrintNL. |
|
4059 |
] ifFalse:[ |
|
4060 |
path := p nextLine. |
|
4061 |
p close. |
|
4062 |
]. |
|
4063 |
]. |
|
4064 |
path isNil ifTrue:[ |
|
4065 |
path := pathName |
|
4066 |
]. |
|
4067 |
(SlowFork==true or:[ForkFailed]) ifTrue:[ |
|
4068 |
path := self compressPath:path |
|
4069 |
] |
|
4070 |
]. |
|
4071 |
^ path. |
|
4072 |
||
4073 |
" |
|
4074 |
OperatingSystem pathNameOf:'.' |
|
4075 |
OperatingSystem pathNameOf:'../smalltalk/../smalltalk' |
|
4076 |
OperatingSystem pathNameOf:'../../..' |
|
4077 |
OperatingSystem pathNameOf:'..' |
|
4078 |
" |
|
359 | 4079 |
! |
4080 |
||
616 | 4081 |
primPathNameOf:pathName |
4082 |
"return the pathName of the argument, aPathString, |
|
4083 |
- thats the full pathname of the directory, starting at '/'. |
|
4084 |
This method here returns nil, if the OS does not provide a |
|
4085 |
realPath library function. |
|
4086 |
Notice: if symbolic links are involved, the result may look different |
|
4087 |
from what you expect." |
|
4088 |
||
4089 |
|path| |
|
4090 |
||
4091 |
"some systems have a convenient function for this ..." |
|
4092 |
%{ /* STACK: 16000 */ |
|
4093 |
#ifdef HAS_REALPATH |
|
4094 |
char nameBuffer[MAXPATHLEN + 1]; |
|
4095 |
||
4096 |
if (__isString(pathName)) { |
|
1135 | 4097 |
if (realpath(__stringVal(pathName), nameBuffer)) { |
830 | 4098 |
RETURN ( __MKSTRING(nameBuffer COMMA_CON) ); |
616 | 4099 |
} |
4100 |
} |
|
4101 |
#endif |
|
4102 |
%}. |
|
4103 |
^ nil |
|
359 | 4104 |
! |
4105 |
||
616 | 4106 |
timeOfLastAccess:aPathName |
4107 |
"return the time, when the file was last accessed. |
|
4108 |
For nonexistent files, nil is returned." |
|
4109 |
||
4110 |
"could be implemented as: |
|
4111 |
(self infoOf:aPathName) at:#accessed |
|
4112 |
" |
|
4113 |
|timeLow timeHi| |
|
4114 |
%{ |
|
4115 |
struct stat buf; |
|
4116 |
time_t mtime; |
|
4117 |
int ret; |
|
4118 |
||
4119 |
if (__isString(aPathName)) { |
|
4120 |
__BEGIN_INTERRUPTABLE__ |
|
4121 |
do { |
|
1135 | 4122 |
ret = stat((char *) __stringVal(aPathName), &buf); |
616 | 4123 |
} while (ret < 0 && errno == EINTR); |
4124 |
__END_INTERRUPTABLE__ |
|
4125 |
if (ret < 0) { |
|
1135 | 4126 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 4127 |
RETURN (nil); |
4128 |
} |
|
1135 | 4129 |
timeLow = __MKSMALLINT(buf.st_atime & 0xFFFF); |
4130 |
timeHi = __MKSMALLINT((buf.st_atime >> 16) & 0xFFFF); |
|
616 | 4131 |
} |
792 | 4132 |
%}. |
616 | 4133 |
timeLow notNil ifTrue:[^ AbsoluteTime fromOSTimeLow:timeLow and:timeHi]. |
792 | 4134 |
^ self primitiveFailed |
616 | 4135 |
|
4136 |
" |
|
4137 |
OperatingSystem timeOfLastAccess:'/' |
|
4138 |
" |
|
359 | 4139 |
! |
4140 |
||
616 | 4141 |
timeOfLastChange:aPathName |
4142 |
"return the time, when the file was last changed. |
|
4143 |
For nonexistent files, nil is returned." |
|
4144 |
||
4145 |
"could be implemented as: |
|
4146 |
(self infoOf:aPathName) at:#modified |
|
4147 |
" |
|
4148 |
||
4149 |
|timeLow timeHi| |
|
4150 |
%{ |
|
4151 |
struct stat buf; |
|
4152 |
int ret; |
|
4153 |
time_t mtime; |
|
4154 |
||
4155 |
if (__isString(aPathName)) { |
|
4156 |
__BEGIN_INTERRUPTABLE__ |
|
4157 |
do { |
|
1135 | 4158 |
ret = stat((char *) __stringVal(aPathName), &buf); |
616 | 4159 |
} while (ret < 0 && errno == EINTR); |
4160 |
__END_INTERRUPTABLE__ |
|
4161 |
if (ret < 0) { |
|
1135 | 4162 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 4163 |
RETURN ( nil ); |
4164 |
} |
|
1135 | 4165 |
timeLow = __MKSMALLINT(buf.st_mtime & 0xFFFF); |
4166 |
timeHi = __MKSMALLINT((buf.st_mtime >> 16) & 0xFFFF); |
|
616 | 4167 |
} |
792 | 4168 |
%}. |
616 | 4169 |
timeLow notNil ifTrue:[^ AbsoluteTime fromOSTimeLow:timeLow and:timeHi]. |
792 | 4170 |
^ self primitiveFailed |
616 | 4171 |
|
4172 |
" |
|
4173 |
OperatingSystem timeOfLastChange:'/' |
|
4174 |
" |
|
4175 |
! |
|
4176 |
||
4177 |
typeOf:aPathName |
|
4178 |
"return the type of a file as a symbol" |
|
4179 |
||
4180 |
" |
|
4181 |
this could have been implemented as: |
|
4182 |
(self infoOf:aPathName) at:#type |
|
4183 |
but for huge directory searches the code below is faster |
|
4184 |
" |
|
359 | 4185 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4186 |
%{ |
616 | 4187 |
struct stat buf; |
4188 |
int ret; |
|
4189 |
||
4190 |
if (__isString(aPathName)) { |
|
4191 |
__BEGIN_INTERRUPTABLE__ |
|
4192 |
do { |
|
1135 | 4193 |
ret = stat((char *) __stringVal(aPathName), &buf); |
616 | 4194 |
} while (ret < 0 && errno == EINTR); |
4195 |
__END_INTERRUPTABLE__ |
|
4196 |
if (ret < 0) { |
|
1135 | 4197 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 4198 |
RETURN ( nil ); |
4199 |
} |
|
4200 |
switch (buf.st_mode & S_IFMT) { |
|
4201 |
case S_IFDIR: |
|
4202 |
RETURN ( @symbol(directory) ); |
|
4203 |
case S_IFREG: |
|
4204 |
RETURN ( @symbol(regular) ); |
|
4205 |
#ifdef S_IFCHR |
|
4206 |
case S_IFCHR: |
|
4207 |
RETURN ( @symbol(characterSpecial) ); |
|
4208 |
#endif |
|
4209 |
#ifdef S_IFBLK |
|
4210 |
case S_IFBLK: |
|
4211 |
RETURN ( @symbol(blockSpecial) ); |
|
4212 |
#endif |
|
4213 |
#ifdef S_IFLNK |
|
4214 |
case S_IFLNK: |
|
4215 |
RETURN ( @symbol(symbolicLink) ); |
|
4216 |
#endif |
|
4217 |
#ifdef S_IFSOCK |
|
4218 |
case S_IFSOCK: |
|
4219 |
RETURN ( @symbol(socket) ); |
|
4220 |
#endif |
|
4221 |
#ifdef S_IFIFO |
|
4222 |
case S_IFIFO: |
|
4223 |
RETURN ( @symbol(fifo) ); |
|
4224 |
#endif |
|
4225 |
default: |
|
4226 |
RETURN ( @symbol(unknown) ); |
|
4227 |
} |
|
4228 |
} |
|
4229 |
%}. |
|
792 | 4230 |
^ self primitiveFailed |
616 | 4231 |
|
4232 |
" |
|
4233 |
OperatingSystem typeOf:'/' |
|
4234 |
OperatingSystem typeOf:'.' |
|
4235 |
OperatingSystem typeOf:'Make.proto' |
|
4236 |
" |
|
68 | 4237 |
! ! |
4238 |
||
63 | 4239 |
!OperatingSystem class methodsFor:'interrupts & signals'! |
4240 |
||
10 | 4241 |
blockInterrupts |
95 | 4242 |
"disable interrupt processing - if disabled, incoming |
4243 |
interrupts will be registered and handled as soon as |
|
4244 |
interrupts are reenabled by OperatingSystemclass>>unblockInterrupts. |
|
4245 |
Returns the previous blocking status i.e. true if interrupts |
|
4246 |
where already blocked. You need this information for proper |
|
4247 |
unblocking, in case of nested block/unblock calls." |
|
4248 |
||
4249 |
%{ /* NOCONTEXT */ |
|
710 | 4250 |
RETURN ( __BLOCKINTERRUPTS() ); |
10 | 4251 |
%} |
4252 |
! |
|
4253 |
||
616 | 4254 |
defaultSignal:signalNumber |
4255 |
"revert to the default action on arrival of a (Unix-)signal. |
|
4256 |
Dont confuse Unix signals with smalltalk signals. |
|
4257 |
WARNING: for some signals, it is no good idea to revert to default; |
|
4258 |
for example, the default for SIGINT (i.e. ^C) is to exit; while the |
|
4259 |
default for SIGQUIT (^ \) is to dump core. |
|
4260 |
Also, NOTICE that signal numbers are not portable between unix |
|
4261 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
4262 |
a signal." |
|
4263 |
||
4264 |
%{ /* NOCONTEXT */ |
|
4265 |
||
4266 |
if (__isSmallInteger(signalNumber)) { |
|
831 | 4267 |
#ifdef SIG_DFL |
1135 | 4268 |
signal(__intVal(signalNumber), SIG_DFL); |
616 | 4269 |
RETURN (self); |
831 | 4270 |
#endif |
616 | 4271 |
} |
4272 |
%}. |
|
4273 |
" |
|
4274 |
this error is triggered on non-integer argument |
|
4275 |
" |
|
792 | 4276 |
^ self primitiveFailed |
616 | 4277 |
|
4278 |
"you better save a snapshot image before trying this ..." |
|
4279 |
" |
|
4280 |
'if you hit ^C now, Smalltalk will exit immediately' printNewline. |
|
4281 |
OperatingSystem defaultSignal:(OperatingSystem sigINT). |
|
4282 |
1 to:1000000 do:[:i| ]. |
|
4283 |
OperatingSystem enableSignal:(OperatingSystem sigINT). |
|
4284 |
'normal ^C handling again.' printNewline |
|
4285 |
" |
|
4286 |
! |
|
4287 |
||
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4288 |
disableChildSignalInterrupts |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4289 |
"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
|
4290 |
(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
|
4291 |
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
|
4292 |
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
|
4293 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4294 |
^ 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
|
4295 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4296 |
"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
|
4297 |
! |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4298 |
|
616 | 4299 |
disableIOInterruptsOn:fd |
4300 |
"turn off IO interrupts for a filedescriptor" |
|
4301 |
||
4302 |
%{ /* NOCONTEXT */ |
|
4303 |
||
4304 |
int ret, flags, f; |
|
4305 |
||
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4306 |
#if (defined(F_GETFL) && defined(F_SETFL) && defined(FASYNC)) || defined(SYSV4) |
616 | 4307 |
if (__isSmallInteger(fd)) { |
1135 | 4308 |
f = __intVal(fd); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4309 |
# if defined(SYSV4) |
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
756
diff
changeset
|
4310 |
ret = ioctl(f, I_SETSIG, 0); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4311 |
# else /*! SYSV4*/ |
616 | 4312 |
flags = fcntl(f, F_GETFL, 0); |
4313 |
/* |
|
4314 |
* if already clear, there is no need for this syscall ... |
|
4315 |
*/ |
|
4316 |
if (flags & FASYNC) { |
|
4317 |
ret = fcntl(f, F_SETFL, flags & ~FASYNC); |
|
4318 |
if (ret >= 0) ret = flags; |
|
4319 |
} else { |
|
4320 |
ret = flags; |
|
4321 |
} |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4322 |
# endif /* !SYSV4 */ |
1135 | 4323 |
RETURN ( __MKSMALLINT(ret) ); |
616 | 4324 |
} |
4325 |
#endif |
|
4326 |
%}. |
|
4327 |
" |
|
4328 |
this error is triggered on non-integer argument |
|
4329 |
or if the OS does not support IO interrupts. |
|
4330 |
" |
|
792 | 4331 |
^ self primitiveFailed |
10 | 4332 |
! |
4333 |
||
63 | 4334 |
disableSignal:signalNumber |
95 | 4335 |
"disable (Unix-) signal processing for signalNumber. |
4336 |
Dont confuse Unix signals with smalltalk signals. |
|
63 | 4337 |
WARNING: for some signals, it is no good idea to disable |
95 | 4338 |
them; for example, disabling the SIGINT signal turns off ^C |
63 | 4339 |
handling. |
68 | 4340 |
Also, NOTICE that signal numbers are not portable between unix |
4341 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
4342 |
a signal. |
|
63 | 4343 |
Use only for fully debugged stand alone applications." |
4344 |
||
4345 |
%{ /* NOCONTEXT */ |
|
4346 |
||
252 | 4347 |
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
|
4348 |
int sigNo = __intVal(signalNumber); |
831 | 4349 |
|
4350 |
if (sigNo == 0) { |
|
4351 |
RETURN (self); |
|
4352 |
} |
|
4353 |
#ifdef SIG_IGN |
|
4354 |
signal(sigNo, SIG_IGN); |
|
185 | 4355 |
RETURN (self); |
831 | 4356 |
#endif |
63 | 4357 |
} |
68 | 4358 |
%}. |
4359 |
" |
|
4360 |
this error is triggered on non-integer argument |
|
4361 |
" |
|
792 | 4362 |
^ self primitiveFailed |
68 | 4363 |
|
4364 |
" |
|
4365 |
'now, ^C is totally ignored ...' printNewline. |
|
4366 |
OperatingSystem disableSignal:(OperatingSystem sigINT). |
|
4367 |
1 to:1000000 do:[:i| ]. |
|
4368 |
OperatingSystem enableSignal:(OperatingSystem sigINT). |
|
4369 |
'^C handled again.' printNewline |
|
4370 |
" |
|
4371 |
! |
|
4372 |
||
616 | 4373 |
disableTimer |
831 | 4374 |
"disable timer interrupts. |
4375 |
WARNING: |
|
4376 |
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
|
4377 |
disabled, because no scheduling or timeouts are possible." |
616 | 4378 |
|
4379 |
%{ /* NOCONTEXT */ |
|
4380 |
||
4381 |
#if defined(ITIMER_REAL) |
|
4382 |
struct itimerval dt; |
|
4383 |
||
4384 |
dt.it_interval.tv_sec = 0; |
|
4385 |
dt.it_interval.tv_usec = 0; |
|
4386 |
dt.it_value.tv_sec = 0; |
|
4387 |
dt.it_value.tv_usec = 0; |
|
4388 |
setitimer(ITIMER_REAL, &dt, 0); |
|
4389 |
RETURN (true); |
|
831 | 4390 |
#endif /* ITIMER_REAL */ |
616 | 4391 |
%} |
4392 |
. |
|
4393 |
^ false |
|
4394 |
! |
|
4395 |
||
4396 |
disableUserInterrupts |
|
4397 |
"disable userInterrupt processing; |
|
4398 |
when disabled, no ^C processing takes place. |
|
831 | 4399 |
WARNING: |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4400 |
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
|
4401 |
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
|
4402 |
We recommend setting up a handler for the signal instead of disabling it." |
831 | 4403 |
|
4404 |
self disableSignal:(self sigBREAK). |
|
4405 |
self disableSignal:(self sigINT). |
|
616 | 4406 |
! |
4407 |
||
4408 |
enableAbortInterrupts |
|
4409 |
"enable abort signalhandling, and make it a regular signalInterrupt. |
|
4410 |
(the default will dump core and exit - which is not a good idea for |
|
4411 |
end-user applications ...). |
|
4412 |
This is especially useful, if linked-in C-libraries call abort() ..." |
|
4413 |
||
831 | 4414 |
self enableSignal:(self sigABRT) |
616 | 4415 |
! |
4416 |
||
4417 |
enableChildSignalInterrupts |
|
4418 |
"enable childSignal interrupts |
|
4419 |
(SIGCHLD, if the architecture supports it). |
|
831 | 4420 |
After enabling, these signals will send the message |
616 | 4421 |
'childSignalInterrupt' to the ChildSignalInterruptHandler object." |
4422 |
||
831 | 4423 |
self enableSignal:(self sigCHLD) |
616 | 4424 |
! |
4425 |
||
4426 |
enableFpExceptionInterrupts |
|
4427 |
"enable floating point exception interrupts (if the |
|
4428 |
architecture supports it). |
|
831 | 4429 |
After enabling, fpu-exceptions will send the message |
616 | 4430 |
'fpuExceptionInterrupt' to the FPUExceptionInterruptHandler object." |
4431 |
||
831 | 4432 |
self enableSignal:(self sigFP) |
616 | 4433 |
! |
4434 |
||
4435 |
enableHardSignalInterrupts |
|
4436 |
"enable hard signal exception interrupts (trap, buserror & segm. violation). |
|
831 | 4437 |
After enabling, these exceptions will send the message |
616 | 4438 |
'signalInterrupt' to the SignalInterruptHandler object." |
68 | 4439 |
|
855
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
4440 |
"/ 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
|
4441 |
"/ 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
|
4442 |
|
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
4443 |
"/ ... 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
|
4444 |
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
|
4445 |
|
640
be94dfc60eaa
Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents:
630
diff
changeset
|
4446 |
self enableSignal:(self sigBUS). |
be94dfc60eaa
Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents:
630
diff
changeset
|
4447 |
self enableSignal:(self sigSEGV) |
616 | 4448 |
! |
4449 |
||
4450 |
enableIOInterruptsOn:fd |
|
4451 |
"turn on IO interrupts for a filedescriptor" |
|
4452 |
||
4453 |
%{ /* NOCONTEXT */ |
|
4454 |
||
4455 |
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
|
4456 |
#ifndef __signalIoInterrupt |
616 | 4457 |
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
|
4458 |
#endif |
616 | 4459 |
static int firstCall = 1; |
4460 |
||
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4461 |
#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
|
4462 |
/* |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4463 |
* SIGIO/SIGPOLL - data available for I/O |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4464 |
* (used to wake up waiting processes) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4465 |
*/ |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4466 |
#ifdef SIGIO |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4467 |
# define THESIGNAL SIGIO |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4468 |
#else |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4469 |
# ifdef SIGPOLL |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4470 |
# define THESIGNAL SIGPOLL |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4471 |
# else |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4472 |
# ifdef SIGURG |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4473 |
# define THESIGNAL SIGURG |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4474 |
# endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4475 |
# endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4476 |
#endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4477 |
|
616 | 4478 |
if (__isSmallInteger(fd)) { |
4479 |
if (firstCall) { |
|
762
cea705669628
ok, stefan was right: HAS_SIGACTION works
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
4480 |
#ifdef HAS_SIGACTION |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4481 |
struct sigaction act; |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4482 |
|
1487 | 4483 |
/* |
4484 |
* Do not add SA_RESTART here. A signal can cause a |
|
4485 |
* thread switch, another thread can do a garbage collect |
|
4486 |
* and restarted system calls may write into old |
|
4487 |
* (collected) addresses. |
|
4488 |
*/ |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4489 |
|
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4490 |
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
|
4491 |
sigemptyset(&act.sa_mask); |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4492 |
act.sa_handler = __signalIoInterrupt; |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4493 |
sigaction(THESIGNAL, &act, 0); |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4494 |
#else |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4495 |
# ifdef HAS_SIGVEC |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4496 |
struct sigvec vec; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4497 |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4498 |
vec.sv_flags = SV_INTERRUPT; |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4499 |
sigemptyset(&vec.sv_mask); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4500 |
vec.sv_handler = __signalIoInterrupt; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4501 |
sigvec(THESIGNAL, &vec, NULL); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4502 |
# else |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4503 |
signal(THESIGNAL, __signalIoInterrupt); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4504 |
# endif |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4505 |
#endif |
616 | 4506 |
firstCall = 0; |
4507 |
} |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4508 |
#undef THESIGNAL |
616 | 4509 |
|
1135 | 4510 |
f = __intVal(fd); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4511 |
# if defined(SYSV4) |
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
756
diff
changeset
|
4512 |
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
|
4513 |
# else /*! SYSV4*/ |
616 | 4514 |
flags = fcntl(f, F_GETFL, 0); |
4515 |
/* |
|
4516 |
* if already set, there is no need for this syscall ... |
|
4517 |
*/ |
|
4518 |
if (flags & FASYNC) { |
|
4519 |
ret = flags; |
|
4520 |
} else { |
|
4521 |
ret = fcntl(f, F_SETFL, flags | FASYNC); |
|
4522 |
if (ret >= 0) ret = flags; |
|
4523 |
} |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4524 |
# endif /*!SYSV4*/ |
1135 | 4525 |
RETURN ( __MKSMALLINT(ret) ); |
68 | 4526 |
} |
616 | 4527 |
#endif |
68 | 4528 |
%}. |
4529 |
" |
|
4530 |
this error is triggered on non-integer argument |
|
616 | 4531 |
or if the system does not support SIGIO |
68 | 4532 |
" |
792 | 4533 |
^ self primitiveFailed |
616 | 4534 |
! |
4535 |
||
4536 |
enableQuitInterrupts |
|
4537 |
"enable quitInterrupt (usually ^\) handling, and make it a userInterrupt. |
|
4538 |
(the default will dump core and exit - which is not a good idea for |
|
4539 |
end-user applications ...)" |
|
4540 |
||
831 | 4541 |
self enableSignal:(self sigQUIT) |
68 | 4542 |
! |
4543 |
||
4544 |
enableSignal:signalNumber |
|
95 | 4545 |
"enable (Unix-)signal processing for signalNumber. |
4546 |
Dont confuse Unix signals with smalltalk signals. |
|
68 | 4547 |
The signal will be delivered to one of the standard handlers |
4548 |
(SIGINT, SIGQUIT, etc) or to a general handler, which |
|
4549 |
sends #signalInterrupt:. |
|
4550 |
||
4551 |
NOTICE that signal numbers are not portable between unix |
|
4552 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
4553 |
a signal." |
|
4554 |
||
4555 |
%{ /* NOCONTEXT */ |
|
4556 |
||
4557 |
#ifdef NSIG |
|
4558 |
# define SIG_LIMIT NSIG |
|
4559 |
#else |
|
4560 |
# ifdef SIGUSR2 |
|
4561 |
# define SIG_LIMIT SIGUSR2 |
|
4562 |
# else |
|
4563 |
# ifdef SIGUSR |
|
4564 |
# define SIG_LIMIT SIGUSR |
|
4565 |
# endif |
|
4566 |
# endif |
|
4567 |
#endif |
|
4568 |
||
4569 |
#if defined(SIGPOLL) && !defined(SIGIO) |
|
4570 |
# define SIGIO SIGPOLL |
|
4571 |
#endif |
|
4572 |
||
4573 |
#ifdef SIGCHLD |
|
4574 |
# define CHILD_SIGNAL SIGCHLD |
|
4575 |
#else |
|
4576 |
# ifdef SIGCLD |
|
4577 |
# define CHILD_SIGNAL SIGCLD |
|
4578 |
# endif |
|
4579 |
#endif |
|
4580 |
||
4581 |
int sigNr; |
|
443 | 4582 |
#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
|
4583 |
# ifndef __signalUserInterrupt |
831 | 4584 |
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
|
4585 |
# endif |
443 | 4586 |
#endif |
4587 |
#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
|
4588 |
# ifndef __signalFpExceptionInterrupt |
831 | 4589 |
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
|
4590 |
# endif |
443 | 4591 |
#endif |
4592 |
#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
|
4593 |
# ifndef __signalIoInterrupt |
831 | 4594 |
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
|
4595 |
# endif |
443 | 4596 |
#endif |
68 | 4597 |
#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
|
4598 |
# ifndef __signalChildInterrupt |
831 | 4599 |
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
|
4600 |
# endif |
68 | 4601 |
#endif |
443 | 4602 |
#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
|
4603 |
# ifndef __signalPIPEInterrupt |
831 | 4604 |
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
|
4605 |
# endif |
443 | 4606 |
#endif |
4607 |
#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
|
4608 |
# ifndef __signalBUSInterrupt |
831 | 4609 |
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
|
4610 |
# endif |
443 | 4611 |
#endif |
4612 |
#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
|
4613 |
# ifndef __signalSEGVInterrupt |
831 | 4614 |
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
|
4615 |
# endif |
443 | 4616 |
#endif |
4617 |
#ifdef SIGALRM |
|
831 | 4618 |
# 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
|
4619 |
# ifndef __signalTimerInterrupt |
831 | 4620 |
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
|
4621 |
# endif |
831 | 4622 |
# endif |
4623 |
#endif |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4624 |
#ifndef __signalInterrupt |
831 | 4625 |
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
|
4626 |
#endif |
831 | 4627 |
void (*handler)(SIGHANDLER_ARG); |
68 | 4628 |
|
252 | 4629 |
if (__isSmallInteger(signalNumber) |
1135 | 4630 |
&& ((sigNr = __intVal(signalNumber)) >= 0) |
831 | 4631 |
#ifdef SIG_LIMIT |
4632 |
&& (sigNr <= SIG_LIMIT) |
|
4633 |
#endif |
|
4634 |
) { |
|
185 | 4635 |
/* |
4636 |
* standard signals are forced into standard handlers |
|
4637 |
* - all others go into general signalInterrupt |
|
4638 |
*/ |
|
68 | 4639 |
#if defined(SIGPOLL) && defined(SIGIO) |
185 | 4640 |
if (sigNr == SIGPOLL) |
4641 |
sigNr = SIGIO; |
|
68 | 4642 |
#endif |
185 | 4643 |
switch (sigNr) { |
831 | 4644 |
case 0: |
4645 |
/* enabling a non-supported signal */ |
|
4646 |
RETURN (self); |
|
4647 |
||
4648 |
#ifdef SIGBREAK |
|
4649 |
case SIGBREAK: |
|
4650 |
#endif |
|
443 | 4651 |
#ifdef SIGINT |
185 | 4652 |
case SIGINT: |
443 | 4653 |
#endif |
4654 |
#ifdef SIGQUIT |
|
185 | 4655 |
case SIGQUIT: |
443 | 4656 |
#endif |
831 | 4657 |
#if defined(SIGINT) || defined(SIGQUIT) || defined(SIGBREAK) |
329 | 4658 |
handler = __signalUserInterrupt; |
185 | 4659 |
break; |
443 | 4660 |
#endif |
4661 |
||
4662 |
#ifdef SIGFPE |
|
185 | 4663 |
case SIGFPE: |
329 | 4664 |
handler = __signalFpExceptionInterrupt; |
185 | 4665 |
break; |
443 | 4666 |
#endif |
4667 |
||
4668 |
#ifdef SIGPIPE |
|
185 | 4669 |
case SIGPIPE: |
329 | 4670 |
handler = __signalPIPEInterrupt; |
185 | 4671 |
break; |
443 | 4672 |
#endif |
68 | 4673 |
#ifdef SIGBUS |
185 | 4674 |
case SIGBUS: |
329 | 4675 |
handler = __signalBUSInterrupt; |
185 | 4676 |
break; |
68 | 4677 |
#endif |
443 | 4678 |
#ifdef SIGSEGV |
185 | 4679 |
case SIGSEGV: |
329 | 4680 |
handler = __signalSEGVInterrupt; |
185 | 4681 |
break; |
443 | 4682 |
#endif |
68 | 4683 |
#ifdef SIGIO |
185 | 4684 |
case SIGIO: |
329 | 4685 |
handler = __signalIoInterrupt; |
185 | 4686 |
break; |
68 | 4687 |
#endif |
4688 |
||
4689 |
#ifdef CHILD_SIGNAL |
|
185 | 4690 |
case CHILD_SIGNAL: |
329 | 4691 |
handler = __signalChildInterrupt; |
185 | 4692 |
break; |
68 | 4693 |
#endif |
443 | 4694 |
#ifdef SIGALRM |
831 | 4695 |
# ifndef WIN32 |
185 | 4696 |
case SIGALRM: |
329 | 4697 |
handler = __signalTimerInterrupt; |
185 | 4698 |
break; |
831 | 4699 |
# endif |
443 | 4700 |
#endif |
185 | 4701 |
|
4702 |
default: |
|
329 | 4703 |
handler = __signalInterrupt; |
185 | 4704 |
break; |
4705 |
} |
|
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4706 |
|
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4707 |
{ |
762
cea705669628
ok, stefan was right: HAS_SIGACTION works
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
4708 |
#ifdef HAS_SIGACTION |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4709 |
struct sigaction act; |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4710 |
|
1487 | 4711 |
/* |
4712 |
* Do not add SA_RESTART here. A signal can cause a |
|
4713 |
* thread switch, another thread can do a garbage collect |
|
4714 |
* and restarted system calls may write into old |
|
4715 |
* (collected) addresses. |
|
4716 |
*/ |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4717 |
|
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4718 |
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
|
4719 |
sigemptyset(&act.sa_mask); |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4720 |
act.sa_handler = handler; |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4721 |
sigaction(sigNr, &act, 0); |
213 | 4722 |
#else |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4723 |
# ifdef HAS_SIGVEC |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4724 |
struct sigvec vec; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4725 |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4726 |
vec.sv_flags = SV_INTERRUPT; |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4727 |
sigemptyset(&vec.sv_mask); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4728 |
vec.sv_handler = handler; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4729 |
sigvec(sigNr, &vec, NULL); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4730 |
# else |
831 | 4731 |
(void) signal(sigNr, handler); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4732 |
# endif |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4733 |
#endif |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4734 |
} |
213 | 4735 |
|
185 | 4736 |
/* |
4737 |
* maybe, we should return the old enable-status |
|
4738 |
* as boolean here ... |
|
4739 |
*/ |
|
4740 |
RETURN (self); |
|
68 | 4741 |
} |
4742 |
%}. |
|
4743 |
||
4744 |
" |
|
4745 |
this error is triggered on non-integer argument, or |
|
4746 |
if the signal number is not in the valid range (1..NSIG) |
|
4747 |
" |
|
792 | 4748 |
^ self primitiveFailed |
63 | 4749 |
! |
4750 |
||
831 | 4751 |
enableTimer:milliSeconds |
616 | 4752 |
"trigger a timerInterrupt, to be signalled after some (real) time." |
4753 |
||
4754 |
%{ /* NOCONTEXT */ |
|
831 | 4755 |
int millis; |
4756 |
||
4757 |
millis = __intVal(milliSeconds); |
|
616 | 4758 |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4759 |
#if defined(ITIMER_REAL) |
831 | 4760 |
{ |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4761 |
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
|
4762 |
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
|
4763 |
#ifndef __signalTimerInterrupt |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4764 |
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
|
4765 |
#endif |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4766 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4767 |
if (firstCall) { |
831 | 4768 |
# ifdef HAS_SIGACTION |
4769 |
struct sigaction act; |
|
4770 |
||
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4771 |
act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */ |
831 | 4772 |
sigemptyset(&act.sa_mask); |
4773 |
act.sa_handler = __signalTimerInterrupt; |
|
4774 |
sigaction(SIGALRM, &act, 0); |
|
4775 |
# else |
|
4776 |
# 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
|
4777 |
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
|
4778 |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4779 |
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
|
4780 |
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
|
4781 |
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
|
4782 |
sigvec(SIGALRM, &vec, NULL); |
831 | 4783 |
# else |
4784 |
signal(SIGALRM, __signalTimerInterrupt); |
|
4785 |
# endif |
|
4786 |
# endif |
|
4787 |
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
|
4788 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4789 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4790 |
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
|
4791 |
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
|
4792 |
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
|
4793 |
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
|
4794 |
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
|
4795 |
RETURN (true); |
831 | 4796 |
} |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4797 |
#else |
831 | 4798 |
# ifdef WIN32 |
4799 |
{ |
|
4800 |
/* |
|
4801 |
* two mechanisms - which one to use ? |
|
4802 |
*/ |
|
4803 |
# define USE_TimerProc |
|
4804 |
# ifdef USE_TimerProc |
|
4805 |
||
4806 |
extern VOID CALLBACK __win32TimerProc(HWND, UINT, UINT, DWORD); |
|
4807 |
SetTimer(NULL, 0, millis, __win32TimerProc); |
|
4808 |
||
4809 |
# else /* USE_TimeProc */ |
|
4810 |
||
4811 |
extern void CALLBACK __win32TimeProc(UINT, UINT, DWORD, DWORD, DWORD, DWORD); |
|
4812 |
timeSetEvent(millis, 5, __win32TimeProc, 0, TIME_ONESHOT); |
|
4813 |
# endif |
|
640
be94dfc60eaa
Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents:
630
diff
changeset
|
4814 |
} |
831 | 4815 |
# endif /* WIN32 */ |
4816 |
#endif /* ITIMER_REAL */ |
|
4817 |
%}. |
|
616 | 4818 |
^ false |
4819 |
! |
|
4820 |
||
1 | 4821 |
enableUserInterrupts |
4822 |
"enable userInterrupt (^C) handling; |
|
95 | 4823 |
when enabled, ^C in the terminal window will send the message |
4824 |
'userInterrupt' to the UserInterruptHandler object." |
|
1 | 4825 |
|
831 | 4826 |
self enableSignal:(self sigINT). |
4827 |
self enableSignal:(self sigBREAK). |
|
63 | 4828 |
! |
4829 |
||
616 | 4830 |
interruptPending |
4831 |
"return true, if an interrupt is pending. The returned value is |
|
4832 |
invalid if interrupts are not currently blocked, since otherwise |
|
4833 |
the interrupt is usually already handled before arriving here, |
|
4834 |
or may be served while returning from here." |
|
4835 |
||
4836 |
%{ /* NOCONTEXT */ |
|
4837 |
extern OBJ __INTERRUPTPENDING(); |
|
4838 |
||
4839 |
RETURN ( __INTERRUPTPENDING() ); |
|
4840 |
%} |
|
1 | 4841 |
! |
4842 |
||
704 | 4843 |
killProcess:processId |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
4844 |
"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
|
4845 |
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
|
4846 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4847 |
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
|
4848 |
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
|
4849 |
OperatingSystem>>getStatusOfProcess:aProcessId." |
704 | 4850 |
|
4851 |
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
|
4852 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
4853 |
"Modified: 28.12.1995 / 15:06:18 / stefan" |
704 | 4854 |
! |
4855 |
||
616 | 4856 |
nameForSignal:aSignalNumber |
4857 |
"for a given Unix signalnumber, return a descriptive string" |
|
4858 |
||
4859 |
aSignalNumber == self sigHUP ifTrue:[^ 'hangup']. |
|
4860 |
aSignalNumber == self sigINT ifTrue:[^ 'interrupt']. |
|
4861 |
aSignalNumber == self sigKILL ifTrue:[^ 'kill']. |
|
4862 |
aSignalNumber == self sigQUIT ifTrue:[^ 'quit']. |
|
4863 |
aSignalNumber == self sigILL ifTrue:[^ 'illegal instruction']. |
|
4864 |
aSignalNumber == self sigTRAP ifTrue:[^ 'trap']. |
|
4865 |
aSignalNumber == self sigABRT ifTrue:[^ 'abort']. |
|
4866 |
aSignalNumber == self sigIOT ifTrue:[^ 'iot trap']. |
|
4867 |
aSignalNumber == self sigEMT ifTrue:[^ 'emt trap']. |
|
4868 |
aSignalNumber == self sigFP ifTrue:[^ 'fp exception']. |
|
4869 |
aSignalNumber == self sigBUS ifTrue:[^ 'bus error']. |
|
4870 |
aSignalNumber == self sigSEGV ifTrue:[^ 'segmentation violation']. |
|
4871 |
aSignalNumber == self sigSYS ifTrue:[^ 'bad system call']. |
|
4872 |
aSignalNumber == self sigPIPE ifTrue:[^ 'broken pipe']. |
|
4873 |
aSignalNumber == self sigALRM ifTrue:[^ 'alarm timer']. |
|
4874 |
aSignalNumber == self sigTERM ifTrue:[^ 'termination']. |
|
4875 |
aSignalNumber == self sigSTOP ifTrue:[^ 'stop']. |
|
4876 |
aSignalNumber == self sigTSTP ifTrue:[^ 'tty stop']. |
|
4877 |
aSignalNumber == self sigCONT ifTrue:[^ 'continue']. |
|
4878 |
aSignalNumber == self sigCHLD ifTrue:[^ 'child death']. |
|
4879 |
aSignalNumber == self sigTTIN ifTrue:[^ 'background tty input']. |
|
4880 |
aSignalNumber == self sigTTOU ifTrue:[^ 'background tty output']. |
|
4881 |
aSignalNumber == self sigIO ifTrue:[^ 'io available']. |
|
4882 |
aSignalNumber == self sigXCPU ifTrue:[^ 'cpu time expired']. |
|
4883 |
aSignalNumber == self sigXFSZ ifTrue:[^ 'file size limit']. |
|
4884 |
aSignalNumber == self sigVTALRM ifTrue:[^ 'virtual alarm timer']. |
|
4885 |
aSignalNumber == self sigPROF ifTrue:[^ 'profiling timer']. |
|
4886 |
aSignalNumber == self sigWINCH ifTrue:[^ 'winsize changed']. |
|
4887 |
aSignalNumber == self sigLOST ifTrue:[^ 'resource lost']. |
|
4888 |
aSignalNumber == self sigUSR1 ifTrue:[^ 'user signal 1']. |
|
4889 |
aSignalNumber == self sigUSR2 ifTrue:[^ 'user signal 2']. |
|
4890 |
aSignalNumber == self sigMSG ifTrue:[^ 'HFT message']. |
|
4891 |
aSignalNumber == self sigPWR ifTrue:[^ 'power-fail']. |
|
4892 |
aSignalNumber == self sigPRE ifTrue:[^ 'programming exception']. |
|
4893 |
aSignalNumber == self sigGRANT ifTrue:[^ 'HFT access wanted']. |
|
4894 |
aSignalNumber == self sigRETRACT ifTrue:[^ 'HFT access relinquish']. |
|
4895 |
aSignalNumber == self sigSOUND ifTrue:[^ 'HFT sound complete']. |
|
4896 |
aSignalNumber == self sigDANGER ifTrue:[^ 'low on paging space']. |
|
4897 |
||
4898 |
"notice: many systems map SIGPOLL and/or SIGUSR onto SIGIO |
|
4899 |
therefore, keep SIGIO always above the two below" |
|
4900 |
aSignalNumber == self sigPOLL ifTrue:[^ 'io available']. |
|
4901 |
aSignalNumber == self sigURG ifTrue:[^ 'urgent']. |
|
4902 |
||
4903 |
^ 'unknown signal' |
|
4904 |
||
68 | 4905 |
" |
616 | 4906 |
OperatingSystem nameForSignal:9 |
4907 |
OperatingSystem nameForSignal:(OperatingSystem sigPOLL) |
|
68 | 4908 |
" |
616 | 4909 |
! |
4910 |
||
4911 |
operatingSystemSignal:signalNumber |
|
4912 |
"return the signal to be raised when an |
|
4913 |
operatingSystem-signal occurs, or nil" |
|
4914 |
||
4915 |
OSSignals notNil ifTrue:[ |
|
4916 |
^ OSSignals at:signalNumber ifAbsent:[nil] |
|
4917 |
]. |
|
4918 |
^ nil |
|
10 | 4919 |
! |
4920 |
||
616 | 4921 |
operatingSystemSignal:signalNumber install:aSignal |
4922 |
"install a signal to be raised when an operatingSystem-signal occurs" |
|
4923 |
||
4924 |
OSSignals isNil ifTrue:[ |
|
4925 |
OSSignals := Array new:32 |
|
4926 |
]. |
|
4927 |
OSSignals at:signalNumber put:aSignal |
|
4928 |
! |
|
4929 |
||
4930 |
sendSignal:signalNumber to:processId |
|
4931 |
"send a unix signal to some process (maybe myself). |
|
4932 |
Returns false if any error occurred, true otherwise. |
|
4933 |
||
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4934 |
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
|
4935 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4936 |
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
|
4937 |
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
|
4938 |
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
|
4939 |
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
|
4940 |
|
616 | 4941 |
%{ |
792 | 4942 |
#ifndef MSDOS_LIKE |
616 | 4943 |
if (__bothSmallInteger(signalNumber, processId)) { |
4944 |
if (kill(__intVal(processId), __intVal(signalNumber)) < 0) { |
|
1135 | 4945 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 4946 |
RETURN ( false ); |
216 | 4947 |
} |
616 | 4948 |
RETURN ( true ); |
10 | 4949 |
} |
792 | 4950 |
#endif |
68 | 4951 |
%}. |
792 | 4952 |
"/ |
4953 |
"/ either invalid argument (non-integers) |
|
4954 |
"/ or not supported by OS |
|
4955 |
"/ |
|
4956 |
^ self primitiveFailed |
|
1 | 4957 |
! |
4958 |
||
4959 |
startSpyTimer |
|
63 | 4960 |
"trigger a spyInterrupt, to be signalled after some short (virtual) time. |
359 | 4961 |
This is used by the old MessageTally for profiling. |
63 | 4962 |
Should be changed to use real profiling timer if available. |
68 | 4963 |
On systems, where no virtual timer is available, use the real timer |
359 | 4964 |
(which is of course less correct). |
4965 |
OBSOLETE: the new messageTally runs as a high prio process, not using |
|
4966 |
spy interrupts." |
|
1 | 4967 |
|
4968 |
%{ /* NOCONTEXT */ |
|
4969 |
||
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4970 |
#ifndef __spyInterrupt |
329 | 4971 |
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
|
4972 |
#endif |
10 | 4973 |
#if defined(ITIMER_VIRTUAL) |
1 | 4974 |
struct itimerval dt; |
4975 |
||
13 | 4976 |
# ifdef SIGVTALRM |
329 | 4977 |
signal(SIGVTALRM, __spyInterrupt); |
13 | 4978 |
# else |
329 | 4979 |
signal(SIGALRM, __spyInterrupt); |
13 | 4980 |
# endif |
4981 |
||
348 | 4982 |
dt.it_interval.tv_sec = 0; |
4983 |
dt.it_interval.tv_usec = 0; |
|
4984 |
dt.it_value.tv_sec = 0; |
|
4985 |
dt.it_value.tv_usec = 1000; /* 1000 Hz */ |
|
4986 |
setitimer(ITIMER_VIRTUAL, &dt, 0); |
|
4987 |
||
13 | 4988 |
RETURN (true); |
1 | 4989 |
#endif |
4990 |
%} |
|
13 | 4991 |
. |
4992 |
^ false |
|
1 | 4993 |
! |
4994 |
||
4995 |
stopSpyTimer |
|
359 | 4996 |
"stop spy timing - disable spy timer. |
4997 |
OBSOLETE: the new messageTally runs as a high prio process, not using |
|
4998 |
spy interrupts." |
|
1 | 4999 |
|
5000 |
%{ /* NOCONTEXT */ |
|
5001 |
||
10 | 5002 |
#if defined(ITIMER_VIRTUAL) |
1 | 5003 |
struct itimerval dt; |
5004 |
||
5005 |
dt.it_interval.tv_sec = 0; |
|
5006 |
dt.it_interval.tv_usec = 0; |
|
5007 |
dt.it_value.tv_sec = 0; |
|
5008 |
dt.it_value.tv_usec = 0; |
|
5009 |
setitimer(ITIMER_VIRTUAL, &dt, 0); |
|
13 | 5010 |
RETURN (true); |
10 | 5011 |
#endif |
5012 |
%} |
|
13 | 5013 |
. |
5014 |
^ false |
|
10 | 5015 |
! |
5016 |
||
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5017 |
terminateProcess:processId |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5018 |
"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
|
5019 |
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
|
5020 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5021 |
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
|
5022 |
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
|
5023 |
OperatingSystem>>getStatusOfProcess:aProcessId." |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5024 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5025 |
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
|
5026 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5027 |
"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
|
5028 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5029 |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5030 |
terminateProcessGroup:processGroupId |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5031 |
"terminate a unix process group. |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5032 |
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
|
5033 |
|
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5034 |
WARNING: in order to avoid zombie processes (on unix), |
1487 | 5035 |
you may have to fetch the processes exitstatus with |
5036 |
OperatingSystem>>getStatusOfProcess:aProcessId." |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5037 |
|
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5038 |
self sendSignal:(self sigTERM) to:(processGroupId negated). |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5039 |
|
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5040 |
"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
|
5041 |
"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
|
5042 |
! |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5043 |
|
616 | 5044 |
unblockInterrupts |
5045 |
"enable interrupt processing - if any interrupts are pending, |
|
5046 |
these will be handled immediately. |
|
5047 |
When unblocking interrupts, take care of nested block/unblock |
|
5048 |
calls - you must only unblock after a blockcall if they where |
|
5049 |
really not blocked before. See OperatingSystemclass>>blockInterrupts." |
|
5050 |
%{ |
|
5051 |
__UNBLOCKINTERRUPTS(); |
|
1040
60e4c4bbbca2
return nil from unblockInterrupts (thats what the inlined code returns)
Claus Gittinger <cg@exept.de>
parents:
1034
diff
changeset
|
5052 |
RETURN (nil); |
616 | 5053 |
%} |
5054 |
! ! |
|
5055 |
||
5056 |
!OperatingSystem class methodsFor:'misc'! |
|
5057 |
||
5058 |
exit |
|
710 | 5059 |
"shutdown smalltalk immediately - this method does not return. |
5060 |
Return 'good'-status (0) to the parent unix process." |
|
616 | 5061 |
|
5062 |
%{ /* NOCONTEXT */ |
|
5063 |
__mainExit(0); |
|
5064 |
%} |
|
5065 |
"OperatingSystem exit - dont evaluate this" |
|
5066 |
! |
|
5067 |
||
5068 |
exit:exitCode |
|
5069 |
"shutdown smalltalk immediately - |
|
5070 |
returning an exit-code to the parent unix process." |
|
5071 |
||
5072 |
%{ /* NOCONTEXT */ |
|
5073 |
int code = 1; |
|
5074 |
||
5075 |
if (__isSmallInteger(exitCode)) { |
|
1135 | 5076 |
code = __intVal(exitCode); |
616 | 5077 |
} |
5078 |
__mainExit(code); |
|
5079 |
%} |
|
5080 |
"OperatingSystem exit:1 - dont evaluate this" |
|
5081 |
! |
|
5082 |
||
5083 |
exitWithCoreDump |
|
5084 |
"shutdown smalltalk immediately - dumping core. |
|
5085 |
This always returns 'bad'-status to the parent unix process. |
|
5086 |
Notice, that no cleanup is performed at all - you may have to |
|
5087 |
manually remove any tempfiles. |
|
5088 |
Use this only for debugging ST/X itself" |
|
5089 |
||
5090 |
%{ /* NOCONTEXT */ |
|
5091 |
abort(); |
|
5092 |
%} |
|
831 | 5093 |
" |
5094 |
OperatingSystem exitWithCoreDump - dont evaluate this |
|
5095 |
" |
|
616 | 5096 |
! |
5097 |
||
5098 |
slowFork:aBoolean |
|
1247 | 5099 |
"set/clear the `avoid-fork-if-possible-because-its-slow' flag. |
5100 |
Only used internally on SYSV3 systems" |
|
5101 |
||
616 | 5102 |
SlowFork := aBoolean |
1247 | 5103 |
|
5104 |
"Modified: 22.4.1996 / 13:13:09 / cg" |
|
616 | 5105 |
! ! |
5106 |
||
5107 |
!OperatingSystem class methodsFor:'os queries'! |
|
5108 |
||
5109 |
getCPUDefine |
|
831 | 5110 |
"return a string which was used to identify this CPU type when STX was |
616 | 5111 |
compiled, and which should be passed down when compiling methods. |
831 | 5112 |
For example, on linux, this may be '-Di386'; on a vax, this would be '-Dvax'. |
5113 |
This is normally not of interest to 'normal' users; however, it is passed |
|
5114 |
down to the c-compiler when methods are incrementally compiled to machine code." |
|
616 | 5115 |
|
5116 |
%{ /* NOCONTEXT */ |
|
831 | 5117 |
# ifndef CPU_DEFINE |
5118 |
# define CPU_DEFINE "-DunknownCPU" |
|
5119 |
# endif |
|
5120 |
||
616 | 5121 |
RETURN ( __MKSTRING(CPU_DEFINE COMMA_CON)); |
5122 |
%} |
|
5123 |
" |
|
5124 |
OperatingSystem getCPUDefine |
|
5125 |
" |
|
5126 |
! |
|
5127 |
||
5128 |
getCPUType |
|
5129 |
"return a string giving the type of machine we're running on. |
|
831 | 5130 |
Here, the machine for which ST/X was compiled is returned |
5131 |
(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
|
5132 |
This may normally not be of any interest to you ..." |
616 | 5133 |
|
5134 |
|cpu| |
|
5135 |
||
5136 |
%{ /* NOCONTEXT */ |
|
5137 |
||
5138 |
# ifdef vax |
|
5139 |
# define CPU_STRING "vax" |
|
5140 |
# endif |
|
5141 |
# ifdef mips |
|
5142 |
# define CPU_STRING "mips" |
|
5143 |
# endif |
|
5144 |
# ifdef i386 |
|
5145 |
# define CPU_STRING "i386" |
|
5146 |
# endif |
|
5147 |
# ifdef ns32k |
|
5148 |
# define CPU_STRING "ns32k" |
|
5149 |
# endif |
|
5150 |
# ifdef mc68k |
|
5151 |
# define CPU_STRING "mc68k" |
|
5152 |
# endif |
|
5153 |
# ifdef mc88k |
|
5154 |
# define CPU_STRING "mc88k" |
|
5155 |
# endif |
|
5156 |
# ifdef sparc |
|
5157 |
# define CPU_STRING "sparc" |
|
5158 |
# endif |
|
5159 |
# ifdef hppa |
|
5160 |
# define CPU_STRING "hppa" |
|
5161 |
# endif |
|
5162 |
# ifdef rs6000 |
|
5163 |
# define CPU_STRING "rs6000" |
|
5164 |
# endif |
|
831 | 5165 |
# ifdef powerPC |
5166 |
# define CPU_STRING "powerPC" |
|
5167 |
# endif |
|
616 | 5168 |
# ifdef alpha |
5169 |
# define CPU_STRING "alpha" |
|
5170 |
# endif |
|
5171 |
# ifdef transputer |
|
5172 |
# define CPU_STRING "transputer" |
|
5173 |
# endif |
|
5174 |
# ifdef ibm370 |
|
5175 |
# define CPU_STRING "ibm370" |
|
5176 |
# endif |
|
5177 |
||
5178 |
# ifndef CPU_STRING |
|
5179 |
# define CPU_STRING "unknown" |
|
5180 |
# endif |
|
5181 |
||
830 | 5182 |
cpu = __MKSTRING(CPU_STRING COMMA_CON); |
616 | 5183 |
# undef CPU_STRING |
831 | 5184 |
%}. |
616 | 5185 |
^ cpu |
5186 |
||
5187 |
" |
|
5188 |
OperatingSystem getCPUType |
|
5189 |
" |
|
5190 |
||
5191 |
"examples: are we running on a ss-10/solaris ?" |
|
5192 |
" |
|
5193 |
(OperatingSystem getCPUType = 'sparc') |
|
5194 |
and:[OperatingSystem getOSType = 'solaris'] |
|
5195 |
" |
|
5196 |
||
5197 |
"or on a pc/solaris ?" |
|
5198 |
" |
|
5199 |
(OperatingSystem getCPUType = 'i386') |
|
5200 |
and:[OperatingSystem getOSType = 'solaris'] |
|
5201 |
" |
|
5202 |
! |
|
5203 |
||
5204 |
getCommandOutputFrom:aCommand |
|
5205 |
"execute a simple command (such as hostname) and |
|
5206 |
return the commands output as a string" |
|
5207 |
||
5208 |
|p result| |
|
5209 |
||
5210 |
ForkFailed ifFalse:[ |
|
5211 |
PipeStream openErrorSignal handle:[:ex | |
|
5212 |
ForkFailed := true. |
|
5213 |
'OS: cannot fork/popen' errorPrintNL. |
|
5214 |
ex return. |
|
5215 |
] do:[ |
|
5216 |
p := PipeStream readingFrom:aCommand. |
|
5217 |
p notNil ifTrue:[ |
|
5218 |
result := p nextLine. |
|
5219 |
p close |
|
5220 |
] |
|
5221 |
] |
|
5222 |
]. |
|
5223 |
^ result |
|
5224 |
! |
|
5225 |
||
5226 |
getDomainName |
|
5227 |
"return the domain this host is in. |
|
5228 |
Notice: |
|
1487 | 5229 |
not all systems support this; on some, 'unknown' is returned." |
616 | 5230 |
|
5231 |
|name| |
|
5232 |
||
5233 |
DomainName notNil ifTrue:[ |
|
1487 | 5234 |
^ DomainName |
616 | 5235 |
]. |
5236 |
||
5237 |
%{ /* STACK: 2048 */ |
|
5238 |
#if defined(HAS_GETDOMAINNAME) |
|
5239 |
char buffer[128]; |
|
5240 |
||
5241 |
if (getdomainname(buffer, sizeof(buffer)) == 0) { |
|
1487 | 5242 |
name = __MKSTRING(buffer COMMA_CON); |
616 | 5243 |
} |
5244 |
#else |
|
5245 |
# if defined(HAS_UNAME) && defined(HAS_UTS_DOMAINNAME) |
|
5246 |
struct utsname ubuff; |
|
5247 |
||
5248 |
if (uname(&ubuff) >= 0) { |
|
1487 | 5249 |
name = __MKSTRING(ubuff.domainname COMMA_CON); |
1433 | 5250 |
} |
5251 |
# else |
|
5252 |
# if defined(HAS_SYSINFO) && defined(SI_SRPC_DOMAIN) |
|
5253 |
char buffer[256]; |
|
5254 |
int ret; |
|
5255 |
||
5256 |
if ((ret = sysinfo(SI_SRPC_DOMAIN, buffer, sizeof(buffer))) >= 0 && ret <= sizeof(buffer)) { |
|
1487 | 5257 |
name = __MKSTRING(buffer COMMA_CON); |
1433 | 5258 |
} |
5259 |
# endif |
|
616 | 5260 |
# endif |
5261 |
#endif |
|
5262 |
%}. |
|
5263 |
name isNil ifTrue:[ |
|
1487 | 5264 |
name := self getEnvironment:'DOMAIN'. |
5265 |
name isNil ifTrue:[ |
|
5266 |
name := self getCommandOutputFrom:'domainname' |
|
5267 |
] |
|
616 | 5268 |
]. |
5269 |
name isNil ifTrue:[ |
|
1487 | 5270 |
'OS: cannot find out domainname' errorPrintNL. |
5271 |
name := 'unknown'. |
|
616 | 5272 |
]. |
5273 |
DomainName := name. |
|
5274 |
^ name |
|
5275 |
||
5276 |
" |
|
5277 |
OperatingSystem getDomainName |
|
5278 |
" |
|
1433 | 5279 |
|
5280 |
"Modified: 26.4.1996 / 10:04:54 / stefan" |
|
616 | 5281 |
! |
5282 |
||
5283 |
getEnvironment:aStringOrSymbol |
|
5284 |
"get an environment string" |
|
10 | 5285 |
|
5286 |
%{ /* NOCONTEXT */ |
|
5287 |
||
616 | 5288 |
char *env; |
5289 |
||
5290 |
if (__isString(aStringOrSymbol) || __isSymbol(aStringOrSymbol)) { |
|
1135 | 5291 |
env = (char *)getenv(__stringVal(aStringOrSymbol)); |
616 | 5292 |
if (env) { |
830 | 5293 |
RETURN ( __MKSTRING(env COMMA_CON) ); |
616 | 5294 |
} |
5295 |
} |
|
5296 |
%} |
|
5297 |
. |
|
5298 |
^ nil |
|
5299 |
||
5300 |
" |
|
5301 |
OperatingSystem getEnvironment:'LANG' |
|
5302 |
OperatingSystem getEnvironment:'LOGIN' |
|
5303 |
OperatingSystem getEnvironment:'HOME' |
|
5304 |
OperatingSystem getEnvironment:'NNTPSERVER' |
|
5305 |
OperatingSystem getEnvironment:'MAIL' |
|
5306 |
OperatingSystem getEnvironment:'PATH' |
|
5307 |
" |
|
5308 |
! |
|
5309 |
||
5310 |
getHostName |
|
5311 |
"return the hostname we are running on - if there is |
|
5312 |
a HOST environment variable, we are much faster here ... |
|
5313 |
Notice: |
|
5314 |
not all systems support this; on some, 'unknown' is returned." |
|
5315 |
||
5316 |
|name| |
|
5317 |
||
5318 |
HostName notNil ifTrue:[ |
|
5319 |
^ HostName |
|
5320 |
]. |
|
5321 |
||
5322 |
%{ /* STACK: 2048 */ |
|
5323 |
#if defined(HAS_GETHOSTNAME) |
|
5324 |
char buffer[128]; |
|
5325 |
||
5326 |
if (gethostname(buffer, sizeof(buffer)) == 0) { |
|
830 | 5327 |
name = __MKSTRING(buffer COMMA_CON); |
616 | 5328 |
} |
5329 |
#else |
|
5330 |
# if defined(HAS_UNAME) |
|
5331 |
struct utsname ubuff; |
|
5332 |
||
5333 |
if (uname(&ubuff) >= 0) { |
|
830 | 5334 |
name = __MKSTRING(ubuff.nodename COMMA_CON); |
616 | 5335 |
} |
831 | 5336 |
# else |
5337 |
# ifdef WIN32 |
|
5338 |
char buffer[128]; |
|
5339 |
int buffSize = sizeof(buffer); |
|
5340 |
||
5341 |
if (GetComputerName(buffer, &buffSize) == TRUE) { |
|
1135 | 5342 |
name = __MKSTRING(buffer COMMA_CON); |
831 | 5343 |
} |
5344 |
# endif |
|
1 | 5345 |
# endif |
616 | 5346 |
#endif |
5347 |
%}. |
|
5348 |
name isNil ifTrue:[ |
|
5349 |
name := self getEnvironment:'HOST'. |
|
5350 |
name isNil ifTrue:[ |
|
5351 |
name := self getCommandOutputFrom:'hostname' |
|
5352 |
] |
|
5353 |
]. |
|
5354 |
name isNil ifTrue:[ |
|
5355 |
'OS: cannot find out hostname' errorPrintNL. |
|
5356 |
name := 'unknown'. |
|
5357 |
]. |
|
5358 |
HostName := name. |
|
5359 |
^ name |
|
5360 |
||
5361 |
" |
|
5362 |
OperatingSystem getHostName |
|
5363 |
" |
|
5364 |
! |
|
5365 |
||
1034 | 5366 |
getLocaleInfo |
5367 |
"return a dictionary filled with values from the locale information; |
|
5368 |
Not all fields may be present, depending on the OS's setup and capabilities. |
|
5369 |
Possible fields are: |
|
5370 |
decimalPoint <String> |
|
5371 |
||
5372 |
thousandsSep <String> |
|
5373 |
||
5374 |
internationalCurrencySymbol <String> |
|
5375 |
||
5376 |
currencySymbol <String> |
|
5377 |
||
5378 |
monetaryDecimalPoint <String> |
|
5379 |
||
5380 |
monetaryThousandsSeparator <String> |
|
5381 |
||
5382 |
positiveSign <String> |
|
5383 |
||
5384 |
negativeSign <String> |
|
5385 |
||
5386 |
internationalFractionalDigits <Integer> |
|
5387 |
||
5388 |
fractionalDigits <Integer> |
|
5389 |
||
5390 |
positiveSignPrecedesCurrencySymbol <Boolean> |
|
5391 |
||
5392 |
negativeSignPrecedesCurrencySymbol <Boolean> |
|
5393 |
||
5394 |
positiveSignSeparatedBySpaceFromCurrencySymbol <Boolean> |
|
5395 |
||
5396 |
negativeSignSeparatedBySpaceFromCurrencySymbol <Boolean> |
|
5397 |
||
5398 |
positiveSignPosition <Symbol> |
|
5399 |
one of: #parenthesesAround, |
|
5400 |
#signPrecedes, |
|
5401 |
#signSuceeds, |
|
5402 |
#signPrecedesCurrencySymbol, |
|
5403 |
#signSuceedsCurrencySymbol |
|
5404 |
||
5405 |
negativeSignPosition <like above> |
|
5406 |
||
5407 |
it is up to the application to deal with undefined values. |
|
5408 |
||
5409 |
Notice, that (for now), the system does not use this information; |
|
5410 |
it should be used by applications as required. |
|
5411 |
" |
|
5412 |
||
5413 |
|info val| |
|
5414 |
||
5415 |
LocaleInfo notNil ifTrue:[ |
|
5416 |
"/ return the internal info; useful on systems which do not |
|
5417 |
"/ support this. |
|
5418 |
^ LocaleInfo |
|
5419 |
]. |
|
5420 |
||
5421 |
info := IdentityDictionary new. |
|
5422 |
%{ |
|
5423 |
char *decimalPoint; /* something like "." (US) or "," (german) */ |
|
5424 |
char *thousandsSep; /* something like "," (US) or "." (german) */ |
|
5425 |
char *intCurrencySymbol; /* international currency symbol; something like "USD " "DM " */ |
|
5426 |
char *currencySymbol; /* local currency symbol; something like "USD " "DM " */ |
|
5427 |
char *monDecimalPoint; /* money: decimal point */ |
|
5428 |
char *monThousandsSep; /* money: thousands sep */ |
|
5429 |
char *positiveSign; |
|
5430 |
char *negativeSign; |
|
5431 |
int intFractDigits; /* money: international digits after decPoint */ |
|
5432 |
int fractDigits; /* money: local digits after decPoint */ |
|
5433 |
int csPosPrecedes; /* money: 1 if currency symbol precedes a positive value; 0 if it sceeds */ |
|
5434 |
int csNegPrecedes; /* money: 1 if currency symbol precedes a negative value; 0 if it sceeds */ |
|
5435 |
int csPosSepBySpace; /* money: 1 if currency symbol should be separated by a space from a positive value; 0 if no space */ |
|
5436 |
int csNegSepBySpace; /* money: 1 if currency symbol should be separated by a space from a negative value; 0 if no space */ |
|
5437 |
int csPosSignPosition; /* money: 0: ()'s around the value & currency symbol */ |
|
5438 |
int csNegSignPosition; /* 1: sign precedes the value & currency symbol */ |
|
5439 |
/* 2: sign succeeds the value & currency symbol */ |
|
5440 |
/* 3: sign immediately precedes the currency symbol */ |
|
5441 |
/* 4: sign immediately suceeds the currency symbol */ |
|
5442 |
||
5443 |
#if defined(HAS_LOCALECONV) |
|
5444 |
struct lconv *conf; |
|
5445 |
||
5446 |
conf = localeconv(); |
|
5447 |
if (conf) { |
|
5448 |
decimalPoint = conf->decimal_point; |
|
5449 |
thousandsSep = conf->thousands_sep; |
|
5450 |
intCurrencySymbol = conf->int_curr_symbol; |
|
5451 |
currencySymbol = conf->currency_symbol; |
|
5452 |
monDecimalPoint = conf->mon_decimal_point; |
|
5453 |
monThousandsSep = conf->mon_thousands_sep; |
|
5454 |
positiveSign = conf->positive_sign; |
|
5455 |
negativeSign = conf->negative_sign; |
|
5456 |
intFractDigits = conf->int_frac_digits; |
|
5457 |
fractDigits = conf->frac_digits; |
|
5458 |
csPosPrecedes = conf->p_cs_precedes; |
|
5459 |
csNegPrecedes = conf->n_cs_precedes; |
|
5460 |
csPosSepBySpace = conf->p_sep_by_space; |
|
5461 |
csNegSepBySpace = conf->n_sep_by_space; |
|
5462 |
csPosSignPosition = conf->p_sign_posn; |
|
5463 |
csNegSignPosition = conf->n_sign_posn; |
|
5464 |
} |
|
5465 |
#else |
|
5466 |
decimalPoint = (char *)0; |
|
5467 |
thousandsSep = (char *)0; |
|
5468 |
intCurrencySymbol = (char *)0; |
|
5469 |
currencySymbol = (char *)0; |
|
5470 |
monDecimalPoint = (char *)0; |
|
5471 |
monThousandsSep = (char *)0; |
|
5472 |
positiveSign = (char *)0; |
|
5473 |
negativeSign =(char *)0; |
|
5474 |
intFractDigits = -1; |
|
5475 |
fractDigits = -1; |
|
5476 |
csPosPrecedes = -1; |
|
5477 |
csNegPrecedes = -1; |
|
5478 |
csPosSepBySpace = -1; |
|
5479 |
csNegSepBySpace = -1; |
|
5480 |
csPosSignPosition = -1; |
|
5481 |
csNegSignPosition = -1; |
|
5482 |
#endif |
|
5483 |
if (decimalPoint) { |
|
5484 |
val = __MKSTRING(decimalPoint); |
|
5485 |
__AT_PUT_(info, @symbol(decimalPoint), val); |
|
5486 |
} |
|
5487 |
if (thousandsSep) { |
|
5488 |
val = __MKSTRING(thousandsSep); |
|
5489 |
__AT_PUT_(info, @symbol(thousandsSeparator), val); |
|
5490 |
} |
|
5491 |
if (intCurrencySymbol) { |
|
5492 |
val = __MKSTRING(intCurrencySymbol); |
|
5493 |
__AT_PUT_(info, @symbol(internationCurrencySymbol), val); |
|
5494 |
} |
|
5495 |
if (currencySymbol) { |
|
5496 |
val = __MKSTRING(currencySymbol); |
|
5497 |
__AT_PUT_(info, @symbol(currencySymbol), val); |
|
5498 |
} |
|
5499 |
if (monDecimalPoint) { |
|
5500 |
val = __MKSTRING(monDecimalPoint); |
|
5501 |
__AT_PUT_(info, @symbol(monetaryDecimalPoint), val); |
|
5502 |
} |
|
5503 |
if (monThousandsSep) { |
|
5504 |
val = __MKSTRING(monThousandsSep); |
|
5505 |
__AT_PUT_(info, @symbol(monetaryThousandsSeparator), val); |
|
5506 |
} |
|
5507 |
if (positiveSign) { |
|
5508 |
val = __MKSTRING(positiveSign); |
|
5509 |
__AT_PUT_(info, @symbol(positiveSign), val); |
|
5510 |
} |
|
5511 |
if (negativeSign) { |
|
5512 |
val = __MKSTRING(negativeSign); |
|
5513 |
__AT_PUT_(info, @symbol(negativeSign), val); |
|
5514 |
} |
|
5515 |
if (intFractDigits >= 0) { |
|
5516 |
__AT_PUT_(info, @symbol(internationalFractionalDigits), __MKSMALLINT(intFractDigits)); |
|
5517 |
} |
|
5518 |
if (fractDigits >= 0) { |
|
5519 |
__AT_PUT_(info, @symbol(fractionalDigits), __MKSMALLINT(fractDigits)); |
|
5520 |
} |
|
5521 |
if (csPosPrecedes >= 0) { |
|
5522 |
if (csPosPrecedes == 0) { |
|
5523 |
val = false; |
|
5524 |
} else { |
|
5525 |
val = true; |
|
5526 |
} |
|
5527 |
__AT_PUT_(info, @symbol(positiveSignPrecedesCurrencySymbol), val ); |
|
5528 |
} |
|
5529 |
if (csNegPrecedes >= 0) { |
|
5530 |
if (csNegPrecedes == 0) { |
|
5531 |
val = false; |
|
5532 |
} else { |
|
5533 |
val = true; |
|
5534 |
} |
|
5535 |
__AT_PUT_(info, @symbol(negativeSignPrecedesCurrencySymbol), val ); |
|
5536 |
} |
|
5537 |
if (csPosSepBySpace >= 0) { |
|
5538 |
if (csPosSepBySpace == 0) { |
|
5539 |
val = false; |
|
5540 |
} else { |
|
5541 |
val = true; |
|
5542 |
} |
|
5543 |
__AT_PUT_(info, @symbol(positiveSignSeparatedBySpaceFromCurrencySymbol), val); |
|
5544 |
} |
|
5545 |
if (csNegSepBySpace >= 0) { |
|
5546 |
if (csNegSepBySpace == 0) { |
|
5547 |
val = false; |
|
5548 |
} else { |
|
5549 |
val = true; |
|
5550 |
} |
|
5551 |
__AT_PUT_(info, @symbol(negativeSignSeparatedBySpaceFromCurrencySymbol), val); |
|
5552 |
} |
|
5553 |
switch (csPosSignPosition) { |
|
5554 |
case 0: |
|
5555 |
val = @symbol(parenthesesAround); |
|
5556 |
break; |
|
5557 |
||
5558 |
case 1: |
|
5559 |
val = @symbol(signPrecedes); |
|
5560 |
break; |
|
5561 |
||
5562 |
case 2: |
|
5563 |
val = @symbol(signSuceeds); |
|
5564 |
break; |
|
5565 |
||
5566 |
case 3: |
|
5567 |
val = @symbol(signPrecedesCurrencySymbol); |
|
5568 |
break; |
|
5569 |
||
5570 |
case 4: |
|
5571 |
val = @symbol(signSuceedsCurrencySymbol); |
|
5572 |
break; |
|
5573 |
||
5574 |
default: |
|
5575 |
val = nil; |
|
5576 |
} |
|
5577 |
if (val != nil) { |
|
5578 |
__AT_PUT_(info, @symbol(positiveSignPosition), val); |
|
5579 |
} |
|
5580 |
||
5581 |
switch (csNegSignPosition) { |
|
5582 |
case 0: |
|
5583 |
val = @symbol(parenthesesAround); |
|
5584 |
break; |
|
5585 |
||
5586 |
case 1: |
|
5587 |
val = @symbol(signPrecedes); |
|
5588 |
break; |
|
5589 |
||
5590 |
case 2: |
|
5591 |
val = @symbol(signSuceeds); |
|
5592 |
break; |
|
5593 |
||
5594 |
case 3: |
|
5595 |
val = @symbol(signPrecedesCurrencySymbol); |
|
5596 |
break; |
|
5597 |
||
5598 |
case 4: |
|
5599 |
val = @symbol(signSuceedsCurrencySymbol); |
|
5600 |
break; |
|
5601 |
||
5602 |
default: |
|
5603 |
val = nil; |
|
5604 |
} |
|
5605 |
if (val != nil) { |
|
5606 |
__AT_PUT_(info, @symbol(negativeSignPosition), val); |
|
5607 |
} |
|
5608 |
%}. |
|
5609 |
^ info |
|
5610 |
||
5611 |
" |
|
5612 |
OperatingSystem getLocaleInfo |
|
5613 |
" |
|
5614 |
||
5615 |
"Created: 23.12.1995 / 14:19:20 / cg" |
|
5616 |
! |
|
5617 |
||
616 | 5618 |
getOSDefine |
5619 |
"return a string which was used to identify this machine when stx was |
|
5620 |
compiled, and which should be passed down when compiling methods. |
|
5621 |
For example, on linux, this is '-DLINUX'." |
|
5622 |
||
5623 |
%{ /* NOCONTEXT */ |
|
831 | 5624 |
#ifdef WIN32 |
5625 |
# ifndef OS_DEFINE |
|
5626 |
# define OS_DEFINE "-DWIN32" |
|
5627 |
# endif |
|
5628 |
#endif |
|
5629 |
||
616 | 5630 |
#ifndef OS_DEFINE |
5631 |
# define OS_DEFINE "-DunknownOS" |
|
5632 |
#endif |
|
831 | 5633 |
|
616 | 5634 |
RETURN ( __MKSTRING(OS_DEFINE COMMA_CON)); |
5635 |
%} |
|
5636 |
" |
|
5637 |
OperatingSystem getOSDefine |
|
5638 |
" |
|
5639 |
! |
|
5640 |
||
5641 |
getOSType |
|
5642 |
"return a string giving the type of OS we're running on. |
|
5643 |
This can be used to adapt programs to certain environment |
|
5644 |
differences (for example: mail-lock strategy ...)" |
|
5645 |
||
5646 |
|os| |
|
5647 |
||
5648 |
%{ /* NOCONTEXT */ |
|
5649 |
||
5650 |
# ifdef MSDOS |
|
5651 |
# define OS_STRING "msdos" |
|
5652 |
# endif |
|
5653 |
||
831 | 5654 |
# ifdef WIN32 |
5655 |
char *OS_STRING = "win32"; |
|
5656 |
||
5657 |
# endif |
|
5658 |
||
616 | 5659 |
# ifdef MSWINDOWS |
5660 |
# define OS_STRING "mswindows" |
|
5661 |
# endif |
|
5662 |
||
5663 |
# ifdef NT |
|
5664 |
# define OS_STRING "nt" |
|
5665 |
# endif |
|
5666 |
||
5667 |
# ifdef VMS |
|
5668 |
# define OS_STRING "vms" |
|
5669 |
# endif |
|
5670 |
||
5671 |
# ifdef MVS |
|
5672 |
# define OS_STRING "mvs" |
|
5673 |
# endif |
|
5674 |
||
5675 |
# ifdef OS2 |
|
5676 |
# define OS_STRING "os2" |
|
5677 |
# endif |
|
5678 |
||
5679 |
# ifdef sinix |
|
5680 |
# define OS_STRING "sinix" |
|
5681 |
# endif |
|
5682 |
||
5683 |
# ifdef ultrix |
|
5684 |
# define OS_STRING "ultrix" |
|
5685 |
# endif |
|
5686 |
||
5687 |
# ifdef sco |
|
5688 |
# define OS_STRING "sco" |
|
5689 |
# endif |
|
5690 |
||
5691 |
# ifdef hpux |
|
5692 |
# define OS_STRING "hpux" |
|
5693 |
# endif |
|
5694 |
||
5695 |
# ifdef LINUX |
|
5696 |
# define OS_STRING "linux" |
|
5697 |
# endif |
|
5698 |
||
5699 |
# ifdef sunos |
|
5700 |
# define OS_STRING "sunos" |
|
5701 |
# endif |
|
5702 |
||
5703 |
# ifdef solaris |
|
5704 |
# define OS_STRING "solaris" |
|
5705 |
# endif |
|
5706 |
||
5707 |
# ifdef IRIS |
|
5708 |
# define OS_STRING "irix" |
|
5709 |
# endif |
|
5710 |
||
5711 |
# ifdef aix |
|
5712 |
# define OS_STRING "aix" |
|
5713 |
# endif |
|
5714 |
||
5715 |
# ifdef realIX |
|
5716 |
# define OS_STRING "realIX" |
|
5717 |
# endif |
|
5718 |
||
5719 |
/* |
|
5720 |
* no concrete info; become somewhat vague ... |
|
5721 |
*/ |
|
5722 |
# ifndef OS_STRING |
|
5723 |
# ifdef MACH |
|
5724 |
# define OS_STRING "mach" |
|
5725 |
# endif |
|
5726 |
# endif |
|
5727 |
||
5728 |
# ifndef OS_STRING |
|
5729 |
# ifdef BSD |
|
5730 |
# define OS_STRING "bsd" |
|
5731 |
# endif |
|
5732 |
||
5733 |
# ifdef SYSV |
|
5734 |
# ifdef SYSV3 |
|
5735 |
# define OS_STRING "sys5_3" |
|
5736 |
# else |
|
5737 |
# ifdef SYSV4 |
|
5738 |
# define OS_STRING "sys5_4" |
|
5739 |
# else |
|
5740 |
# define OS_STRING "sys5" |
|
5741 |
# endif |
|
5742 |
# endif |
|
5743 |
# endif |
|
5744 |
# endif |
|
5745 |
||
5746 |
/* |
|
5747 |
* become very vague ... |
|
5748 |
*/ |
|
5749 |
# ifndef OS_STRING |
|
5750 |
# ifdef POSIX |
|
5751 |
# define OS_STRING "posix" |
|
5752 |
# endif |
|
5753 |
# endif |
|
5754 |
# ifndef OS_STRING |
|
5755 |
# ifdef UNIX |
|
5756 |
# define OS_STRING "unix" |
|
5757 |
# endif |
|
5758 |
# endif |
|
5759 |
||
5760 |
# ifndef OS_STRING |
|
5761 |
# define OS_STRING "unknown" |
|
5762 |
# endif |
|
5763 |
||
830 | 5764 |
os = __MKSTRING(OS_STRING COMMA_CON); |
616 | 5765 |
# undef OS_STRING |
831 | 5766 |
%}. |
616 | 5767 |
^ os |
5768 |
||
5769 |
"OperatingSystem getOSType" |
|
5770 |
! |
|
5771 |
||
5772 |
getProcessId |
|
5773 |
"return the (unix-)processId" |
|
5774 |
||
5775 |
%{ /* NOCONTEXT */ |
|
5776 |
||
5777 |
int pid = 0; |
|
5778 |
#ifdef UNIX_LIKE |
|
5779 |
pid = getpid(); |
|
5780 |
#endif |
|
1135 | 5781 |
RETURN ( __MKSMALLINT(pid) ); |
616 | 5782 |
%} |
5783 |
" |
|
5784 |
OperatingSystem getProcessId |
|
5785 |
" |
|
5786 |
! |
|
5787 |
||
5788 |
getSystemID |
|
5789 |
"if supported by the OS, return the systemID; |
|
5790 |
a unique per machine identification. |
|
5791 |
WARNING: |
|
5792 |
not all systems support this; on some, 'unknown' is returned." |
|
5793 |
||
5794 |
%{ /* NO_CONTEXT */ |
|
5795 |
#if defined(IRIX5) && !defined(HAS_GETHOSTID) |
|
5796 |
char idBuffer[MAXSYSIDSIZE]; |
|
5797 |
int retVal; |
|
5798 |
OBJ arr; |
|
5799 |
||
5800 |
if ((retVal = syssgi(SGI_SYSID, idBuffer)) == 0) { |
|
5801 |
arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(MAXSYSIDSIZE); |
|
5802 |
bcopy(idBuffer, __ByteArrayInstPtr(arr)->ba_element, MAXSYSIDSIZE); |
|
5803 |
RETURN (arr); |
|
5804 |
} |
|
5805 |
#endif |
|
5806 |
#if defined(HAS_GETHOSTID) |
|
5807 |
int runningId; |
|
5808 |
OBJ arr; |
|
5809 |
||
5810 |
runningId = gethostid(); |
|
5811 |
arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(4); |
|
5812 |
*(int *)(__ByteArrayInstPtr(arr)->ba_element) = runningId; |
|
5813 |
RETURN (arr); |
|
5814 |
#endif |
|
5815 |
%}. |
|
5816 |
^ 'unknown' |
|
5817 |
||
5818 |
" |
|
5819 |
OperatingSystem getSystemID |
|
5820 |
" |
|
5821 |
! |
|
5822 |
||
5823 |
getSystemInfo |
|
831 | 5824 |
"return info on the system weare running on. |
5825 |
If the system supports the uname system call, that info is returned; |
|
616 | 5826 |
otherwise, some simulated info is returned. |
831 | 5827 |
|
616 | 5828 |
WARNING: |
831 | 5829 |
Do not depend on the amount and contents of the returned information, some |
5830 |
systems may return more/less than others. Also, the contents depends on the |
|
5831 |
OS, for example, linux returns 'ix86', while WIN32 returns 'x86'. |
|
5832 |
||
5833 |
This method is mainly provided to augment error reports with some system |
|
5834 |
information. |
|
5835 |
(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
|
5836 |
may be based upon this info) |
616 | 5837 |
|
5838 |
The returned info may (or may not) contain: |
|
831 | 5839 |
#system -> some operating system identification (irix, Linux, nt, win32s ...) |
5840 |
#version -> OS version (some os version identification) |
|
5841 |
#release -> OS release (3.5, 1.2.1 ...) |
|
5842 |
#node -> some host identification (hostname) |
|
5843 |
#domain -> domain name (hosts domain) |
|
5844 |
#machine -> type of machine (i586, mips ...) |
|
616 | 5845 |
" |
5846 |
||
5847 |
|sys node rel ver mach dom mtyp brel info| |
|
5848 |
||
1060
119d45f975e1
increased getSystemInfos stack - just to make certain
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
5849 |
%{ /* STACK: 4096 */ |
616 | 5850 |
#if defined(HAS_UNAME) |
5851 |
struct utsname ubuff; |
|
5852 |
||
5853 |
if (uname(&ubuff) >= 0) { |
|
830 | 5854 |
sys = __MKSTRING(ubuff.sysname COMMA_CON); |
5855 |
node = __MKSTRING(ubuff.nodename COMMA_CON); |
|
5856 |
rel = __MKSTRING(ubuff.release COMMA_CON); |
|
5857 |
ver = __MKSTRING(ubuff.version COMMA_CON); |
|
5858 |
mach = __MKSTRING(ubuff.machine COMMA_CON); |
|
616 | 5859 |
# ifdef HAS_UTS_DOMAINNAME |
830 | 5860 |
dom = __MKSTRING(ubuff.domainname COMMA_CON); |
616 | 5861 |
# endif |
5862 |
} |
|
831 | 5863 |
#else /* no uname */ |
5864 |
# ifdef WIN32 |
|
5865 |
||
5866 |
char vsnBuffer[32]; |
|
5867 |
char *s; |
|
5868 |
int winVer; |
|
5869 |
DWORD vsn; |
|
5870 |
SYSTEM_INFO sysInfo; |
|
5871 |
||
5872 |
vsn = GetVersion(); |
|
5873 |
||
5874 |
if (HIWORD(vsn) & 0x8000) { |
|
5875 |
s = "win32s"; |
|
5876 |
} else { |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5877 |
s = "nt"; |
831 | 5878 |
} |
5879 |
sys = __MKSTRING(s COMMA_CON); |
|
5880 |
winVer = LOWORD(vsn); |
|
5881 |
sprintf(vsnBuffer, "%d.%d", LOBYTE(winVer), HIBYTE(winVer)); |
|
5882 |
rel = __MKSTRING(vsnBuffer COMMA_CON); |
|
5883 |
||
5884 |
GetSystemInfo(&sysInfo); |
|
5885 |
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
|
5886 |
sprintf(vsnBuffer, "%d", sysInfo.dwProcessorType); |
831 | 5887 |
mach = __MKSTRING(vsnBuffer COMMA_CON); |
5888 |
} |
|
5889 |
||
5890 |
# endif /* WIN32 */ |
|
5891 |
#endif /* no uname */ |
|
616 | 5892 |
%}. |
5893 |
sys isNil ifTrue:[ |
|
5894 |
sys := self getSystemType. |
|
5895 |
]. |
|
5896 |
node isNil ifTrue:[ |
|
5897 |
node := self getHostName |
|
5898 |
]. |
|
5899 |
dom isNil ifTrue:[ |
|
5900 |
dom := self getDomainName |
|
5901 |
]. |
|
831 | 5902 |
mach isNil ifTrue:[ |
5903 |
mach := self getCPUType |
|
5904 |
]. |
|
616 | 5905 |
|
5906 |
info := IdentityDictionary new. |
|
5907 |
info at:#system put:sys. |
|
5908 |
info at:#node put:node. |
|
5909 |
rel notNil ifTrue:[info at:#release put:rel]. |
|
5910 |
ver notNil ifTrue:[info at:#version put:ver]. |
|
5911 |
mach notNil ifTrue:[info at:#machine put:mach]. |
|
5912 |
dom notNil ifTrue:[info at:#domain put:dom]. |
|
5913 |
^ info |
|
5914 |
||
5915 |
" |
|
5916 |
OperatingSystem getSystemInfo |
|
5917 |
" |
|
5918 |
! |
|
5919 |
||
5920 |
getSystemType |
|
5921 |
"return a string giving the type of system we're running on. |
|
5922 |
This is almost the same as getOSType, but the returned string |
|
5923 |
is slightly different for some systems (i.e. iris vs. irix). |
|
5924 |
Dont depend on this - use getOSType. I dont really see a point |
|
831 | 5925 |
here ... |
5926 |
(except for slight differences between next/mach and other machs)" |
|
616 | 5927 |
|
5928 |
|sys| |
|
5929 |
||
5930 |
%{ |
|
5931 |
# ifdef NEXT |
|
5932 |
# define SYS_STRING "next" |
|
5933 |
# endif |
|
5934 |
||
5935 |
# ifdef IRIS |
|
5936 |
# define SYS_STRING "iris" |
|
5937 |
# endif |
|
5938 |
||
831 | 5939 |
# ifdef WIN32 |
5940 |
# define SYS_STRING "win32" |
|
5941 |
# endif |
|
5942 |
||
616 | 5943 |
# ifdef SYS_STRING |
830 | 5944 |
sys = __MKSTRING(SYS_STRING COMMA_CON); |
616 | 5945 |
# undef SYS_STRING |
5946 |
# endif |
|
831 | 5947 |
%}. |
616 | 5948 |
sys isNil ifTrue:[ |
5949 |
^ self getOSType |
|
5950 |
]. |
|
5951 |
^ sys |
|
5952 |
||
5953 |
" |
|
5954 |
OperatingSystem getSystemType |
|
5955 |
" |
|
5956 |
! |
|
5957 |
||
5958 |
isBSDlike |
|
5959 |
"return true, if the OS we're running on is a 'real' unix." |
|
5960 |
||
5961 |
%{ /* NOCONTEXT */ |
|
5962 |
||
5963 |
#if defined(BSD) || defined(MACH) || defined(SYSV4) |
|
5964 |
RETURN ( true ); |
|
13 | 5965 |
#endif |
831 | 5966 |
%}. |
13 | 5967 |
^ false |
10 | 5968 |
! |
5969 |
||
616 | 5970 |
isMSDOSlike |
5971 |
"return true, if the OS we're running on is dos like |
|
5972 |
(in contrast to unix-like)." |
|
5973 |
||
5974 |
%{ /* NOCONTEXT */ |
|
5975 |
||
5976 |
#if defined(MSDOS_LIKE) |
|
5977 |
RETURN ( true ); |
|
5978 |
#endif |
|
831 | 5979 |
%}. |
616 | 5980 |
^ false |
5981 |
! |
|
5982 |
||
831 | 5983 |
isMSWINDOWSlike |
5984 |
"return true, if the OS we're running on is MS-Windows like." |
|
5985 |
||
5986 |
%{ /* NOCONTEXT */ |
|
5987 |
||
5988 |
#if defined(WIN32) |
|
5989 |
RETURN ( true ); |
|
5990 |
#endif |
|
5991 |
||
5992 |
%}. |
|
5993 |
^ false |
|
5994 |
! |
|
5995 |
||
5996 |
isOS2like |
|
5997 |
"return true, if the OS we're running on is OS2 like" |
|
5998 |
||
5999 |
%{ /* NOCONTEXT */ |
|
6000 |
||
6001 |
#if defined(OS2) |
|
6002 |
RETURN (true); |
|
6003 |
#endif |
|
6004 |
||
6005 |
%}. |
|
6006 |
^ false |
|
6007 |
! |
|
6008 |
||
1034 | 6009 |
isUNIXlike |
6010 |
"return true, if the OS we're running on is a unix like." |
|
6011 |
||
6012 |
%{ /* NOCONTEXT */ |
|
6013 |
||
6014 |
#if !defined(UNIX_LIKE) |
|
6015 |
RETURN ( false ); |
|
6016 |
#endif |
|
6017 |
%}. |
|
6018 |
^ true |
|
6019 |
! |
|
6020 |
||
616 | 6021 |
maxFileNameLength |
6022 |
"return the max number of characters in a filename. |
|
831 | 6023 |
CAVEAT: |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6024 |
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
|
6025 |
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
|
6026 |
We return a somewhat conservative number here." |
10 | 6027 |
|
6028 |
%{ /* NOCONTEXT */ |
|
616 | 6029 |
|
6030 |
/* |
|
6031 |
* XXX: newer systems provide a query function for this ... use it |
|
6032 |
*/ |
|
6033 |
# if defined(BSD) || defined(SYSV4) || defined(LONGFILENAMES) |
|
831 | 6034 |
RETURN ( __MKSMALLINT(255) ); |
616 | 6035 |
# endif |
6036 |
||
6037 |
# ifdef realIX |
|
831 | 6038 |
RETURN ( __MKSMALLINT(127) ); |
616 | 6039 |
# endif |
6040 |
||
6041 |
# ifdef SYSV |
|
831 | 6042 |
RETURN ( __MKSMALLINT(14) ); |
616 | 6043 |
# endif |
6044 |
||
6045 |
# ifdef MSDOS |
|
831 | 6046 |
RETURN ( __MKSMALLINT(9) ); |
616 | 6047 |
# endif |
6048 |
||
831 | 6049 |
# ifdef WIN32 |
616 | 6050 |
/* |
6051 |
* mhmh - depends on the filesystem type |
|
6052 |
*/ |
|
831 | 6053 |
RETURN ( __MKSMALLINT(9) ); |
616 | 6054 |
# endif |
6055 |
%}. |
|
6056 |
"unix default" |
|
831 | 6057 |
|
616 | 6058 |
^ 14 |
6059 |
! |
|
6060 |
||
1034 | 6061 |
setLocaleInfo:anInfoDictionary |
6062 |
"set the locale information; if set, this oerrides the OS's settings. |
|
6063 |
(internal in ST/X only - the OS's settings remain unaffected) |
|
6064 |
See description of fields in #getLocaleInfo. |
|
6065 |
||
6066 |
Notice, that (for now), the system does not use this information; |
|
6067 |
it should be used by applications as required." |
|
6068 |
||
6069 |
LocaleInfo := anInfoDictionary |
|
6070 |
||
6071 |
" |
|
6072 |
|d| |
|
6073 |
||
6074 |
d := IdentityDictionary new. |
|
6075 |
d at:#decimalPoint put:'.' . |
|
6076 |
d at:#thousandsSeparator put:',' . |
|
6077 |
d at:#currencySymbol put:'USD' . |
|
6078 |
d at:#monetaryDecimalPoint put:'.' . |
|
6079 |
d at:#monetaryThousandsSeparator put:'.' . |
|
6080 |
d at:#fractionalDigits put:2 . |
|
6081 |
d at:#positiveSign put:'+' . |
|
6082 |
d at:#negativeSign put:'-' . |
|
6083 |
d at:#positiveSignPrecedesCurrencySymbol put:true . |
|
6084 |
d at:#negativeSignPrecedesCurrencySymbol put:false . |
|
6085 |
OperatingSystem setLocaleInfo:d |
|
6086 |
" |
|
6087 |
! |
|
6088 |
||
616 | 6089 |
supportsIOInterrupts |
6090 |
"return true, if the OS supports IO availability interrupts |
|
6091 |
(i.e. SIGPOLL/SIGIO). |
|
6092 |
||
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6093 |
Currently, this mechanism does work for SYSV4 only ..." |
616 | 6094 |
|
6095 |
%{ /* NOCONTEXT */ |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
6096 |
#if defined(SYSV4) && defined(USE_SIGIO) && 0 |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6097 |
|
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6098 |
# if defined(SIGPOLL) || defined(SIGIO) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6099 |
# 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
|
6100 |
/* |
765
93bdb4f0e095
no, SIGIO does not work on SGI ...
Claus Gittinger <cg@exept.de>
parents:
764
diff
changeset
|
6101 |
* 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
|
6102 |
* (not even on SGI ...) |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6103 |
*/ |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6104 |
# if !defined(NEXT) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6105 |
RETURN (true); |
616 | 6106 |
# endif |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6107 |
# endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6108 |
# endif |
616 | 6109 |
|
10 | 6110 |
#endif |
831 | 6111 |
%}. |
13 | 6112 |
^ false |
123 | 6113 |
! |
6114 |
||
616 | 6115 |
supportsNonBlockingIO |
6116 |
"return true, if the OS supports nonblocking IO." |
|
6117 |
||
6118 |
%{ /* NOCONTEXT */ |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6119 |
#if defined(F_GETFL) && defined(F_SETFL) && defined(FNDELAY) |
616 | 6120 |
RETURN (true); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6121 |
#endif |
831 | 6122 |
%}. |
616 | 6123 |
^ false |
123 | 6124 |
! |
6125 |
||
616 | 6126 |
supportsSelect |
6127 |
"return true, if the OS supports selecting on multiple |
|
6128 |
filedescriptors via select." |
|
6129 |
||
6130 |
%{ /* NOCONTEXT */ |
|
831 | 6131 |
#if defined(WIN32) |
6132 |
RETURN (false); |
|
6133 |
#endif |
|
616 | 6134 |
#if defined(sco) |
6135 |
/* |
|
831 | 6136 |
* sco has a select, but its broken: always waiting 1 second |
616 | 6137 |
*/ |
6138 |
RETURN(false); |
|
6139 |
#endif |
|
6140 |
%} |
|
6141 |
. |
|
6142 |
^ true |
|
6143 |
! ! |
|
6144 |
||
6145 |
!OperatingSystem class methodsFor:'shared memory access'! |
|
6146 |
||
6147 |
shmAttach:id address:addr flags:flags |
|
1247 | 6148 |
"low level entry to shmat()-system call. |
6149 |
Not supported on all operatingSystems" |
|
6150 |
||
616 | 6151 |
%{ /* NOCONTEXT */ |
6152 |
#ifdef WANT_SHM |
|
6153 |
void *address, *shmaddr; |
|
6154 |
int shmflg, shmid; |
|
6155 |
||
6156 |
if (__isSmallInteger(addr) |
|
6157 |
&& __bothSmallInteger(flags, id)) { |
|
1487 | 6158 |
shmaddr = (void *) __intVal(addr); |
6159 |
shmflg = __intVal(flags); |
|
6160 |
shmid = __intVal(id); |
|
6161 |
||
6162 |
address = shmat(shmid, shmaddr, shmflg); |
|
6163 |
if (address != (void *)-1) { |
|
6164 |
RETURN (__MKEXTERNALBYTES(addr)); |
|
6165 |
} |
|
6166 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
|
6167 |
RETURN (nil); |
|
616 | 6168 |
} |
6169 |
#endif |
|
6170 |
%}. |
|
792 | 6171 |
^ self primitiveFailed |
1247 | 6172 |
|
6173 |
"Modified: 22.4.1996 / 13:15:12 / cg" |
|
370 | 6174 |
! |
6175 |
||
616 | 6176 |
shmDetach:addr |
1247 | 6177 |
"low level entry to shmdt()-system call. |
6178 |
Not supported on all operatingSystems" |
|
6179 |
||
616 | 6180 |
%{ /* NOCONTEXT */ |
6181 |
#ifdef WANT_SHM |
|
6182 |
void *shmaddr; |
|
6183 |
int rslt; |
|
6184 |
||
6185 |
if (__isSmallInteger(addr)) { |
|
1487 | 6186 |
shmaddr = (void *) __intVal(addr); |
6187 |
||
6188 |
rslt = shmdt(shmaddr); |
|
6189 |
if (rslt != -1) { |
|
6190 |
RETURN (true); |
|
6191 |
} |
|
6192 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
|
6193 |
RETURN (false); |
|
370 | 6194 |
} |
616 | 6195 |
#endif |
6196 |
%}. |
|
792 | 6197 |
^ self primitiveFailed |
1247 | 6198 |
|
6199 |
"Modified: 22.4.1996 / 13:15:03 / cg" |
|
616 | 6200 |
! |
6201 |
||
6202 |
shmGet:key size:size flags:flags |
|
1247 | 6203 |
"low level entry to shmget()-system call. |
6204 |
This is not for public use and not supported with all operatingSystems. |
|
616 | 6205 |
- use the provided wrapper class SharedExternalBytes instead." |
6206 |
||
6207 |
%{ /* NOCONTEXT */ |
|
6208 |
#ifdef WANT_SHM |
|
6209 |
if (__bothSmallInteger(key, size) |
|
6210 |
&& __isSmallInteger(flags)) { |
|
1487 | 6211 |
int rslt; |
6212 |
||
6213 |
rslt = shmget(__intVal(key), __intVal(size), __intVal(flags)); |
|
6214 |
if (rslt != -1) { |
|
6215 |
RETURN (__MKSMALLINT(rslt)); |
|
6216 |
} |
|
6217 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
|
6218 |
RETURN (nil); |
|
616 | 6219 |
} |
6220 |
#endif |
|
370 | 6221 |
%}. |
792 | 6222 |
^ self primitiveFailed |
1247 | 6223 |
|
6224 |
"Modified: 22.4.1996 / 13:14:46 / cg" |
|
1 | 6225 |
! ! |
6226 |
||
6227 |
!OperatingSystem class methodsFor:'time and date'! |
|
6228 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6229 |
computeDatePartsOf:osTimeLow and:osTimeHi for:aBlock |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6230 |
"compute year, month and day from the OS time-parts osTimeLow and |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6231 |
osTimeHi and evaluate the argument, a 3-arg block with these. |
241 | 6232 |
Conversion is to localtime including any daylight saving adjustments. |
63 | 6233 |
|
6234 |
This method was added to avoid LargeInteger arithmetic and to be |
|
6235 |
independent of how the OperatingSystem represents time; |
|
6236 |
the time-parts expected are those returned by getTimeParts." |
|
1 | 6237 |
|
6238 |
|year month day| |
|
6239 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6240 |
((osTimeLow isMemberOf:SmallInteger) |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6241 |
and:[osTimeHi isMemberOf:SmallInteger]) ifFalse:[ |
185 | 6242 |
^ self primitiveFailed |
1 | 6243 |
]. |
6244 |
%{ |
|
6245 |
struct tm *tmPtr; |
|
6246 |
long t; |
|
6247 |
||
1135 | 6248 |
t = (__intVal(osTimeHi) << 16) | __intVal(osTimeLow); |
1 | 6249 |
tmPtr = localtime(&t); |
1135 | 6250 |
year = __MKSMALLINT(tmPtr->tm_year + 1900); |
6251 |
month = __MKSMALLINT(tmPtr->tm_mon + 1); |
|
6252 |
day = __MKSMALLINT(tmPtr->tm_mday); |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6253 |
%}. |
1 | 6254 |
aBlock value:year value:month value:day |
6255 |
! |
|
6256 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6257 |
computeDatePartsOf:osTimeParts for:aBlock |
616 | 6258 |
"compute year, month and day from the ostime in timeParts, |
6259 |
and evaluate the argument, a 3-arg block with these. |
|
6260 |
Conversion is to localtime including any daylight saving adjustments." |
|
6261 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6262 |
^ self |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6263 |
computeDatePartsOf:(osTimeParts at:1) |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6264 |
and:(osTimeParts at:2) |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6265 |
for:aBlock |
1 | 6266 |
! |
6267 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6268 |
computeTimeAndDateFrom:osTimeParts |
63 | 6269 |
"given an Array containing the OS-dependent time, return an Array |
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6270 |
containing year, month, day, hour, minute and seconds, |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6271 |
offset to UTC and a daylight savings time flag. |
241 | 6272 |
Conversion is to localtime including any daylight saving adjustments." |
63 | 6273 |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6274 |
|low hi year month day hours minutes seconds utcOffset dst ret| |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6275 |
|
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6276 |
low := osTimeParts at:1. |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6277 |
hi := osTimeParts at:2. |
63 | 6278 |
%{ |
6279 |
struct tm *tmPtr; |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6280 |
struct tm *gmTmPtr; |
63 | 6281 |
long t; |
6282 |
||
1441 | 6283 |
#if defined(ultrix) || defined(sunos) /* mhmh - isnt this ifdef BSD ? */ |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6284 |
# define TIMEZONE tmPtr->tm_gmtoff |
811 | 6285 |
#else |
831 | 6286 |
# ifdef MSDOS_LIKE |
1487 | 6287 |
# define TIMEZONE 0 |
831 | 6288 |
# else |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6289 |
# define TIMEZONE timezone |
831 | 6290 |
# endif |
811 | 6291 |
#endif |
6292 |
||
252 | 6293 |
if (__bothSmallInteger(low, hi)) { |
1135 | 6294 |
t = (__intVal(hi) << 16) | __intVal(low); |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6295 |
tmPtr = localtime(&t); |
1135 | 6296 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
6297 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
|
6298 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
|
6299 |
||
6300 |
year = __MKSMALLINT(tmPtr->tm_year + 1900); |
|
6301 |
month = __MKSMALLINT(tmPtr->tm_mon + 1); |
|
6302 |
day = __MKSMALLINT(tmPtr->tm_mday); |
|
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6303 |
|
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6304 |
if (tmPtr->tm_isdst == 0) { |
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6305 |
dst = false; |
1135 | 6306 |
utcOffset = __MKSMALLINT(TIMEZONE); |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6307 |
} else { |
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6308 |
dst = true; |
800
067094efdaed
use HAS_ALTZONE / HAS_DAYLIGHT
Claus Gittinger <cg@exept.de>
parents:
798
diff
changeset
|
6309 |
#ifdef HAS_ALTZONE |
1135 | 6310 |
utcOffset = __MKSMALLINT(altzone); |
800
067094efdaed
use HAS_ALTZONE / HAS_DAYLIGHT
Claus Gittinger <cg@exept.de>
parents:
798
diff
changeset
|
6311 |
#else |
1135 | 6312 |
utcOffset = __MKSMALLINT(TIMEZONE) + 3600; |
800
067094efdaed
use HAS_ALTZONE / HAS_DAYLIGHT
Claus Gittinger <cg@exept.de>
parents:
798
diff
changeset
|
6313 |
#endif |
067094efdaed
use HAS_ALTZONE / HAS_DAYLIGHT
Claus Gittinger <cg@exept.de>
parents:
798
diff
changeset
|
6314 |
} |
63 | 6315 |
} |
241 | 6316 |
%}. |
63 | 6317 |
year notNil ifTrue:[ |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6318 |
"I would love to have SELF-like inline objects ..." |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6319 |
ret := Array new:8. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6320 |
ret at:1 put:year. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6321 |
ret at:2 put:month. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6322 |
ret at:3 put:day. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6323 |
ret at:4 put:hours. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6324 |
ret at:5 put:minutes. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6325 |
ret at:6 put:seconds. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6326 |
ret at:7 put:utcOffset. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6327 |
ret at:8 put:dst. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6328 |
^ ret |
63 | 6329 |
]. |
6330 |
^ self primitiveFailed |
|
6331 |
! |
|
6332 |
||
241 | 6333 |
computeTimePartsFromYear:y month:m day:d hour:h minute:min seconds:s |
6334 |
"return an Array containing the OS-dependent time for the given |
|
6335 |
time and day. The arguments are assumed to be in localtime including |
|
6336 |
any daylight saving adjustings." |
|
6337 |
||
6338 |
|low hi| |
|
6339 |
||
6340 |
%{ |
|
6341 |
struct tm tm; |
|
6342 |
long t; |
|
6343 |
||
252 | 6344 |
if (__bothSmallInteger(y, m) |
6345 |
&& __bothSmallInteger(d, h) |
|
6346 |
&& __bothSmallInteger(min, s)) { |
|
6347 |
tm.tm_hour = __intVal(h); |
|
6348 |
tm.tm_min = __intVal(min); |
|
6349 |
tm.tm_sec = __intVal(s); |
|
6350 |
||
6351 |
tm.tm_year = __intVal(y) - 1900; |
|
6352 |
tm.tm_mon = __intVal(m) - 1; |
|
6353 |
tm.tm_mday = __intVal(d); |
|
241 | 6354 |
tm.tm_isdst = -1; |
6355 |
||
6356 |
t = mktime(&tm); |
|
1135 | 6357 |
low = __MKSMALLINT(t & 0xFFFF); |
6358 |
hi = __MKSMALLINT((t >> 16) & 0xFFFF); |
|
241 | 6359 |
} |
6360 |
%}. |
|
6361 |
low notNil ifTrue:[ |
|
6362 |
^ Array with:low with:hi |
|
6363 |
]. |
|
6364 |
^ self primitiveFailed |
|
6365 |
! |
|
6366 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6367 |
computeTimePartsOf:osTimeLow and:osTimeHi for:aBlock |
616 | 6368 |
"compute hours, minutes and seconds from the time-parts timeLow and |
6369 |
timeHi and evaluate the argument, a 3-arg block with these. |
|
6370 |
Conversion is to localtime including any daylight saving adjustments. |
|
6371 |
||
6372 |
This method was added to avoid LargeInteger arithmetic and to be |
|
6373 |
independent of how the OperatingSystem represents time; |
|
6374 |
the time-parts expected are those returned by getTimeParts." |
|
6375 |
||
6376 |
|hours minutes seconds| |
|
6377 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6378 |
((osTimeLow isMemberOf:SmallInteger) |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6379 |
and:[osTimeHi isMemberOf:SmallInteger]) ifFalse:[ |
616 | 6380 |
^ self primitiveFailed |
6381 |
]. |
|
6382 |
%{ |
|
6383 |
struct tm *tmPtr; |
|
6384 |
long t; |
|
6385 |
||
1135 | 6386 |
t = (__intVal(osTimeHi) << 16) | __intVal(osTimeLow); |
616 | 6387 |
tmPtr = localtime(&t); |
1135 | 6388 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
6389 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
|
6390 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6391 |
%}. |
616 | 6392 |
aBlock value:hours value:minutes value:seconds |
6393 |
! |
|
6394 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6395 |
computeTimePartsOf:osTimeParts for:aBlock |
616 | 6396 |
"compute hour, minute and seconds from the ostime in timeParts, |
6397 |
and evaluate the argument, a 3-arg block with these. |
|
6398 |
Conversion is to localtime including any daylight saving adjustments." |
|
6399 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6400 |
^ self |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6401 |
computeTimePartsOf:(osTimeParts at:1) |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6402 |
and:(osTimeParts at:2) |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6403 |
for:aBlock |
275 | 6404 |
! |
6405 |
||
1 | 6406 |
getMillisecondTime |
185 | 6407 |
"This returns the millisecond timers value. |
6408 |
The range is limited to 0..1fffffff (i.e. the SmallInteger range) to avoid |
|
6409 |
LargeInteger arithmetic when doing timeouts and delays. |
|
792 | 6410 |
Since this value is wrapping around in regular intervals, this can only be used for |
185 | 6411 |
short relative time deltas. |
6412 |
Use the millisecondTimeXXX:-methods to compare and add time deltas - these know about the wrap. |
|
6413 |
||
6414 |
BAD DESIGN: |
|
6415 |
This should be changed to return some instance of RelativeTime, |
|
6416 |
and these computations moved there. |
|
95 | 6417 |
|
6418 |
Dont use this method in application code since it is an internal (private) |
|
6419 |
interface. For compatibility with ST-80, use Time millisecondClockValue. |
|
6420 |
" |
|
1 | 6421 |
|
6422 |
%{ /* NOCONTEXT */ |
|
6423 |
||
6424 |
long t; |
|
185 | 6425 |
#if !defined(HAS_GETTIMEOFDAY) && defined(SYSV) && defined(HZ) |
6426 |
/* |
|
6427 |
* sys5 time |
|
6428 |
*/ |
|
1 | 6429 |
long ticks; |
6430 |
struct tms tb; |
|
6431 |
||
6432 |
ticks = times(&tb); |
|
6433 |
t = (ticks * 1000) / HZ; |
|
792 | 6434 |
#else |
6435 |
# ifdef MSDOS_LIKE |
|
6436 |
struct _timeb timebuffer; |
|
6437 |
||
6438 |
_ftime(&timebuffer); |
|
6439 |
t = (timebuffer.time * 1000) + timebuffer.millitm; |
|
6440 |
# else /* assume HAS_GETTIMEOFDAY */ |
|
185 | 6441 |
/* |
6442 |
* bsd time |
|
6443 |
*/ |
|
1 | 6444 |
struct timeval tb; |
6445 |
struct timezone tzb; |
|
6446 |
||
6447 |
gettimeofday(&tb, &tzb); |
|
6448 |
t = tb.tv_sec*1000 + tb.tv_usec/1000; |
|
792 | 6449 |
# endif |
68 | 6450 |
#endif |
1135 | 6451 |
RETURN ( __MKSMALLINT(t & 0x1FFFFFFF) ); |
1 | 6452 |
%} |
6453 |
! |
|
6454 |
||
616 | 6455 |
getTime |
6456 |
"return current Time in some OS dependent representation. |
|
6457 |
(on unix, its the seconds since 1970). |
|
6458 |
||
831 | 6459 |
WARNING: |
6460 |
this is OperatingSystem dependent |
|
6461 |
- for portable code, use getTimeParts and compute*PartsOf:and:for:. |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6462 |
Better yet, use Date>>today or Time>>now for fully ST-80 compatible code." |
831 | 6463 |
|
6464 |
^ (OperatingSystem getTimeInto:[:low :hi | hi*16r10000 + low]) |
|
616 | 6465 |
|
6466 |
" |
|
6467 |
OperatingSystem getTime |
|
6468 |
" |
|
6469 |
! |
|
6470 |
||
6471 |
getTimeHi |
|
6472 |
"return hi 16 bits of current time. |
|
6473 |
||
6474 |
OBSOLETE: Dont use this method, use getTimeParts. |
|
6475 |
This method will NOT always return the correct time |
|
6476 |
if used together with getTimeHi, since a wrap between |
|
6477 |
the two getTimeXXX sends could occur. |
|
6478 |
WARNING: this method will vanish - dont use it." |
|
6479 |
||
6480 |
%{ /* NOCONTEXT */ |
|
6481 |
||
1135 | 6482 |
RETURN ( __MKSMALLINT((time(0) >> 16) & 0xFFFF) ); |
616 | 6483 |
%} |
6484 |
||
6485 |
"OperatingSystem getTimeHi" |
|
6486 |
! |
|
6487 |
||
6488 |
getTimeInto:aBlock |
|
6489 |
"evaluate the argument aBlock, passing the time-parts of |
|
6490 |
the current time as arguments. |
|
6491 |
See comment in 'OperatingSystem>>getTimeParts' on what to |
|
6492 |
do with those parts." |
|
6493 |
||
6494 |
|low hi| |
|
6495 |
%{ |
|
6496 |
int now; |
|
6497 |
||
6498 |
now = time(0); |
|
1135 | 6499 |
hi = __MKSMALLINT((now >> 16) & 0xFFFF); |
6500 |
low = __MKSMALLINT(now & 0xFFFF); |
|
831 | 6501 |
%}. |
6502 |
^ aBlock value:low value:hi |
|
6503 |
||
6504 |
" |
|
6505 |
OperatingSystem getTimeInto:[:low :hi | low printNewline. hi printNewline] |
|
6506 |
" |
|
616 | 6507 |
! |
6508 |
||
6509 |
getTimeLow |
|
6510 |
"return low 16 bits of current time. |
|
6511 |
||
6512 |
OBSOLETE: Dont use this method, use getTimeParts. |
|
6513 |
This method will not always return the correct time |
|
6514 |
if used together with getTimeHi, since a wrap between |
|
6515 |
the two getTimeXXX sends could occur. |
|
6516 |
WARNING: this method will vanish - dont use it." |
|
6517 |
||
6518 |
%{ /* NOCONTEXT */ |
|
6519 |
||
1135 | 6520 |
RETURN ( __MKSMALLINT(time(0) & 0xFFFF) ); |
616 | 6521 |
%} |
6522 |
||
831 | 6523 |
" |
6524 |
OperatingSystem getTimeLow |
|
6525 |
" |
|
616 | 6526 |
! |
6527 |
||
6528 |
getTimeParts |
|
6529 |
"return the current time as an array of 2 integers representing |
|
6530 |
the current time (usually low 16bits / hi 16 bits) in some OS |
|
6531 |
dependent way. |
|
6532 |
||
6533 |
On unix, the values represent the seconds since 1970, on other |
|
6534 |
systems this may be different. |
|
6535 |
WARNING: |
|
6536 |
for portability, never use these values directly, but pass them |
|
6537 |
to #computeTimeParts and/or #computeDatePartsOf:, which know how to |
|
6538 |
interpret them. |
|
6539 |
Better yet, use Date>>today and Time>>now for ST-80 compatibility." |
|
6540 |
||
6541 |
|low hi| |
|
6542 |
%{ |
|
6543 |
int now; |
|
6544 |
||
6545 |
now = time(0); |
|
1135 | 6546 |
hi = __MKSMALLINT((now >> 16) & 0xFFFF); |
6547 |
low = __MKSMALLINT(now & 0xFFFF); |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6548 |
%}. |
616 | 6549 |
^ Array with:low with:hi |
6550 |
||
831 | 6551 |
" |
6552 |
OperatingSystem getTimeParts |
|
6553 |
" |
|
616 | 6554 |
! |
6555 |
||
6556 |
maximumMillisecondTimeDelta |
|
6557 |
"this returns the maximum delta supported by millisecondCounter |
|
6558 |
based methods. The returned value is half the value at which the |
|
6559 |
timer wraps." |
|
6560 |
||
6561 |
%{ /* NOCONTEXT */ |
|
1135 | 6562 |
RETURN ( __MKSMALLINT(0x0FFFFFFF) ); |
616 | 6563 |
%} |
6564 |
! |
|
6565 |
||
6566 |
millisecondDelay:millis |
|
6567 |
"delay execution for millis milliseconds or until the next event |
|
6568 |
arrives. |
|
6569 |
All lower priority threads will also sleep for the duration, |
|
6570 |
interrupts (and therefore, higher prio processes) are |
|
6571 |
still handled. |
|
6572 |
Better use a Delay, to only delay the calling thread. |
|
6573 |
(however, a delay cannot be used in the event handler or scheduler)" |
|
6574 |
||
6575 |
|now then delta| |
|
6576 |
||
831 | 6577 |
%{ /* NOCONTEXT */ |
6578 |
#ifdef WIN32 |
|
6579 |
int t = __intVal(millis); |
|
6580 |
||
6581 |
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
|
6582 |
Sleep(t); |
831 | 6583 |
} |
6584 |
RETURN (self); |
|
6585 |
#endif |
|
6586 |
%}. |
|
6587 |
||
616 | 6588 |
now := OperatingSystem getMillisecondTime. |
6589 |
then := OperatingSystem millisecondTimeAdd:now and:millis. |
|
6590 |
||
6591 |
[OperatingSystem millisecondTime:then isAfter:now] whileTrue:[ |
|
6592 |
delta := OperatingSystem millisecondTimeDeltaBetween:then and:now. |
|
6593 |
self selectOnAnyReadable:nil writable:nil exception:nil withTimeOut:delta. |
|
6594 |
now := OperatingSystem getMillisecondTime. |
|
6595 |
] |
|
6596 |
||
6597 |
" |
|
6598 |
OperatingSystem millisecondDelay:2000 |
|
6599 |
" |
|
6600 |
! |
|
6601 |
||
6602 |
millisecondTime:msTime1 isAfter:msTime2 |
|
6603 |
"return true if msTime1 is after msTime2, false if not. |
|
6604 |
The two arguments are supposed to be millisecond times |
|
6605 |
(such as returned getMillisecondTime) which wrap at 16r1FFFFFFF. |
|
6606 |
||
6607 |
This should really be moved to some RelativeTime class." |
|
6608 |
||
6609 |
(msTime1 > msTime2) ifTrue:[ |
|
6610 |
((msTime1 - msTime2) >= 16r10000000) ifTrue:[ |
|
6611 |
^ false |
|
6612 |
]. |
|
6613 |
^ true |
|
6614 |
]. |
|
6615 |
((msTime2 - msTime1) > 16r10000000) ifTrue:[ |
|
6616 |
^ true |
|
6617 |
]. |
|
6618 |
^ false |
|
6619 |
! |
|
6620 |
||
6621 |
millisecondTimeAdd:msTime1 and:msTime2 |
|
6622 |
"Add two millisecond times (such as returned getMillisecondTime). |
|
6623 |
The returned value is msTime1 + msTime2 where a wrap occurs at:16r1FFFFFFF. |
|
6624 |
||
6625 |
This should really be moved to some RelativeTime class." |
|
6626 |
||
6627 |
|sum| |
|
6628 |
||
6629 |
sum := msTime1 + msTime2. |
|
6630 |
(sum > 16r1FFFFFFF) ifTrue:[^ sum - 16r20000000]. |
|
6631 |
(sum < 0) ifTrue:[^ sum + 16r20000000]. |
|
6632 |
^ sum |
|
6633 |
! |
|
6634 |
||
1 | 6635 |
millisecondTimeDeltaBetween:msTime1 and:msTime2 |
95 | 6636 |
"subtract two millisecond times (such as returned getMillisecondTime) |
185 | 6637 |
and return the difference. Since milli-times wrap (at 16r01FFFFFFF), |
95 | 6638 |
some special handling is built-in here. |
185 | 6639 |
The returned value is msTime1 - msTime2. The returned value is invalid |
6640 |
if the delta is >= 0x10000000. |
|
63 | 6641 |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6642 |
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
|
6643 |
better yet: create a subclass of Integer named LimitedRangeInteger." |
1 | 6644 |
|
6645 |
(msTime1 > msTime2) ifTrue:[ |
|
185 | 6646 |
^ msTime1 - msTime2 |
1 | 6647 |
]. |
6648 |
^ msTime1 + 16r10000000 - msTime2 |
|
95 | 6649 |
|
6650 |
" |
|
6651 |
OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:1 |
|
6652 |
OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:(16 / 3) |
|
6653 |
OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:1000 |
|
6654 |
||
6655 |
OperatingSystem millisecondTimeDeltaBetween:0 and:16r0FFFFFFF |
|
6656 |
OperatingSystem millisecondTimeDeltaBetween:(13/3) and:16r0FFFFFFF |
|
6657 |
OperatingSystem millisecondTimeDeltaBetween:999 and:16r0FFFFFFF |
|
6658 |
||
6659 |
OperatingSystem millisecondTime:0 isAfter:16r0FFFFFFF |
|
6660 |
OperatingSystem millisecondTime:(13/3) isAfter:16r0FFFFFFF |
|
6661 |
OperatingSystem millisecondTime:999 isAfter:16r0FFFFFFF |
|
6662 |
||
6663 |
OperatingSystem millisecondTime:0 isAfter:0 |
|
6664 |
OperatingSystem millisecondTime:(13/3) isAfter:0 |
|
6665 |
OperatingSystem millisecondTime:999 isAfter:0 |
|
6666 |
||
6667 |
OperatingSystem millisecondTime:1 isAfter:0 |
|
6668 |
OperatingSystem millisecondTime:(13/3) isAfter:2 |
|
6669 |
OperatingSystem millisecondTime:999 isAfter:900 |
|
6670 |
||
6671 |
|t1 t2| |
|
6672 |
||
6673 |
t1 := Time millisecondClockValue. |
|
6674 |
(Delay forMilliseconds:1) wait. |
|
6675 |
t2 := Time millisecondClockValue. |
|
6676 |
OperatingSystem millisecondTimeDeltaBetween:t2 and:t1 |
|
6677 |
" |
|
1 | 6678 |
! |
6679 |
||
6680 |
sleep:numberOfSeconds |
|
308 | 6681 |
"cease ANY action for some time. This suspends the whole smalltalk |
6682 |
(unix-) process for some time. |
|
1 | 6683 |
Not really useful since not even low-prio processes and interrupt |
95 | 6684 |
handling will run during the sleep. |
6685 |
Use either OperatingSystem>>millisecondDelay: (which makes all |
|
6686 |
threads sleep, but handles interrupts) or use a Delay (which makes |
|
6687 |
only the calling thread sleep)." |
|
1 | 6688 |
|
6689 |
%{ /* NOCONTEXT */ |
|
6690 |
||
252 | 6691 |
if (__isSmallInteger(numberOfSeconds)) { |
1135 | 6692 |
sleep(__intVal(numberOfSeconds)); |
185 | 6693 |
RETURN ( self ); |
1 | 6694 |
} |
68 | 6695 |
%}. |
6696 |
" |
|
6697 |
argument not integer |
|
6698 |
" |
|
792 | 6699 |
^ self primitiveFailed |
95 | 6700 |
|
6701 |
" |
|
6702 |
OperatingSystem sleep:2 |
|
6703 |
" |
|
10 | 6704 |
! ! |
6705 |
||
616 | 6706 |
!OperatingSystem class methodsFor:'users & groups'! |
6707 |
||
6708 |
getEffectiveGroupID |
|
6709 |
"return the current users (thats you) effective numeric group id. |
|
6710 |
This is only different from getGroupID, if you have ST/X running |
|
6711 |
as a setuid program (of which you should think about twice)." |
|
6712 |
||
6713 |
%{ /* NOCONTEXT */ |
|
6714 |
||
6715 |
#ifdef UNIX_LIKE |
|
6716 |
int uid; |
|
6717 |
||
6718 |
uid = getegid(); |
|
6719 |
RETURN ( __MKSMALLINT(uid) ); |
|
6720 |
#endif |
|
6721 |
/* --- return same as getGroupID --- */ |
|
6722 |
%}. |
|
6723 |
^ self getGroupID |
|
6724 |
||
6725 |
" |
|
6726 |
OperatingSystem getEffectiveGroupID |
|
6727 |
" |
|
6728 |
! |
|
6729 |
||
6730 |
getEffectiveUserID |
|
6731 |
"return the current users (thats you) effective numeric user id. |
|
6732 |
This is only different from getUserID, if you have ST/X running |
|
6733 |
as a setuid program (of which you should think about twice)." |
|
10 | 6734 |
|
6735 |
%{ /* NOCONTEXT */ |
|
6736 |
||
616 | 6737 |
#ifdef UNIX_LIKE |
6738 |
int uid; |
|
6739 |
||
6740 |
uid = geteuid(); |
|
6741 |
RETURN ( __MKSMALLINT(uid) ); |
|
6742 |
#endif |
|
6743 |
/* --- return same as getUserID --- */ |
|
6744 |
%}. |
|
6745 |
^ self getUserID |
|
6746 |
||
6747 |
" |
|
6748 |
OperatingSystem getEffectiveUserID |
|
6749 |
" |
|
6750 |
! |
|
6751 |
||
6752 |
getGroupID |
|
6753 |
"return the current users (thats you) numeric group id" |
|
6754 |
||
6755 |
%{ /* NOCONTEXT */ |
|
6756 |
||
6757 |
#ifdef UNIX_LIKE |
|
6758 |
int uid; |
|
6759 |
||
6760 |
uid = getgid(); |
|
6761 |
RETURN ( __MKSMALLINT(uid) ); |
|
6762 |
#else |
|
6763 |
# ifdef SYSTEM_HAS_GROUPS |
|
6764 |
/* ... */ |
|
10 | 6765 |
# endif |
6766 |
#endif |
|
68 | 6767 |
%}. |
616 | 6768 |
^ 1 "just a dummy for systems which do not have userIDs" |
6769 |
||
68 | 6770 |
" |
616 | 6771 |
OperatingSystem getGroupID |
6772 |
" |
|
6773 |
! |
|
6774 |
||
6775 |
getGroupNameFromID:aNumber |
|
6776 |
"return the group-name-string for a given numeric group-id" |
|
6777 |
||
6778 |
%{ /* NOCONTEXT */ |
|
6779 |
||
6780 |
#ifdef UNIX_LIKE |
|
6781 |
struct group *g; |
|
6782 |
||
6783 |
if (__isSmallInteger(aNumber)) { |
|
1135 | 6784 |
g = getgrgid(__intVal(aNumber)); |
616 | 6785 |
if (g) { |
830 | 6786 |
RETURN ( __MKSTRING(g->gr_name COMMA_CON) ); |
616 | 6787 |
} |
6788 |
} |
|
6789 |
#endif |
|
6790 |
%}. |
|
6791 |
^ '???' |
|
6792 |
||
6793 |
" |
|
6794 |
OperatingSystem getGroupNameFromID:0 |
|
6795 |
OperatingSystem getGroupNameFromID:10 |
|
6796 |
" |
|
6797 |
! |
|
6798 |
||
6799 |
getHomeDirectory |
|
6800 |
"return the name of the users home directory" |
|
6801 |
||
6802 |
^ OperatingSystem getEnvironment:'HOME' |
|
6803 |
||
6804 |
" |
|
6805 |
OperatingSystem getHomeDirectory |
|
6806 |
" |
|
6807 |
! |
|
6808 |
||
6809 |
getLoginName |
|
6810 |
"return a string with the users name" |
|
6811 |
||
6812 |
%{ /* NOCONTEXT */ |
|
6813 |
static char cachedName[64]; |
|
6814 |
static firstCall = 1; |
|
6815 |
||
831 | 6816 |
char *name = (char *)0; |
616 | 6817 |
#ifdef UNIX_LIKE |
6818 |
if (firstCall) { |
|
6819 |
name = (char *)getlogin(); |
|
6820 |
if (! name || (name[0] == 0)) { |
|
6821 |
name = (char *)getenv("LOGNAME"); |
|
6822 |
} |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
6823 |
if (name && (strlen(name) < sizeof(cachedName))) { |
616 | 6824 |
strcpy(cachedName, name); |
6825 |
firstCall = 0; |
|
6826 |
} |
|
6827 |
} else { |
|
6828 |
name = cachedName; |
|
6829 |
} |
|
831 | 6830 |
#else |
6831 |
# ifdef MSDOS_LIKE |
|
6832 |
if (firstCall) { |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6833 |
int nameSize = sizeof(cachedName); |
831 | 6834 |
|
6835 |
if (GetUserName(cachedName, &nameSize) == TRUE) { |
|
6836 |
name = cachedName; |
|
6837 |
firstCall = 0; |
|
6838 |
} |
|
6839 |
} else { |
|
6840 |
name = cachedName; |
|
6841 |
} |
|
6842 |
# endif |
|
6843 |
#endif |
|
6844 |
if (! name || (name[0] == 0) ) { |
|
6845 |
name = (char *)getenv("LOGNAME"); |
|
6846 |
} |
|
6847 |
if (! name || (name[0] == 0) ) { |
|
6848 |
name = "you"; |
|
6849 |
} |
|
6850 |
||
830 | 6851 |
RETURN ( __MKSTRING(name COMMA_CON) ); |
831 | 6852 |
%}. |
616 | 6853 |
" |
6854 |
OperatingSystem getLoginName |
|
6855 |
" |
|
6856 |
! |
|
6857 |
||
6858 |
getUserID |
|
6859 |
"return the current users (thats you) numeric user id" |
|
6860 |
||
6861 |
%{ /* NOCONTEXT */ |
|
6862 |
||
6863 |
#ifdef UNIX_LIKE |
|
6864 |
int uid; |
|
6865 |
||
6866 |
uid = getuid(); |
|
6867 |
RETURN ( __MKSMALLINT(uid) ); |
|
6868 |
#else |
|
6869 |
# ifdef SYSTEM_HAS_USERS |
|
6870 |
/* ... */ |
|
6871 |
# endif |
|
6872 |
#endif |
|
6873 |
%}. |
|
6874 |
^ 1 "just a dummy for systems which do not have userIDs" |
|
6875 |
||
6876 |
" |
|
6877 |
OperatingSystem getUserID |
|
68 | 6878 |
" |
616 | 6879 |
! |
6880 |
||
6881 |
getUserNameFromID:aNumber |
|
6882 |
"return the user-name-string for a given numeric user-id" |
|
6883 |
||
6884 |
%{ /* NOCONTEXT */ |
|
6885 |
||
6886 |
#ifdef UNIX_LIKE |
|
6887 |
struct passwd *p; |
|
6888 |
||
6889 |
if (__isSmallInteger(aNumber)) { |
|
1135 | 6890 |
p = getpwuid(__intVal(aNumber)); |
616 | 6891 |
if (p) { |
830 | 6892 |
RETURN ( __MKSTRING(p->pw_name COMMA_CON) ); |
616 | 6893 |
} |
6894 |
} |
|
6895 |
#endif |
|
6896 |
%}. |
|
6897 |
^ '? (' , aNumber printString , ')' |
|
6898 |
||
6899 |
" |
|
6900 |
OperatingSystem getUserNameFromID:0 |
|
6901 |
OperatingSystem getUserNameFromID:100 |
|
6902 |
OperatingSystem getUserNameFromID:9991 |
|
6903 |
" |
|
1 | 6904 |
! |
6905 |
||
616 | 6906 |
userInfoOf:aNameOrID |
6907 |
"return a dictionary filled with userinfo. The argument can be either |
|
6908 |
a string with the users name or its numeric id. |
|
6909 |
Notice, that not all systems provide (all of) this info; |
|
6910 |
DOS systems return nothing; |
|
6911 |
non-SYSV4 systems have no age/comment. |
|
6912 |
Portable applications may want to check the systemType and NOT depend |
|
6913 |
on all keys to be present in the returned dictionary. |
|
6914 |
Another notice: on some systems (SYSV4), the gecos field includes multiple |
|
6915 |
entries (i.e. not just the name), separated by commas. You may want to |
|
6916 |
extract any substring, up to the first comma to get the real life name." |
|
6917 |
||
6918 |
|info name passw uid gid age comment |
|
6919 |
gecos dir shell| |
|
6920 |
||
6921 |
%{ |
|
6922 |
#ifdef UNIX_LIKE |
|
6923 |
struct passwd *buf; |
|
6924 |
int ret; |
|
6925 |
||
6926 |
if (__isString(aNameOrID)) { |
|
6927 |
buf = getpwnam(__stringVal(aNameOrID)); |
|
6928 |
} else if (__isSmallInteger(aNameOrID)) { |
|
6929 |
buf = getpwuid(__intVal(aNameOrID)); |
|
6930 |
} else { |
|
6931 |
buf = (struct passwd *)0; |
|
6932 |
} |
|
6933 |
if (buf) { |
|
830 | 6934 |
name = __MKSTRING(buf->pw_name COMMA_CON); |
6935 |
passw = __MKSTRING(buf->pw_passwd COMMA_CON); |
|
616 | 6936 |
# ifdef SYSV4 |
830 | 6937 |
age = __MKSTRING(buf->pw_age COMMA_CON); |
6938 |
comment = __MKSTRING(buf->pw_comment COMMA_CON); |
|
616 | 6939 |
# endif |
830 | 6940 |
dir = __MKSTRING(buf->pw_dir COMMA_CON); |
6941 |
gecos = __MKSTRING(buf->pw_gecos COMMA_CON); |
|
6942 |
shell = __MKSTRING(buf->pw_shell COMMA_CON); |
|
616 | 6943 |
|
1135 | 6944 |
uid = __MKSMALLINT(buf->pw_uid); |
6945 |
gid = __MKSMALLINT(buf->pw_gid); |
|
616 | 6946 |
} |
6947 |
#endif |
|
6948 |
%}. |
|
6949 |
info := IdentityDictionary new. |
|
6950 |
name notNil ifTrue:[ |
|
6951 |
info at:#name put:name. |
|
6952 |
] ifFalse:[ |
|
6953 |
info at:#name put:'unknown' |
|
6954 |
]. |
|
6955 |
passw notNil ifTrue:[info at:#passwd put:passw]. |
|
6956 |
age notNil ifTrue:[info at:#age put:age]. |
|
6957 |
comment notNil ifTrue:[info at:#comment put:comment]. |
|
6958 |
gecos notNil ifTrue:[info at:#gecos put:gecos]. |
|
6959 |
shell notNil ifTrue:[info at:#shell put:shell]. |
|
6960 |
dir notNil ifTrue:[info at:#dir put:dir]. |
|
6961 |
uid notNil ifTrue:[info at:#uid put:uid]. |
|
6962 |
gid notNil ifTrue:[info at:#gid put:gid]. |
|
6963 |
^ info |
|
6964 |
||
6965 |
" |
|
6966 |
OperatingSystem userInfoOf:'root' |
|
6967 |
OperatingSystem userInfoOf:1 |
|
6968 |
OperatingSystem userInfoOf:'claus' |
|
6969 |
OperatingSystem userInfoOf:'fooBar' |
|
6970 |
OperatingSystem userInfoOf:(OperatingSystem getUserID) |
|
6971 |
" |
|
6972 |
! ! |
|
6973 |
||
6974 |
!OperatingSystem class methodsFor:'waiting for events'! |
|
6975 |
||
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6976 |
blockingChildProcessWait |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6977 |
"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
|
6978 |
%{ /*NOCONTEXT*/ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6979 |
#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
|
6980 |
RETURN(false); |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6981 |
#else |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6982 |
RETURN(true); |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6983 |
#endif |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6984 |
%} |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6985 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6986 |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6987 |
childProcessWait:blocking |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6988 |
"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
|
6989 |
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
|
6990 |
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
|
6991 |
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
|
6992 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6993 |
|pid status code core| |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6994 |
%{ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6995 |
int p; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6996 |
#if defined(HAS_WAITPID) |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6997 |
int s; |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6998 |
# define __WAIT waitpid(-1, &s, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED) |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6999 |
#else |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7000 |
# if defined(HAS_WAIT3) |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7001 |
union wait s; |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7002 |
#define __WAIT wait3(&s, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED, 0) |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7003 |
# else /*!HAS_WAIT3*/ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7004 |
int s; |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7005 |
# define __WAIT wait(&s) |
1433 | 7006 |
# define __BLOCKING_WAIT__ 1 |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7007 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7008 |
# if !defined(WIFEXITED) |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7009 |
# define WIFEXITED(stat) (((int)((stat)&0377))==0) |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7010 |
# define WIFSIGNALED(stat) (((int)((stat)&0377))>0&&((int)(((stat)>>8)&0377))==0) |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7011 |
# define WIFSTOPPED(stat) (((int)((stat)&0377))==0177&&((int)(((stat)>>8)&0377))!=0) |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7012 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7013 |
# define WEXITSTATUS(stat) ((int)(((stat)>>8)&0377)) |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7014 |
# define WTERMSIG(stat) (((int)((stat)&0377))&0177) |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7015 |
# define WSTOPSIG(stat) ((int)(((stat)>>8)&0377)) |
843 | 7016 |
# endif /*!WIFEXITED*/ |
7017 |
# if !defined(WCOREDUMP) |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
7018 |
# define WCOREDUMP(stat) ((int)(((stat)>>8)&0200)) |
843 | 7019 |
# endif /*!WCOREDUMP*/ |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7020 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7021 |
if (blocking != true) { |
1487 | 7022 |
/* |
7023 |
* We do not support nonBlocking waits, so signal an error |
|
7024 |
* Sorry about the goto, but with all these ifdefs ... |
|
7025 |
*/ |
|
7026 |
goto done; |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7027 |
} |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7028 |
# endif /*!HAS_WAIT3*/ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7029 |
#endif /*!HAS_WAITPID*/ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7030 |
|
1433 | 7031 |
#if __BLOCKING_WAIT__ |
7032 |
__BEGIN_INTERRUPTABLE__ |
|
7033 |
#endif |
|
7034 |
||
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7035 |
do { |
1487 | 7036 |
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
|
7037 |
} 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
|
7038 |
|
1433 | 7039 |
#if __BLOCKING_WAIT__ |
7040 |
__END_INTERRUPTABLE__ |
|
7041 |
# undef __BLOCKING_WAIT__ |
|
7042 |
#endif |
|
7043 |
||
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7044 |
#undef __WAIT |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7045 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7046 |
if (p == 0) |
1487 | 7047 |
RETURN(nil) |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7048 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7049 |
if (p == -1) { |
1487 | 7050 |
if (errno == ECHILD) |
7051 |
RETURN(nil); |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7052 |
} else { |
1487 | 7053 |
pid = __MKSMALLINT(p); |
7054 |
if (WIFEXITED(s)) { |
|
7055 |
status = @symbol(exit); |
|
7056 |
code = __MKSMALLINT(WEXITSTATUS(s)); |
|
7057 |
core = WCOREDUMP(s) ? true : false; |
|
7058 |
} else if (WIFSIGNALED(s)) { |
|
7059 |
status = @symbol(signal); |
|
7060 |
code = __MKSMALLINT(WTERMSIG(s)); |
|
7061 |
} else if (WIFSTOPPED(s)) { |
|
7062 |
status = @symbol(stop); |
|
7063 |
code = __MKSMALLINT(WSTOPSIG(s)); |
|
7064 |
} |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7065 |
#if defined(WIFCONTINUED) |
1487 | 7066 |
else if (WIFCONTINUED(s)) { |
7067 |
status = @symbol(continue); |
|
7068 |
} |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7069 |
#endif |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7070 |
} |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7071 |
done: ; |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7072 |
%}. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7073 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7074 |
pid isNil ifTrue:[ |
1487 | 7075 |
^ self primitiveFailed |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7076 |
]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7077 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7078 |
^ 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
|
7079 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7080 |
" |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7081 |
OperatingSystem childProcessWait:false |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7082 |
" |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7083 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7084 |
"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
|
7085 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7086 |
|
10 | 7087 |
readCheck:fd |
95 | 7088 |
"return true, if data is available on a filedescriptor (i.e. read |
7089 |
is possible without blocking)" |
|
10 | 7090 |
|
7091 |
(self selectOnAnyReadable:(Array with:fd) |
|
185 | 7092 |
writable:nil |
7093 |
exception:nil |
|
7094 |
withTimeOut:0) == fd |
|
7095 |
ifTrue:[^ true]. |
|
10 | 7096 |
^ false |
7097 |
! |
|
7098 |
||
616 | 7099 |
selectOn:fd1 and:fd2 withTimeOut:millis |
7100 |
"wait for any fd to become ready; timeout after t milliseconds. |
|
7101 |
A zero timeout-time will immediately return (i.e. poll). |
|
7102 |
Return fd if i/o ok, nil if timed-out or interrupted. |
|
7103 |
Obsolete: |
|
7104 |
This is a leftover method and will vanish." |
|
7105 |
||
7106 |
^ self selectOnAnyReadable:(Array with:fd1 with:fd2) |
|
7107 |
writable:(Array with:fd1 with:fd2) |
|
7108 |
exception:nil |
|
7109 |
withTimeOut:millis |
|
10 | 7110 |
! |
7111 |
||
7112 |
selectOn:fd withTimeOut:millis |
|
7113 |
"wait for aFileDesriptor to become ready; timeout after t milliseconds. |
|
1 | 7114 |
Return true, if i/o ok, false if timed-out or interrupted. |
7115 |
With 0 as timeout argument, this can be used to check for availability |
|
7116 |
of read-data. |
|
7117 |
Experimental." |
|
7118 |
||
3 | 7119 |
^ self selectOnAnyReadable:(Array with:fd) |
185 | 7120 |
writable:(Array with:fd) |
7121 |
exception:nil |
|
7122 |
withTimeOut:millis |
|
1 | 7123 |
! |
7124 |
||
616 | 7125 |
selectOnAny:fdArray withTimeOut:millis |
7126 |
"wait for any fd in fdArray (an Array of integers) to become ready; |
|
7127 |
timeout after t milliseconds. An empty set will always wait. |
|
7128 |
Return first ready fd if i/o ok, nil if timed-out or interrupted. |
|
7129 |
Experimental." |
|
7130 |
||
7131 |
^ self selectOnAnyReadable:fdArray |
|
7132 |
writable:fdArray |
|
185 | 7133 |
exception:nil |
7134 |
withTimeOut:millis |
|
1 | 7135 |
! |
7136 |
||
10 | 7137 |
selectOnAnyReadable:fdArray withTimeOut:millis |
95 | 7138 |
"wait for any fd in fdArray (an Array of integers) to become ready for |
7139 |
reading. Timeout after t milliseconds. An empty set will always wait. |
|
7140 |
A zero timeout-time will immediately return (i.e. poll). |
|
3 | 7141 |
Return first ready fd if i/o ok, nil if timed-out or interrupted. |
7142 |
Experimental." |
|
7143 |
||
7144 |
^ self selectOnAnyReadable:fdArray |
|
185 | 7145 |
writable:nil |
7146 |
exception:nil |
|
7147 |
withTimeOut:millis |
|
3 | 7148 |
! |
7149 |
||
95 | 7150 |
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray withTimeOut:millis |
7151 |
"wait for any fd in readFdArray (an Array of integers) to become ready for |
|
7152 |
reading, writeFdArray to become ready for writing, or exceptFdArray to |
|
7153 |
arrive exceptional data (i.e. out-of-band data). |
|
7154 |
Timeout after t milliseconds or, if the timeout time is 0, immediately.. |
|
7155 |
Empty fd-sets will always wait. Zero time can be used to poll file- |
|
7156 |
descriptors (i.e. to check if I/O possible without blocking). |
|
7157 |
Return first ready fd if I/O ok, nil if timed-out or interrupted." |
|
3 | 7158 |
|
1 | 7159 |
%{ |
831 | 7160 |
#ifdef MSDOS_LIKE |
7161 |
/* |
|
7162 |
* support a delay-wait only |
|
7163 |
* (i.e. fail if any filedescriptor is selected upon) |
|
7164 |
*/ |
|
7165 |
int count; |
|
7166 |
int i; |
|
7167 |
int t; |
|
7168 |
OBJ fd; |
|
7169 |
||
7170 |
if (! __isSmallInteger(millis)) { |
|
7171 |
goto fail; |
|
7172 |
} |
|
7173 |
||
7174 |
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
|
7175 |
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
|
7176 |
goto fail; |
831 | 7177 |
} |
7178 |
count = __arraySize(readFdArray); |
|
7179 |
for (i=0; i<count;i++) { |
|
1135 | 7180 |
fd = __ArrayInstPtr(readFdArray)->a_element[i]; |
831 | 7181 |
if (fd != nil) { |
7182 |
goto fail; |
|
7183 |
} |
|
7184 |
} |
|
7185 |
} |
|
7186 |
if (writeFdArray != nil) { |
|
7187 |
if (! __isArray(writeFdArray)) { |
|
7188 |
goto fail; |
|
7189 |
} |
|
7190 |
count = __arraySize(writeFdArray); |
|
7191 |
for (i=0; i<count;i++) { |
|
1135 | 7192 |
fd = __ArrayInstPtr(writeFdArray)->a_element[i]; |
831 | 7193 |
if (fd != nil) { |
7194 |
goto fail; |
|
7195 |
} |
|
7196 |
} |
|
7197 |
} |
|
7198 |
if (exceptFdArray != nil) { |
|
7199 |
if (! __isArray(exceptFdArray)) { |
|
7200 |
goto fail; |
|
7201 |
} |
|
7202 |
count = __arraySize(exceptFdArray); |
|
7203 |
for (i=0; i<count;i++) { |
|
1135 | 7204 |
fd = __ArrayInstPtr(exceptFdArray)->a_element[i]; |
831 | 7205 |
if (fd != nil) { |
7206 |
goto fail; |
|
7207 |
} |
|
7208 |
} |
|
7209 |
} |
|
1135 | 7210 |
t = __intVal(millis); |
831 | 7211 |
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
|
7212 |
/* |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
7213 |
* delay only |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
7214 |
*/ |
831 | 7215 |
Sleep(t); |
7216 |
} |
|
7217 |
RETURN (nil); |
|
7218 |
||
7219 |
#else /* not MSDOS_LIKE */ |
|
1 | 7220 |
fd_set rset, wset, eset; |
831 | 7221 |
struct timeval wt, et; |
1 | 7222 |
int t, f, maxF, i, lX, bX; |
7223 |
OBJ fd, retFd; |
|
95 | 7224 |
int ret; |
300 | 7225 |
int count; |
1 | 7226 |
|
252 | 7227 |
if (__isSmallInteger(millis)) { |
185 | 7228 |
FD_ZERO(&rset); |
7229 |
FD_ZERO(&wset); |
|
7230 |
FD_ZERO(&eset); |
|
7231 |
||
7232 |
maxF = -1; |
|
308 | 7233 |
if (readFdArray != nil) { |
300 | 7234 |
if (! __isArray(readFdArray)) { |
7235 |
goto fail; |
|
7236 |
} |
|
7237 |
count = __arraySize(readFdArray); |
|
308 | 7238 |
|
7239 |
for (i=0; i<count;i++) { |
|
1135 | 7240 |
fd = __ArrayInstPtr(readFdArray)->a_element[i]; |
308 | 7241 |
if (fd != nil) { |
1135 | 7242 |
f = __intVal(fd); |
308 | 7243 |
if ((f >= 0) && (f < FD_SETSIZE)) { |
7244 |
FD_SET(f, &rset); |
|
7245 |
if (f > maxF) maxF = f; |
|
7246 |
} |
|
185 | 7247 |
} |
7248 |
} |
|
7249 |
} |
|
300 | 7250 |
|
308 | 7251 |
if (writeFdArray != nil) { |
300 | 7252 |
if (! __isArray(writeFdArray)) { |
7253 |
goto fail; |
|
7254 |
} |
|
7255 |
count = __arraySize(writeFdArray); |
|
308 | 7256 |
for (i=0; i<count;i++) { |
1135 | 7257 |
fd = __ArrayInstPtr(writeFdArray)->a_element[i]; |
308 | 7258 |
if (fd != nil) { |
1135 | 7259 |
f = __intVal(fd); |
308 | 7260 |
if ((f >= 0) && (f < FD_SETSIZE)) { |
7261 |
FD_SET(f, &wset); |
|
7262 |
if (f > maxF) maxF = f; |
|
7263 |
} |
|
185 | 7264 |
} |
7265 |
} |
|
7266 |
} |
|
300 | 7267 |
|
308 | 7268 |
if (exceptFdArray != nil) { |
300 | 7269 |
if (! __isArray(exceptFdArray)) { |
7270 |
goto fail; |
|
7271 |
} |
|
7272 |
count = __arraySize(exceptFdArray); |
|
308 | 7273 |
for (i=0; i<count;i++) { |
1135 | 7274 |
fd = __ArrayInstPtr(exceptFdArray)->a_element[i]; |
308 | 7275 |
if (fd != nil) { |
1135 | 7276 |
f = __intVal(fd); |
308 | 7277 |
if ((f >= 0) && (f < FD_SETSIZE)) { |
7278 |
FD_SET(f, &eset); |
|
7279 |
if (f > maxF) maxF = f; |
|
7280 |
} |
|
185 | 7281 |
} |
7282 |
} |
|
7283 |
} |
|
308 | 7284 |
|
1135 | 7285 |
t = __intVal(millis); |
774
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7286 |
if (t) { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7287 |
wt.tv_sec = t / 1000; |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7288 |
wt.tv_usec = (t % 1000) * 1000; |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7289 |
} else { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7290 |
wt.tv_sec = wt.tv_usec = 0; |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7291 |
} |
185 | 7292 |
|
7293 |
/* |
|
7294 |
* make certain, that interrupt gets us out of the select |
|
7295 |
*/ |
|
362 | 7296 |
__BEGIN_INTERRUPTABLE__ |
185 | 7297 |
errno = 0; |
774
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7298 |
|
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7299 |
if (t == 0) { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7300 |
/* |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7301 |
* 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
|
7302 |
* interruptable. |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7303 |
*/ |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7304 |
do { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7305 |
ret = select(maxF+1, &rset, &wset, &eset, &wt); |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7306 |
} while ((ret < 0) && (errno == EINTR)); |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7307 |
} else { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7308 |
do { |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7309 |
ret = select(maxF+1, &rset, &wset, &eset, &wt); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7310 |
/* |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7311 |
* 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
|
7312 |
* could otherwise stay in this loop forever ... |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7313 |
* 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
|
7314 |
* 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
|
7315 |
*/ |
774
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7316 |
} while (0 /* (ret < 0) && (errno == EINTR) */ ); |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7317 |
} |
362 | 7318 |
__END_INTERRUPTABLE__ |
95 | 7319 |
|
185 | 7320 |
if (ret > 0) { |
7321 |
for (i=0; i <= maxF; i++) { |
|
7322 |
if (FD_ISSET(i, &rset) |
|
7323 |
|| FD_ISSET(i, &wset) |
|
7324 |
|| FD_ISSET(i, &eset)) { |
|
1135 | 7325 |
RETURN ( __MKSMALLINT(i) ); |
185 | 7326 |
} |
7327 |
} |
|
855
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
7328 |
} else { |
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
7329 |
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
|
7330 |
if (errno != EINTR) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
7331 |
fprintf(stderr, "OS: select errno = %d\n", errno); |
1135 | 7332 |
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
|
7333 |
} |
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
7334 |
} |
185 | 7335 |
} |
308 | 7336 |
|
185 | 7337 |
/* |
7338 |
* return nil (means time expired) |
|
7339 |
*/ |
|
7340 |
RETURN ( nil ); |
|
1 | 7341 |
} |
831 | 7342 |
#endif /* not MSDOS_LIKE */ |
7343 |
||
300 | 7344 |
fail: ; |
68 | 7345 |
%}. |
7346 |
" |
|
300 | 7347 |
timeout argument not integer, |
7348 |
or any fd-array nonNil and not an array |
|
792 | 7349 |
or not supported by OS |
68 | 7350 |
" |
792 | 7351 |
^ self primitiveFailed |
1 | 7352 |
! |
7353 |
||
616 | 7354 |
setBlocking:aBoolean on:fd |
7355 |
"set/clear the blocking attribute - if set (which is the default) |
|
7356 |
a read on the fileDescriptor will block until data is available. |
|
7357 |
If cleared, a read operation will immediately return with a value of |
|
7358 |
nil." |
|
10 | 7359 |
|
7360 |
%{ /* NOCONTEXT */ |
|
7361 |
||
616 | 7362 |
int ret, flags; |
7363 |
int savInt; |
|
7364 |
||
7365 |
#if defined(F_GETFL) && defined(F_SETFL) |
|
7366 |
# if defined(FNDELAY) |
|
7367 |
if (__isSmallInteger(fd)) { |
|
1135 | 7368 |
int f = __intVal(fd); |
7369 |
||
7370 |
flags = fcntl(f, F_GETFL, 0); |
|
616 | 7371 |
if (aBoolean == true) { |
1135 | 7372 |
ret = fcntl(f, F_SETFL, flags & ~FNDELAY); |
616 | 7373 |
} else { |
1135 | 7374 |
ret = fcntl(f, F_SETFL, flags | FNDELAY); |
185 | 7375 |
} |
616 | 7376 |
if (ret >= 0) ret = flags; |
1135 | 7377 |
RETURN ( __MKSMALLINT(ret) ); |
77 | 7378 |
} |
616 | 7379 |
# endif |
77 | 7380 |
#endif |
308 | 7381 |
%}. |
77 | 7382 |
" |
616 | 7383 |
fd argument not integer |
185 | 7384 |
" |
792 | 7385 |
^ self primitiveFailed |
1 | 7386 |
! |
7387 |
||
616 | 7388 |
writeCheck:fd |
7389 |
"return true, if filedescriptor can be written without blocking" |
|
7390 |
||
7391 |
(self selectOnAnyReadable:nil |
|
7392 |
writable:(Array with:fd) |
|
7393 |
exception:nil |
|
7394 |
withTimeOut:0) == fd |
|
7395 |
ifTrue:[^ true]. |
|
7396 |
^ false |
|
1 | 7397 |
! ! |
434 | 7398 |
|
630 | 7399 |
!OperatingSystem class methodsFor:'documentation'! |
7400 |
||
7401 |
version |
|
1487 | 7402 |
^ '$Header: /cvs/stx/stx/libbasic/Attic/Unix.st,v 1.145 1996-06-25 19:39:33 cg Exp $' |
630 | 7403 |
! ! |
616 | 7404 |
OperatingSystem initialize! |