author | Claus Gittinger <cg@exept.de> |
Fri, 19 Apr 1996 12:47:25 +0200 | |
changeset 1221 | 46d72af387e9 |
parent 1153 | 8119975c55ce |
child 1247 | 2716d915e84e |
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 |
|
253 |
||
254 |
/* # include <windows.h> /* */ |
|
255 |
# include <stdarg.h> /* */ |
|
256 |
# include <windef.h> /* */ |
|
257 |
# include <winbase.h> /* */ |
|
258 |
# include <wingdi.h> /* */ |
|
259 |
# include <winuser.h> /* */ |
|
260 |
||
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
261 |
# 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
|
262 |
# define Array __DEF_Array |
831 | 263 |
# endif |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
264 |
# 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
|
265 |
# define Number __DEF_Number |
831 | 266 |
# endif |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
267 |
# 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
|
268 |
# define Method __DEF_Method |
831 | 269 |
# endif |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
270 |
# 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
|
271 |
# define Point __DEF_Point |
831 | 272 |
# endif |
273 |
# endif |
|
274 |
||
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
275 |
|
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
276 |
# if defined(LINUX) |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
277 |
# define HAS_LOCALECONV |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
278 |
# endif |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
279 |
|
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
280 |
# if defined (HAS_LOCALECONV) |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
281 |
# ifndef _LOCALE_H_INCLUDED_ |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
282 |
# include <locale.h> |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
283 |
# define _LOCALE_H_INCLUDED_ |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
284 |
# endif |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
285 |
# endif |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
286 |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
287 |
/* |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
288 |
* posix systems should define these ... |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
289 |
* but on some (older) systems, they are not. |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
290 |
*/ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
291 |
# ifndef S_IXUSR |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
292 |
# ifdef S_IEXEC |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
293 |
# define S_IXUSR S_IEXEC |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
294 |
# define S_IXGRP (S_IEXEC>>3) |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
295 |
# define S_IXOTH (S_IEXEC>>6) |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
296 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
297 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
298 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
299 |
# ifndef S_IXUSR |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
300 |
# define S_IXUSR 0100 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
301 |
# define S_IXGRP 0010 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
302 |
# define S_IXOTH 0001 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
303 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
304 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
305 |
# ifndef S_IRUSR |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
306 |
# define S_IRUSR 0400 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
307 |
# define S_IRGRP 0040 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
308 |
# define S_IROTH 0004 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
309 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
310 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
311 |
# ifndef S_IWUSR |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
312 |
# define S_IWUSR 0200 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
313 |
# define S_IWGRP 0020 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
314 |
# define S_IWOTH 0002 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
315 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
316 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
317 |
# ifndef MAXPATHLEN |
792 | 318 |
# ifndef MSDOS_LIKE |
319 |
# include <sys/param.h> |
|
320 |
# endif |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
321 |
# ifndef MAXPATHLEN |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
322 |
# ifdef FILENAME_MAX /* i.e. MSDOS_LIKE */ |
792 | 323 |
# define MAXPATHLEN FILENAME_MAX |
324 |
# else |
|
325 |
# define MAXPATHLEN 1024 |
|
326 |
# endif |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
327 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
328 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
329 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
330 |
# if defined(HAS_UNAME) |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
331 |
# include <sys/utsname.h> |
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 |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
334 |
# if defined(SYSV4) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
335 |
# include <stropts.h> |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
336 |
# endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
337 |
|
763
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
338 |
/* |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
339 |
* 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
|
340 |
*/ |
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
341 |
# ifndef SA_RESTART |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
342 |
# 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
|
343 |
# endif |
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
344 |
# ifndef SA_SIGINFO |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
345 |
# 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
|
346 |
# endif |
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
347 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
348 |
# 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
|
349 |
# include <sys/wait.h> |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
350 |
# endif |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
351 |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
352 |
#endif /* ! transputer */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
353 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
354 |
/* |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
355 |
* 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
|
356 |
*/ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
357 |
#ifndef errno |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
358 |
extern errno; |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
359 |
#endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
360 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
361 |
/* |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
362 |
* some (old ?) systems do not define this ... |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
363 |
*/ |
675 | 364 |
#if !defined(R_OK) && !defined(_AIX) |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
365 |
# define R_OK 4 /* Test for Read permission */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
366 |
# define W_OK 2 /* Test for Write permission */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
367 |
# define X_OK 1 /* Test for eXecute permission */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
368 |
# define F_OK 0 /* Test for existence of File */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
369 |
#endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
370 |
|
832 | 371 |
#ifdef WIN32 |
372 |
# define SIGHANDLER_ARG int |
|
373 |
#else |
|
374 |
# define SIGHANDLER_ARG |
|
375 |
#endif |
|
376 |
||
437 | 377 |
%} |
378 |
! ! |
|
379 |
||
380 |
!OperatingSystem primitiveFunctions! |
|
381 |
%{ |
|
382 |
||
383 |
/* |
|
384 |
* some systems' system() is broken in that it does not correctly |
|
385 |
* handle EINTR and returns failure even though it actually succeeded. |
|
386 |
* (LINUX is one of them) |
|
387 |
* Here is a fixed version. If you encounter EINTR returns from |
|
388 |
* OperatingSystem>>executeCommand, you ought to define WANT_SYSTEM |
|
389 |
* in the xxxIntern.h file to get this fixed version. |
|
390 |
* |
|
391 |
* As an added BONUS, this system() enables interrupts while waiting |
|
392 |
* 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
|
393 |
* (i.e. it is RT safe) |
437 | 394 |
*/ |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
395 |
|
433 | 396 |
#if defined(WANT_SYSTEM) |
397 |
||
434 | 398 |
/* # define DPRINTF(x) printf x */ |
399 |
# define DPRINTF(x) /* nothing */ |
|
433 | 400 |
|
437 | 401 |
# ifndef _STDDEF_H_INCLUDED_ |
402 |
# include <stddef.h> |
|
403 |
# define _STDDEF_H_INCLUDED_ |
|
404 |
# endif |
|
405 |
||
406 |
# ifndef _STDLIB_H_INCLUDED_ |
|
407 |
# include <stdlib.h> |
|
408 |
# define _STDLIB_H_INCLUDED_ |
|
409 |
# endif |
|
410 |
||
411 |
# ifndef _UNISTD_H_INCLUDED_ |
|
412 |
# include <unistd.h> |
|
413 |
# define _UNISTD_H_INCLUDED_ |
|
414 |
# endif |
|
415 |
||
416 |
# ifndef _SYS_WAIT_H_INCLUDED |
|
417 |
# include <sys/wait.h> |
|
418 |
# define _SYS_WAIT_H_INCLUDED |
|
419 |
# endif |
|
420 |
||
421 |
# ifndef _SIGNAL_H_INCLUDED_ |
|
422 |
# include <signal.h> |
|
423 |
# define _SIGNAL_H_INCLUDED_ |
|
424 |
# endif |
|
425 |
||
426 |
# ifndef _SYS_TYPES_H_INCLUDED_ |
|
427 |
# include <sys/types.h> |
|
428 |
# define _SYS_TYPES_H_INCLUDED_ |
|
429 |
# endif |
|
433 | 430 |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
431 |
# if (!defined(HAVE_GNU_LD) && !defined (__ELF__)) || !defined(LINUX) |
433 | 432 |
# define __environ environ |
512 | 433 |
# if !defined(LINUX) |
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
434 |
# define __sigemptyset sigemptyset |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
435 |
# define __sigaction sigaction |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
436 |
# define __sigaddset sigaddset |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
437 |
# define __sigprocmask sigprocmask |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
438 |
# define __execve execve |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
439 |
# define __wait wait |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
440 |
# define __waitpid waitpid |
674 | 441 |
# if defined(HAS_VFORK) |
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
442 |
# define FORK vfork |
514
81fa80a953e2
system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents:
513
diff
changeset
|
443 |
# else |
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
444 |
# define FORK fork |
514
81fa80a953e2
system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents:
513
diff
changeset
|
445 |
# endif |
512 | 446 |
# endif /* ! LINUX */ |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
447 |
extern char **environ; |
433 | 448 |
# endif |
449 |
||
450 |
# define SHELL_PATH "/bin/sh" /* Path of the shell. */ |
|
451 |
# define SHELL_NAME "sh" /* Name to give it. */ |
|
452 |
||
453 |
# ifndef FORK |
|
454 |
# define FORK __fork |
|
455 |
# endif |
|
456 |
||
457 |
# ifndef CONST |
|
458 |
# ifdef __GNUC__ |
|
459 |
# define CONST const |
|
460 |
# else |
|
461 |
# define CONST /* nothing */ |
|
462 |
# endif |
|
463 |
# endif |
|
464 |
||
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
465 |
static int |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
466 |
mySystem(line) |
433 | 467 |
register CONST char *line; |
468 |
{ |
|
469 |
int status, save; |
|
470 |
pid_t pid; |
|
471 |
struct sigaction sa, intr, quit; |
|
472 |
sigset_t block, omask; |
|
473 |
||
474 |
if (line == NULL) |
|
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
475 |
return -1; |
433 | 476 |
|
477 |
sa.sa_handler = SIG_IGN; |
|
478 |
sa.sa_flags = 0; |
|
479 |
__sigemptyset (&sa.sa_mask); |
|
480 |
||
481 |
if (__sigaction (SIGINT, &sa, &intr) < 0) { |
|
482 |
DPRINTF(("1: errno=%d\n", errno)); |
|
483 |
return -1; |
|
484 |
} |
|
485 |
if (__sigaction (SIGQUIT, &sa, &quit) < 0) { |
|
486 |
save = errno; |
|
487 |
(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL); |
|
488 |
errno = save; |
|
489 |
DPRINTF(("2: errno=%d\n", errno)); |
|
490 |
return -1; |
|
491 |
} |
|
492 |
||
493 |
__sigemptyset (&block); |
|
494 |
__sigaddset (&block, SIGCHLD); |
|
495 |
save = errno; |
|
496 |
if (__sigprocmask(SIG_BLOCK, &block, &omask) < 0) { |
|
497 |
if (errno == ENOSYS) |
|
498 |
errno = save; |
|
499 |
else { |
|
500 |
save = errno; |
|
501 |
(void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL); |
|
502 |
(void) __sigaction(SIGQUIT, &quit, (struct sigaction *) NULL); |
|
503 |
errno = save; |
|
504 |
DPRINTF(("3: errno=%d\n", errno)); |
|
505 |
return -1; |
|
506 |
} |
|
507 |
} |
|
508 |
||
509 |
pid = FORK (); |
|
510 |
if (pid == (pid_t) 0) { |
|
511 |
/* Child side. */ |
|
512 |
CONST char *new_argv[4]; |
|
513 |
new_argv[0] = SHELL_NAME; |
|
514 |
new_argv[1] = "-c"; |
|
515 |
new_argv[2] = line; |
|
516 |
new_argv[3] = NULL; |
|
517 |
||
518 |
/* Restore the signals. */ |
|
519 |
(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL); |
|
520 |
(void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL); |
|
521 |
(void) __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL); |
|
522 |
||
523 |
/* Exec the shell. */ |
|
524 |
(void) __execve (SHELL_PATH, (char *CONST *) new_argv, __environ); |
|
525 |
_exit (127); |
|
526 |
} else { |
|
527 |
if (pid < (pid_t) 0) { |
|
528 |
/* The fork failed. */ |
|
529 |
DPRINTF(("4: errno=%d\n", errno)); |
|
530 |
status = -1; |
|
531 |
} else { |
|
532 |
/* Parent side. */ |
|
533 |
#ifdef NO_WAITPID |
|
534 |
pid_t child; |
|
535 |
||
536 |
do { |
|
805 | 537 |
__BEGIN_INTERRUPTABLE__ |
433 | 538 |
child = __wait (&status); |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
539 |
__END_INTERRUPTABLE__ |
805 | 540 |
if (child < 0 && errno != EINTR) { |
433 | 541 |
DPRINTF(("5: errno=%d\n", errno)); |
542 |
status = -1; |
|
543 |
break; |
|
544 |
} |
|
545 |
} while (child != pid); |
|
546 |
#else |
|
547 |
pid_t child; |
|
548 |
||
549 |
/* claus: the original did not care for EINTR here ... */ |
|
550 |
do { |
|
805 | 551 |
__BEGIN_INTERRUPTABLE__ |
433 | 552 |
child = __waitpid (pid, &status, 0); |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
553 |
__END_INTERRUPTABLE__ |
433 | 554 |
} while ((child != pid) && (errno == EINTR)); |
555 |
if (child != pid) { |
|
556 |
DPRINTF(("6: errno=%d\n", errno)); |
|
557 |
status = -1; |
|
558 |
} |
|
559 |
#endif /* NO_WAITPID */ |
|
560 |
} |
|
561 |
} |
|
562 |
save = errno; |
|
563 |
if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL) |
|
564 |
| __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL) |
|
565 |
| __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)) != 0) { |
|
566 |
if (errno == ENOSYS) { |
|
567 |
errno = save; |
|
568 |
} else { |
|
569 |
status = -1; |
|
570 |
DPRINTF(("7: errno=%d\n", errno)); |
|
571 |
} |
|
572 |
} |
|
573 |
||
574 |
return status; |
|
575 |
} |
|
576 |
#endif /* WANT_SYSTEM */ |
|
577 |
||
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
578 |
|
433 | 579 |
/* |
580 |
* some systems do not have realpath(); |
|
581 |
* the alternative of reading from a 'pwp'-pipe |
|
582 |
* is way too slow. Here is a realpath for the rest of us. |
|
440 | 583 |
* define WANT_REALPATH in the xxxIntern-file to get it. |
433 | 584 |
*/ |
443 | 585 |
|
440 | 586 |
#if defined(HAS_REALPATH) |
587 |
# undef WANT_REALPATH |
|
588 |
#endif |
|
589 |
#if !defined(HAS_GETWD) && !defined(HAS_GETCWD) |
|
590 |
# undef WANT_REALPATH |
|
591 |
#endif |
|
592 |
||
593 |
#if defined(WANT_REALPATH) |
|
406 | 594 |
|
595 |
# ifndef NULL |
|
596 |
# define NULL (char *)0 |
|
597 |
# endif |
|
598 |
||
439 | 599 |
# define MAX_READLINKS 32 |
600 |
||
601 |
# ifndef MAXPATHLEN |
|
602 |
# define MAXPATHLEN 1024 |
|
603 |
# endif |
|
406 | 604 |
|
605 |
static |
|
606 |
char *realpath(path, resolved_path) |
|
607 |
char *path; |
|
608 |
char resolved_path []; |
|
609 |
{ |
|
610 |
char copy_path[MAXPATHLEN]; |
|
611 |
char link_path[MAXPATHLEN]; |
|
612 |
char *new_path = resolved_path; |
|
613 |
char *max_path; |
|
614 |
int readlinks = 0; |
|
615 |
int n; |
|
616 |
||
617 |
/* Make a copy of the source path since we may need to modify it. */ |
|
618 |
strcpy(copy_path, path); |
|
619 |
path = copy_path; |
|
620 |
max_path = copy_path + MAXPATHLEN - 2; |
|
621 |
/* If it's a relative pathname use getwd for starters. */ |
|
622 |
if (*path != '/') { |
|
623 |
#ifdef HAS_GETCWD |
|
624 |
getcwd(new_path, MAXPATHLEN - 1); |
|
625 |
#else |
|
626 |
getwd(new_path); |
|
627 |
#endif |
|
628 |
new_path += strlen(new_path); |
|
629 |
if (new_path[-1] != '/') |
|
630 |
*new_path++ = '/'; |
|
631 |
} |
|
632 |
else { |
|
633 |
*new_path++ = '/'; |
|
634 |
path++; |
|
635 |
} |
|
636 |
/* Expand each slash-separated pathname component. */ |
|
637 |
while (*path != '\0') { |
|
638 |
/* Ignore stray "/". */ |
|
639 |
if (*path == '/') { |
|
640 |
path++; |
|
641 |
continue; |
|
642 |
} |
|
643 |
if (*path == '.') { |
|
644 |
/* Ignore ".". */ |
|
645 |
if (path[1] == '\0' || path[1] == '/') { |
|
646 |
path++; |
|
647 |
continue; |
|
648 |
} |
|
649 |
if (path[1] == '.') { |
|
650 |
if (path[2] == '\0' || path[2] == '/') { |
|
651 |
path += 2; |
|
652 |
/* Ignore ".." at root. */ |
|
653 |
if (new_path == resolved_path + 1) |
|
654 |
continue; |
|
655 |
/* Handle ".." by backing up. */ |
|
656 |
while ((--new_path)[-1] != '/') |
|
657 |
; |
|
658 |
continue; |
|
659 |
} |
|
660 |
} |
|
661 |
} |
|
662 |
/* Safely copy the next pathname component. */ |
|
663 |
while (*path != '\0' && *path != '/') { |
|
664 |
if (path > max_path) { |
|
665 |
errno = ENAMETOOLONG; |
|
666 |
return NULL; |
|
667 |
} |
|
668 |
*new_path++ = *path++; |
|
669 |
} |
|
670 |
#ifdef S_IFLNK |
|
671 |
/* Protect against infinite loops. */ |
|
672 |
if (readlinks++ > MAX_READLINKS) { |
|
673 |
errno = ELOOP; |
|
674 |
return NULL; |
|
675 |
} |
|
676 |
/* See if latest pathname component is a symlink. */ |
|
677 |
*new_path = '\0'; |
|
678 |
n = readlink(resolved_path, link_path, MAXPATHLEN - 1); |
|
679 |
if (n < 0) { |
|
680 |
/* EINVAL means the file exists but isn't a symlink. */ |
|
681 |
if (errno != EINVAL) |
|
682 |
return NULL; |
|
683 |
} |
|
684 |
else { |
|
685 |
/* Note: readlink doesn't add the null byte. */ |
|
686 |
link_path[n] = '\0'; |
|
687 |
if (*link_path == '/') |
|
688 |
/* Start over for an absolute symlink. */ |
|
689 |
new_path = resolved_path; |
|
690 |
else |
|
691 |
/* Otherwise back up over this component. */ |
|
692 |
while (*(--new_path) != '/') |
|
693 |
; |
|
694 |
/* Safe sex check. */ |
|
695 |
if (strlen(path) + n >= MAXPATHLEN) { |
|
696 |
errno = ENAMETOOLONG; |
|
697 |
return NULL; |
|
698 |
} |
|
699 |
/* Insert symlink contents into path. */ |
|
700 |
strcat(link_path, path); |
|
701 |
strcpy(copy_path, link_path); |
|
702 |
path = copy_path; |
|
703 |
} |
|
704 |
#endif /* S_IFLNK */ |
|
705 |
*new_path++ = '/'; |
|
706 |
} |
|
707 |
/* Delete trailing slash but don't whomp a lone slash. */ |
|
708 |
if (new_path != resolved_path + 1 && new_path[-1] == '/') |
|
709 |
new_path--; |
|
710 |
/* Make sure it's null terminated. */ |
|
711 |
*new_path = '\0'; |
|
712 |
return resolved_path; |
|
713 |
} |
|
714 |
# define HAS_REALPATH |
|
715 |
#endif /* WANT_REALPATH && not HAS_REALPATH */ |
|
716 |
%} |
|
717 |
! ! |
|
718 |
||
2 | 719 |
!OperatingSystem class methodsFor:'documentation'! |
720 |
||
88 | 721 |
copyright |
722 |
" |
|
723 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
185 | 724 |
All Rights Reserved |
88 | 725 |
|
726 |
This software is furnished under a license and may be used |
|
727 |
only in accordance with the terms of that license and with the |
|
728 |
inclusion of the above copyright notice. This software may not |
|
729 |
be provided or otherwise made available to, or used by, any |
|
730 |
other person. No title to or ownership of the software is |
|
731 |
hereby transferred. |
|
732 |
" |
|
733 |
! |
|
734 |
||
2 | 735 |
documentation |
736 |
" |
|
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
737 |
this class realizes access to most (all ?) required operating system services; |
68 | 738 |
some of it is very specific for unix, so do not depend on |
739 |
things available here in your applications - some may not |
|
370 | 740 |
be found in other OS's or be slightly different ... |
68 | 741 |
|
742 |
(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
|
743 |
from you - in some situations it MAY be interesting to be |
792 | 744 |
able to get down to a select or fork system call easily (at least on Unix systems). |
68 | 745 |
You decide - portability vs. functionality) |
746 |
||
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
747 |
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
|
748 |
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
|
749 |
global variable OperatingSystem. |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
750 |
|
68 | 751 |
Class variables: |
752 |
||
185 | 753 |
HostName <String> remembered hostname |
754 |
||
575
4ad726f27891
oops cached HostName was clobbered by a domainName query
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
755 |
DomainName <String> remembered domainname |
4ad726f27891
oops cached HostName was clobbered by a domainName query
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
756 |
|
185 | 757 |
LastErrorNumber <Integer> the last value of errno |
758 |
||
759 |
LastExecStatus <Integer> the returned exec status after |
|
760 |
the last call of system |
|
761 |
||
762 |
OSSignals <Array> Array of signals to be raised for corresponding |
|
763 |
OperatingSystem signals. |
|
308 | 764 |
|
765 |
ForkFailed <Boolean> set if a fork (or popen) has failed; |
|
766 |
ST/X will avoid doing more forks/popens |
|
767 |
if this flag is set, for a slightly |
|
768 |
smoother operation. |
|
769 |
||
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
770 |
SlowFork <Boolean> if set, fork and popen are avoided; |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
771 |
(more or less obsolete now) |
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
772 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
773 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
774 |
ErrorSignal <Signal> Parentsignal of all OS error signals. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
775 |
not directly raised. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
776 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
777 |
AccessDeniedErrorSignal |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
778 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
779 |
FileNotFoundErrorSignal |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
780 |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
781 |
LocaleInfo <Dictionary> if non nil, that is taken instead of the operating |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
782 |
systems locale definitions (allows for overwriting |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
783 |
these, or provide a compatible info on systems which do |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
784 |
not support locales) |
2 | 785 |
" |
786 |
! ! |
|
787 |
||
95 | 788 |
!OperatingSystem class methodsFor:'initialization'! |
789 |
||
790 |
initialize |
|
185 | 791 |
"initialize the class" |
792 |
||
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
793 |
ObjectMemory addDependent:self. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
794 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
795 |
ErrorSignal isNil ifTrue:[ |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
796 |
ErrorSignal := Object errorSignal newSignalMayProceed:true.. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
797 |
ErrorSignal nameClass:self message:#errorSignal. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
798 |
ErrorSignal notifierString:'OS error encountered'. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
799 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
800 |
AccessDeniedErrorSignal := ErrorSignal newSignalMayProceed:true. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
801 |
AccessDeniedErrorSignal nameClass:self message:#accessDeniedError. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
802 |
AccessDeniedErrorSignal notifierString:'OS access denied'. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
803 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
804 |
FileNotFoundErrorSignal := ErrorSignal newSignalMayProceed:true. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
805 |
FileNotFoundErrorSignal nameClass:self message:#fileNotFoundErrorSignal. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
806 |
FileNotFoundErrorSignal notifierString:'OS file not found'. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
807 |
] |
95 | 808 |
! |
809 |
||
810 |
update:something |
|
811 |
something == #earlyRestart ifTrue:[ |
|
185 | 812 |
" |
813 |
flush cached data |
|
814 |
" |
|
815 |
HostName := nil. |
|
575
4ad726f27891
oops cached HostName was clobbered by a domainName query
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
816 |
DomainName := nil. |
185 | 817 |
LastErrorNumber := nil. |
818 |
LastExecStatus := nil |
|
95 | 819 |
] |
820 |
! ! |
|
821 |
||
616 | 822 |
!OperatingSystem class methodsFor:'OS signal constants'! |
823 |
||
824 |
sigABRT |
|
825 |
"return the signal number for SIGABRT - 0 if not supported by OS |
|
826 |
(the numeric value is not the same across unix-systems)" |
|
827 |
||
828 |
%{ /* NOCONTEXT */ |
|
829 |
#ifdef SIGABRT |
|
1135 | 830 |
RETURN ( __MKSMALLINT(SIGABRT) ); |
616 | 831 |
#else |
1135 | 832 |
RETURN ( __MKSMALLINT(0) ); |
616 | 833 |
#endif |
834 |
%} |
|
835 |
! |
|
836 |
||
837 |
sigALRM |
|
838 |
"return the signal number for SIGALRM - 0 if not supported |
|
839 |
(the numeric value is not the same across unix-systems)" |
|
840 |
||
841 |
%{ /* NOCONTEXT */ |
|
842 |
#ifdef SIGALRM |
|
1135 | 843 |
RETURN ( __MKSMALLINT(SIGALRM) ); |
616 | 844 |
#else |
1135 | 845 |
RETURN ( __MKSMALLINT(0) ); |
616 | 846 |
#endif |
847 |
%} |
|
848 |
! |
|
849 |
||
831 | 850 |
sigBREAK |
851 |
"return the signal number for SIGBREAK - 0 if not supported. |
|
852 |
This is an MSDOS specific signal" |
|
853 |
||
854 |
%{ /* NOCONTEXT */ |
|
855 |
#ifdef SIGBREAK |
|
1135 | 856 |
RETURN ( __MKSMALLINT(SIGBREAK) ); |
831 | 857 |
#else |
1135 | 858 |
RETURN ( __MKSMALLINT(0) ); |
831 | 859 |
#endif |
860 |
%} |
|
861 |
! |
|
862 |
||
616 | 863 |
sigBUS |
864 |
"return the signal number for SIGBUS - 0 if not supported |
|
865 |
(the numeric value is not the same across unix-systems)" |
|
866 |
||
867 |
%{ /* NOCONTEXT */ |
|
868 |
#ifdef SIGBUS |
|
1135 | 869 |
RETURN ( __MKSMALLINT(SIGBUS) ); |
616 | 870 |
#else |
1135 | 871 |
RETURN ( __MKSMALLINT(0) ); |
616 | 872 |
#endif |
873 |
%} |
|
874 |
! |
|
875 |
||
876 |
sigCHLD |
|
877 |
"return the signal number for SIGCHLD - 0 if not supported |
|
878 |
(the numeric value is not the same across unix-systems)" |
|
879 |
||
880 |
%{ /* NOCONTEXT */ |
|
881 |
#if defined(SIGCHLD) |
|
1135 | 882 |
RETURN ( __MKSMALLINT(SIGCHLD) ); |
616 | 883 |
#else |
884 |
# if defined(SIGCLD) |
|
1135 | 885 |
RETURN ( __MKSMALLINT(SIGCLD) ); |
616 | 886 |
# else |
1135 | 887 |
RETURN ( __MKSMALLINT(0) ); |
616 | 888 |
# endif |
889 |
#endif |
|
890 |
%} |
|
891 |
! |
|
892 |
||
893 |
sigCONT |
|
894 |
"return the signal number for SIGCONT - 0 if not supported |
|
895 |
(the numeric value is not the same across unix-systems)" |
|
896 |
||
897 |
%{ /* NOCONTEXT */ |
|
898 |
#if defined(SIGCONT) |
|
1135 | 899 |
RETURN ( __MKSMALLINT(SIGCONT) ); |
616 | 900 |
#else |
1135 | 901 |
RETURN ( __MKSMALLINT(0) ); |
616 | 902 |
#endif |
903 |
%} |
|
904 |
! |
|
905 |
||
906 |
sigDANGER |
|
907 |
"return the signal number for SIGDANGER - 0 if not supported |
|
908 |
(seems to be an AIX special)" |
|
909 |
||
910 |
%{ /* NOCONTEXT */ |
|
710 | 911 |
#if defined(SIGDANGER) |
1135 | 912 |
RETURN ( __MKSMALLINT(SIGDANGER) ); |
616 | 913 |
#else |
1135 | 914 |
RETURN ( __MKSMALLINT(0) ); |
616 | 915 |
#endif |
916 |
%} |
|
917 |
! |
|
918 |
||
919 |
sigEMT |
|
920 |
"return the signal number for SIGEMT - 0 if not supported by OS |
|
921 |
(the numeric value is not the same across unix-systems)" |
|
922 |
||
923 |
%{ /* NOCONTEXT */ |
|
924 |
#ifdef SIGEMT |
|
1135 | 925 |
RETURN ( __MKSMALLINT(SIGEMT) ); |
616 | 926 |
#else |
1135 | 927 |
RETURN ( __MKSMALLINT(0) ); |
616 | 928 |
#endif |
929 |
%} |
|
930 |
! |
|
931 |
||
932 |
sigFP |
|
933 |
"return the signal number for SIGFP - 0 if not supported by OS |
|
934 |
(the numeric value is not the same across unix-systems)" |
|
935 |
||
936 |
%{ /* NOCONTEXT */ |
|
937 |
#ifdef SIGFPE |
|
1135 | 938 |
RETURN ( __MKSMALLINT(SIGFPE) ); |
616 | 939 |
#else |
1135 | 940 |
RETURN ( __MKSMALLINT(0) ); |
616 | 941 |
#endif |
942 |
%} |
|
943 |
! |
|
944 |
||
945 |
sigGRANT |
|
946 |
"return the signal number for SIGGRANT - 0 if not supported |
|
947 |
(seems to be an AIX special)" |
|
948 |
||
949 |
%{ /* NOCONTEXT */ |
|
950 |
#if defined(SIGGRANT) |
|
1135 | 951 |
RETURN ( __MKSMALLINT(SIGGRANT) ); |
616 | 952 |
#else |
1135 | 953 |
RETURN ( __MKSMALLINT(0) ); |
616 | 954 |
#endif |
955 |
%} |
|
956 |
! |
|
957 |
||
958 |
sigHUP |
|
959 |
"return the signal number for SIGHUP |
|
960 |
(the numeric value is not the same across unix-systems)" |
|
961 |
||
962 |
%{ /* NOCONTEXT */ |
|
963 |
#ifdef SIGHUP |
|
1135 | 964 |
RETURN ( __MKSMALLINT(SIGHUP) ); |
616 | 965 |
#else |
1135 | 966 |
RETURN ( __MKSMALLINT(0) ); |
616 | 967 |
#endif |
968 |
%} |
|
969 |
! |
|
970 |
||
971 |
sigILL |
|
972 |
"return the signal number for SIGILL - 0 if not supported by OS |
|
973 |
(the numeric value is not the same across unix-systems)" |
|
974 |
||
975 |
%{ /* NOCONTEXT */ |
|
976 |
#ifdef SIGILL |
|
1135 | 977 |
RETURN ( __MKSMALLINT(SIGILL) ); |
616 | 978 |
#else |
1135 | 979 |
RETURN ( __MKSMALLINT(0) ); |
616 | 980 |
#endif |
981 |
%} |
|
982 |
! |
|
983 |
||
984 |
sigINT |
|
985 |
"return the signal number for SIGINT |
|
986 |
(the numeric value is not the same across unix-systems)" |
|
987 |
||
988 |
%{ /* NOCONTEXT */ |
|
989 |
#ifdef SIGINT |
|
1135 | 990 |
RETURN ( __MKSMALLINT(SIGINT) ); |
616 | 991 |
#else |
1135 | 992 |
RETURN ( __MKSMALLINT(0) ); |
616 | 993 |
#endif |
994 |
%} |
|
995 |
! |
|
996 |
||
997 |
sigIO |
|
998 |
"return the signal number for SIGIO - 0 if not supported |
|
999 |
(the numeric value is not the same across unix-systems)" |
|
1000 |
||
1001 |
%{ /* NOCONTEXT */ |
|
1002 |
#if defined(SIGIO) |
|
1135 | 1003 |
RETURN ( __MKSMALLINT(SIGIO) ); |
616 | 1004 |
#else |
1135 | 1005 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1006 |
#endif |
1007 |
%} |
|
1008 |
! |
|
1009 |
||
1010 |
sigIOT |
|
1011 |
"return the signal number for SIGIOT - 0 if not supported by OS |
|
1012 |
(the numeric value is not the same across unix-systems)" |
|
1013 |
||
1014 |
%{ /* NOCONTEXT */ |
|
1015 |
#ifdef SIGIOT |
|
1135 | 1016 |
RETURN ( __MKSMALLINT(SIGIOT) ); |
616 | 1017 |
#else |
1135 | 1018 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1019 |
#endif |
1020 |
%} |
|
1021 |
! |
|
1022 |
||
1023 |
sigKILL |
|
1024 |
"return the signal number for SIGKILL |
|
1025 |
(the numeric value is not the same across unix-systems)" |
|
1026 |
||
1027 |
%{ /* NOCONTEXT */ |
|
1028 |
#ifdef SIGKILL |
|
1135 | 1029 |
RETURN ( __MKSMALLINT(SIGKILL) ); |
616 | 1030 |
#else |
1135 | 1031 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1032 |
#endif |
1033 |
%} |
|
1034 |
! |
|
1035 |
||
1036 |
sigLOST |
|
1037 |
"return the signal number for SIGLOST - 0 if not supported |
|
1038 |
(the numeric value is not the same across unix-systems)" |
|
1039 |
||
1040 |
%{ /* NOCONTEXT */ |
|
1041 |
#if defined(SIGLOST) |
|
1135 | 1042 |
RETURN ( __MKSMALLINT(SIGLOST) ); |
616 | 1043 |
#else |
1135 | 1044 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1045 |
#endif |
1046 |
%} |
|
1047 |
! |
|
1048 |
||
1049 |
sigMIGRATE |
|
1050 |
"return the signal number for SIGMIGRATE - 0 if not supported |
|
1051 |
(seems to be an AIX special)" |
|
1052 |
||
1053 |
%{ /* NOCONTEXT */ |
|
1054 |
#if defined(SIGMIGRATE) |
|
1135 | 1055 |
RETURN ( __MKSMALLINT(SIGMIGRATE) ); |
616 | 1056 |
#else |
1135 | 1057 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1058 |
#endif |
1059 |
%} |
|
1060 |
! |
|
1061 |
||
1062 |
sigMSG |
|
1063 |
"return the signal number for SIGMSG - 0 if not supported |
|
1064 |
(seems to be an AIX special)" |
|
1065 |
||
1066 |
%{ /* NOCONTEXT */ |
|
1067 |
#if defined(SIGMSG) |
|
1135 | 1068 |
RETURN ( __MKSMALLINT(SIGMSG) ); |
616 | 1069 |
#else |
1135 | 1070 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1071 |
#endif |
1072 |
%} |
|
1073 |
! |
|
1074 |
||
1075 |
sigPIPE |
|
1076 |
"return the signal number for SIGPIPE - 0 if not supported |
|
1077 |
(the numeric value is not the same across unix-systems)" |
|
1078 |
||
1079 |
%{ /* NOCONTEXT */ |
|
1080 |
#ifdef SIGPIPE |
|
1135 | 1081 |
RETURN ( __MKSMALLINT(SIGPIPE) ); |
616 | 1082 |
#else |
1135 | 1083 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1084 |
#endif |
1085 |
%} |
|
1086 |
! |
|
1087 |
||
1088 |
sigPOLL |
|
1089 |
"return the signal number for SIGPOLL - 0 if not supported |
|
1090 |
(the numeric value is not the same across unix-systems)" |
|
1091 |
||
1092 |
%{ /* NOCONTEXT */ |
|
1093 |
#if defined(SIGPOLL) |
|
1135 | 1094 |
RETURN ( __MKSMALLINT(SIGPOLL) ); |
616 | 1095 |
#else |
1135 | 1096 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1097 |
#endif |
1098 |
%} |
|
1099 |
! |
|
1100 |
||
1101 |
sigPRE |
|
1102 |
"return the signal number for SIGPRE - 0 if not supported |
|
1103 |
(seems to be an AIX special)" |
|
1104 |
||
1105 |
%{ /* NOCONTEXT */ |
|
1106 |
#if defined(SIGPRE) |
|
1135 | 1107 |
RETURN ( __MKSMALLINT(SIGPRE) ); |
616 | 1108 |
#else |
1135 | 1109 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1110 |
#endif |
1111 |
%} |
|
1112 |
! |
|
1113 |
||
1114 |
sigPROF |
|
1115 |
"return the signal number for SIGPROF - 0 if not supported |
|
1116 |
(the numeric value is not the same across unix-systems)" |
|
1117 |
||
1118 |
%{ /* NOCONTEXT */ |
|
1119 |
#if defined(SIGPROF) |
|
1135 | 1120 |
RETURN ( __MKSMALLINT(SIGPROF) ); |
616 | 1121 |
#else |
1135 | 1122 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1123 |
#endif |
1124 |
%} |
|
1125 |
! |
|
1126 |
||
1127 |
sigPWR |
|
1128 |
"return the signal number for SIGPWR - 0 if not supported |
|
1129 |
(not available on all systems)" |
|
1130 |
||
1131 |
%{ /* NOCONTEXT */ |
|
1132 |
#if defined(SIGPWR) |
|
1135 | 1133 |
RETURN ( __MKSMALLINT(SIGPWR) ); |
616 | 1134 |
#else |
1135 | 1135 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1136 |
#endif |
1137 |
%} |
|
1138 |
! |
|
1139 |
||
1140 |
sigQUIT |
|
1141 |
"return the signal number for SIGQUIT |
|
1142 |
(the numeric value is not the same across unix-systems)" |
|
1143 |
||
1144 |
%{ /* NOCONTEXT */ |
|
1145 |
#ifdef SIGQUIT |
|
1135 | 1146 |
RETURN ( __MKSMALLINT(SIGQUIT) ); |
616 | 1147 |
#else |
1135 | 1148 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1149 |
#endif |
1150 |
%} |
|
1151 |
! |
|
1152 |
||
1153 |
sigRETRACT |
|
1154 |
"return the signal number for SIGRETRACT - 0 if not supported |
|
1155 |
(seems to be an AIX special)" |
|
1156 |
||
1157 |
%{ /* NOCONTEXT */ |
|
1158 |
#if defined(SIGRETRACT) |
|
1135 | 1159 |
RETURN ( __MKSMALLINT(SIGRETRACT) ); |
616 | 1160 |
#else |
1135 | 1161 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1162 |
#endif |
1163 |
%} |
|
1164 |
! |
|
1165 |
||
1166 |
sigSAK |
|
1167 |
"return the signal number for SIGSAK - 0 if not supported |
|
1168 |
(seems to be an AIX special)" |
|
1169 |
||
1170 |
%{ /* NOCONTEXT */ |
|
1171 |
#if defined(SIGSAK) |
|
1135 | 1172 |
RETURN ( __MKSMALLINT(SIGSAK) ); |
616 | 1173 |
#else |
1135 | 1174 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1175 |
#endif |
1176 |
%} |
|
1177 |
! |
|
1178 |
||
1179 |
sigSEGV |
|
1180 |
"return the signal number for SIGSEGV - 0 if not supported |
|
1181 |
(the numeric value is not the same across unix-systems)" |
|
1182 |
||
1183 |
%{ /* NOCONTEXT */ |
|
1184 |
#ifdef SIGSEGV |
|
1135 | 1185 |
RETURN ( __MKSMALLINT(SIGSEGV) ); |
616 | 1186 |
#else |
1135 | 1187 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1188 |
#endif |
1189 |
%} |
|
1190 |
! |
|
1191 |
||
1192 |
sigSOUND |
|
1193 |
"return the signal number for SIGSOUND - 0 if not supported |
|
1194 |
(seems to be an AIX special)" |
|
1195 |
||
1196 |
%{ /* NOCONTEXT */ |
|
1197 |
#if defined(SIGSOUND) |
|
1135 | 1198 |
RETURN ( __MKSMALLINT(SIGSOUND) ); |
616 | 1199 |
#else |
1135 | 1200 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1201 |
#endif |
1202 |
%} |
|
1203 |
! |
|
1204 |
||
1205 |
sigSTOP |
|
1206 |
"return the signal number for SIGSTOP - 0 if not supported |
|
1207 |
(the numeric value is not the same across unix-systems)" |
|
1208 |
||
1209 |
%{ /* NOCONTEXT */ |
|
1210 |
#if defined(SIGSTOP) |
|
1135 | 1211 |
RETURN ( __MKSMALLINT(SIGSTOP) ); |
616 | 1212 |
#else |
1135 | 1213 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1214 |
#endif |
1215 |
%} |
|
1216 |
! |
|
1217 |
||
1218 |
sigSYS |
|
1219 |
"return the signal number for SIGSYS - 0 if not supported |
|
1220 |
(the numeric value is not the same across unix-systems)" |
|
1221 |
||
1222 |
%{ /* NOCONTEXT */ |
|
1223 |
#ifdef SIGSYS |
|
1135 | 1224 |
RETURN ( __MKSMALLINT(SIGSYS) ); |
616 | 1225 |
#else |
1135 | 1226 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1227 |
#endif |
1228 |
%} |
|
1229 |
! |
|
1230 |
||
1231 |
sigTERM |
|
1232 |
"return the signal number for SIGTERM - 0 if not supported |
|
1233 |
(the numeric value is not the same across unix-systems)" |
|
1234 |
||
1235 |
%{ /* NOCONTEXT */ |
|
1236 |
#ifdef SIGTERM |
|
1135 | 1237 |
RETURN ( __MKSMALLINT(SIGTERM) ); |
616 | 1238 |
#else |
1135 | 1239 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1240 |
#endif |
1241 |
%} |
|
1242 |
! |
|
1243 |
||
1244 |
sigTRAP |
|
1245 |
"return the signal number for SIGTRAP - 0 if not supported by OS |
|
1246 |
(the numeric value is not the same across unix-systems)" |
|
1247 |
||
1248 |
%{ /* NOCONTEXT */ |
|
1249 |
#ifdef SIGTRAP |
|
1135 | 1250 |
RETURN ( __MKSMALLINT(SIGTRAP) ); |
616 | 1251 |
#else |
1135 | 1252 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1253 |
#endif |
1254 |
%} |
|
1255 |
! |
|
1256 |
||
1257 |
sigTSTP |
|
1258 |
"return the signal number for SIGTSTP - 0 if not supported |
|
1259 |
(the numeric value is not the same across unix-systems)" |
|
1260 |
||
1261 |
%{ /* NOCONTEXT */ |
|
1262 |
#if defined(SIGTSTP) |
|
1135 | 1263 |
RETURN ( __MKSMALLINT(SIGTSTP) ); |
616 | 1264 |
#else |
1135 | 1265 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1266 |
#endif |
1267 |
%} |
|
1268 |
! |
|
1269 |
||
1270 |
sigTTIN |
|
1271 |
"return the signal number for SIGTTIN - 0 if not supported |
|
1272 |
(the numeric value is not the same across unix-systems)" |
|
1273 |
||
1274 |
%{ /* NOCONTEXT */ |
|
1275 |
#if defined(SIGTTIN) |
|
1135 | 1276 |
RETURN ( __MKSMALLINT(SIGTTIN) ); |
616 | 1277 |
#else |
1135 | 1278 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1279 |
#endif |
1280 |
%} |
|
1281 |
! |
|
1282 |
||
1283 |
sigTTOU |
|
1284 |
"return the signal number for SIGTTOU - 0 if not supported |
|
1285 |
(the numeric value is not the same across unix-systems)" |
|
1286 |
||
1287 |
%{ /* NOCONTEXT */ |
|
1288 |
#if defined(SIGTTOU) |
|
1135 | 1289 |
RETURN ( __MKSMALLINT(SIGTTOU) ); |
616 | 1290 |
#else |
1135 | 1291 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1292 |
#endif |
1293 |
%} |
|
1294 |
! |
|
1295 |
||
1296 |
sigURG |
|
1297 |
"return the signal number for SIGURG - 0 if not supported |
|
1298 |
(the numeric value is not the same across unix-systems)" |
|
1299 |
||
1300 |
%{ /* NOCONTEXT */ |
|
1301 |
#if defined(SIGURG) |
|
1135 | 1302 |
RETURN ( __MKSMALLINT(SIGURG) ); |
616 | 1303 |
#else |
1135 | 1304 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1305 |
#endif |
1306 |
%} |
|
1307 |
! |
|
1308 |
||
1309 |
sigUSR1 |
|
1310 |
"return the signal number for SIGUSR1 - 0 if not supported |
|
1311 |
(the numeric value is not the same across unix-systems)" |
|
1312 |
||
1313 |
%{ /* NOCONTEXT */ |
|
1314 |
#if defined(SIGUSR1) |
|
1135 | 1315 |
RETURN ( __MKSMALLINT(SIGUSR1) ); |
616 | 1316 |
#else |
1135 | 1317 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1318 |
#endif |
1319 |
%} |
|
1320 |
! |
|
1321 |
||
1322 |
sigUSR2 |
|
1323 |
"return the signal number for SIGUSR2 - 0 if not supported |
|
1324 |
(the numeric value is not the same across unix-systems)" |
|
1325 |
||
1326 |
%{ /* NOCONTEXT */ |
|
1327 |
#if defined(SIGUSR2) |
|
1135 | 1328 |
RETURN ( __MKSMALLINT(SIGUSR2) ); |
616 | 1329 |
#else |
1135 | 1330 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1331 |
#endif |
1332 |
%} |
|
1333 |
! |
|
1334 |
||
1335 |
sigVTALRM |
|
1336 |
"return the signal number for SIGVTALRM - 0 if not supported |
|
1337 |
(the numeric value is not the same across unix-systems)" |
|
1338 |
||
1339 |
%{ /* NOCONTEXT */ |
|
1340 |
#if defined(SIGVTALRM) |
|
1135 | 1341 |
RETURN ( __MKSMALLINT(SIGVTALRM) ); |
616 | 1342 |
#else |
1135 | 1343 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1344 |
#endif |
1345 |
%} |
|
1346 |
! |
|
1347 |
||
1348 |
sigWINCH |
|
1349 |
"return the signal number for SIGWINCH - 0 if not supported |
|
1350 |
(the numeric value is not the same across unix-systems)" |
|
1351 |
||
1352 |
%{ /* NOCONTEXT */ |
|
1353 |
#if defined(SIGWINCH) |
|
1135 | 1354 |
RETURN ( __MKSMALLINT(SIGWINCH) ); |
616 | 1355 |
#else |
1135 | 1356 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1357 |
#endif |
1358 |
%} |
|
1359 |
! |
|
1360 |
||
1361 |
sigXCPU |
|
1362 |
"return the signal number for SIGXCPU - 0 if not supported |
|
1363 |
(the numeric value is not the same across unix-systems)" |
|
1364 |
||
1365 |
%{ /* NOCONTEXT */ |
|
1366 |
#if defined(SIGXCPU) |
|
1135 | 1367 |
RETURN ( __MKSMALLINT(SIGXCPU) ); |
616 | 1368 |
#else |
1135 | 1369 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1370 |
#endif |
1371 |
%} |
|
1372 |
! |
|
1373 |
||
1374 |
sigXFSZ |
|
1375 |
"return the signal number for SIGXFSZ - 0 if not supported |
|
1376 |
(the numeric value is not the same across unix-systems)" |
|
1377 |
||
1378 |
%{ /* NOCONTEXT */ |
|
1379 |
#if defined(SIGXFSZ) |
|
1135 | 1380 |
RETURN ( __MKSMALLINT(SIGXFSZ) ); |
616 | 1381 |
#else |
1135 | 1382 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1383 |
#endif |
1384 |
%} |
|
1385 |
! ! |
|
1386 |
||
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1387 |
!OperatingSystem class methodsFor:'Signal constants'! |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1388 |
|
616 | 1389 |
accessDeniedErrorSignal |
1390 |
"return the signal raised when a (file-) access is denied." |
|
1391 |
||
1392 |
^ AccessDeniedErrorSignal |
|
1393 |
! |
|
1394 |
||
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1395 |
errorSignal |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1396 |
"return the OS signals parent signal." |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1397 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1398 |
^ ErrorSignal |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1399 |
! |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1400 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1401 |
fileNotFoundErrorSignal |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1402 |
"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
|
1403 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1404 |
^ FileNotFoundErrorSignal |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1405 |
! ! |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1406 |
|
1 | 1407 |
!OperatingSystem class methodsFor:'error messages'! |
1408 |
||
1153
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1409 |
clearLastErrorNumber |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1410 |
"return the last errors number. |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1411 |
See also: #lastErrorSymbol and #lastErrorString. |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1412 |
Notice: having a single error number is a bad idea in a multithreaded |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1413 |
environment - this interface will change." |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1414 |
|
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1415 |
LastErrorNumber := nil. |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1416 |
|
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1417 |
" |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1418 |
OperatingSystem clearLastErrorNumber |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1419 |
" |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1420 |
|
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1421 |
"Created: 12.4.1996 / 09:28:58 / stefan" |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1422 |
"Modified: 12.4.1996 / 09:38:51 / stefan" |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1423 |
! |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1424 |
|
85 | 1425 |
currentErrorNumber |
68 | 1426 |
"returns the OS's last error nr (i.e. the value of errno). |
1427 |
Notice, that the value of this flag is only valid immediately |
|
1428 |
after the error occurred - it gets updated with every other |
|
85 | 1429 |
request to the OS. |
1430 |
Use lastErrorNumber - currentErrorNumber is invalidated by |
|
1431 |
many, many internal calls." |
|
68 | 1432 |
|
1433 |
%{ /* NOCONTEXT */ |
|
1434 |
||
1135 | 1435 |
RETURN ( __MKSMALLINT(errno) ); |
68 | 1436 |
%} |
1437 |
" |
|
85 | 1438 |
OperatingSystem currentErrorNumber |
1439 |
" |
|
1440 |
! |
|
1441 |
||
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1442 |
errorNumberFor:aSymbol |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1443 |
"given a symbolic error, return the numeric; |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1444 |
(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
|
1445 |
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
|
1446 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1447 |
%{ /* NOCONTEXT */ |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1448 |
OBJ sym = aSymbol; |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1449 |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1450 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1451 |
* POSIX errnos - these should be defined |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1452 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1453 |
#ifdef EPERM |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1454 |
if (sym == @symbol(EPERM)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1455 |
RETURN ( __MKSMALLINT(EPERM) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1456 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1457 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1458 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1459 |
#ifdef ENOENT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1460 |
if (sym == @symbol(ENOENT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1461 |
RETURN ( __MKSMALLINT(ENOENT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1462 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1463 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1464 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1465 |
#ifdef ESRCH |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1466 |
if (sym == @symbol(ESRCH)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1467 |
RETURN ( __MKSMALLINT(ESRCH) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1468 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1469 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1470 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1471 |
#ifdef EINTR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1472 |
if (sym == @symbol(EINTR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1473 |
RETURN ( __MKSMALLINT(EINTR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1474 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1475 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1476 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1477 |
#ifdef EIO |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1478 |
if (sym == @symbol(EIO)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1479 |
RETURN ( __MKSMALLINT(EIO) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1480 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1481 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1482 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1483 |
#ifdef ENXIO |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1484 |
if (sym == @symbol(ENXIO)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1485 |
RETURN ( __MKSMALLINT(ENXIO) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1486 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1487 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1488 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1489 |
#ifdef E2BIG |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1490 |
if (sym == @symbol(E2BIG)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1491 |
RETURN ( __MKSMALLINT(E2BIG) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1492 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1493 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1494 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1495 |
#ifdef ENOEXEC |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1496 |
if (sym == @symbol(ENOEXEC)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1497 |
RETURN ( __MKSMALLINT(ENOEXEC) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1498 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1499 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1500 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1501 |
#ifdef EBADF |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1502 |
if (sym == @symbol(EBADF)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1503 |
RETURN ( __MKSMALLINT(EBADF) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1504 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1505 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1506 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1507 |
#ifdef ECHILD |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1508 |
if (sym == @symbol(ECHILD)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1509 |
RETURN ( __MKSMALLINT(ECHILD) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1510 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1511 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1512 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1513 |
#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
|
1514 |
if (sym == @symbol(EAGAIN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1515 |
RETURN ( __MKSMALLINT(EAGAIN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1516 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1517 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1518 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1519 |
#ifdef ENOMEM |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1520 |
if (sym == @symbol(ENOMEM)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1521 |
RETURN ( __MKSMALLINT(ENOMEM) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1522 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1523 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1524 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1525 |
#ifdef EACCES |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1526 |
if (sym == @symbol(EACCES)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1527 |
RETURN ( __MKSMALLINT(EACCES) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1528 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1529 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1530 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1531 |
#ifdef EFAULT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1532 |
if (sym == @symbol(EFAULT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1533 |
RETURN ( __MKSMALLINT(EFAULT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1534 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1535 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1536 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1537 |
#ifdef EBUSY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1538 |
if (sym == @symbol(EBUSY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1539 |
RETURN ( __MKSMALLINT(EBUSY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1540 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1541 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1542 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1543 |
#ifdef EXDEV |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1544 |
if (sym == @symbol(EXDEV)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1545 |
RETURN ( __MKSMALLINT(EXDEV) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1546 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1547 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1548 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1549 |
#ifdef ENODEV |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1550 |
if (sym == @symbol(ENODEV)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1551 |
RETURN ( __MKSMALLINT(ENODEV) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1552 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1553 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1554 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1555 |
#ifdef ENOTDIR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1556 |
if (sym == @symbol(ENOTDIR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1557 |
RETURN ( __MKSMALLINT(ENOTDIR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1558 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1559 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1560 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1561 |
#ifdef EISDIR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1562 |
if (sym == @symbol(EISDIR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1563 |
RETURN ( __MKSMALLINT(EISDIR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1564 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1565 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1566 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1567 |
#ifdef EINVAL |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1568 |
if (sym == @symbol(EINVAL)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1569 |
RETURN ( __MKSMALLINT(EINVAL) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1570 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1571 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1572 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1573 |
#ifdef ENFILE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1574 |
if (sym == @symbol(ENFILE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1575 |
RETURN ( __MKSMALLINT(ENFILE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1576 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1577 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1578 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1579 |
#ifdef EMFILE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1580 |
if (sym == @symbol(EMFILE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1581 |
RETURN ( __MKSMALLINT(EMFILE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1582 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1583 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1584 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1585 |
#ifdef ENOTTY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1586 |
if (sym == @symbol(ENOTTY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1587 |
RETURN ( __MKSMALLINT(ENOTTY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1588 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1589 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1590 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1591 |
#ifdef EFBIG |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1592 |
if (sym == @symbol(EFBIG)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1593 |
RETURN ( __MKSMALLINT(EFBIG) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1594 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1595 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1596 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1597 |
#ifdef ENOSPC |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1598 |
if (sym == @symbol(ENOSPC)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1599 |
RETURN ( __MKSMALLINT(ENOSPC) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1600 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1601 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1602 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1603 |
#ifdef ESPIPE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1604 |
if (sym == @symbol(ESPIPE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1605 |
RETURN ( __MKSMALLINT(ESPIPE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1606 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1607 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1608 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1609 |
#ifdef EROFS |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1610 |
if (sym == @symbol(EROFS)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1611 |
RETURN ( __MKSMALLINT(EROFS) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1612 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1613 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1614 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1615 |
#ifdef EMLINK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1616 |
if (sym == @symbol(EMLINK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1617 |
RETURN ( __MKSMALLINT(EMLINK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1618 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1619 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1620 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1621 |
#ifdef EPIPE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1622 |
if (sym == @symbol(EPIPE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1623 |
RETURN ( __MKSMALLINT(EPIPE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1624 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1625 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1626 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1627 |
#ifdef EDOM |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1628 |
if (sym == @symbol(EDOM)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1629 |
RETURN ( __MKSMALLINT(EDOM) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1630 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1631 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1632 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1633 |
#ifdef ERANGE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1634 |
if (sym == @symbol(ERANGE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1635 |
RETURN ( __MKSMALLINT(ERANGE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1636 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1637 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1638 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1639 |
#ifdef EDEADLK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1640 |
if (sym == @symbol(EDEADLK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1641 |
RETURN ( __MKSMALLINT(EDEADLK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1642 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1643 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1644 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1645 |
#ifdef ENAMETOOLONG |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1646 |
if (sym == @symbol(ENAMETOOLONG)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1647 |
RETURN ( __MKSMALLINT(ENAMETOOLONG) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1648 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1649 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1650 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1651 |
#ifdef ENOLCK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1652 |
if (sym == @symbol(ENOLCK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1653 |
RETURN ( __MKSMALLINT(ENOLCK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1654 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1655 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1656 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1657 |
#ifdef ENOSYS |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1658 |
if (sym == @symbol(ENOSYS)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1659 |
RETURN ( __MKSMALLINT(ENOSYS) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1660 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1661 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1662 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1663 |
#ifdef ENOTEMPTY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1664 |
if (sym == @symbol(ENOTEMPTY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1665 |
RETURN ( __MKSMALLINT(ENOTEMPTY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1666 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1667 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1668 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1669 |
#ifdef EEXIST |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1670 |
if (sym == @symbol(EEXIST)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1671 |
RETURN ( __MKSMALLINT(EEXIST) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1672 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1673 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1674 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1675 |
#ifdef EILSEQ |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1676 |
if (sym == @symbol(EILSEQ)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1677 |
RETURN ( __MKSMALLINT(EILSEQ) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1678 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1679 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1680 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1681 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1682 |
* XPG3 errnos - defined on most systems |
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 |
#ifdef ENOTBLK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1685 |
if (sym == @symbol(ENOTBLK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1686 |
RETURN ( __MKSMALLINT(ENOTBLK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1687 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1688 |
#endif |
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 |
#ifdef ETXTBSY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1691 |
if (sym == @symbol(ETXTBSY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1692 |
RETURN ( __MKSMALLINT(ETXTBSY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1693 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1694 |
#endif |
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 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1697 |
* some others |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1698 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1699 |
#ifdef EWOULDBLOCK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1700 |
if (sym == @symbol(EWOULDBLOCK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1701 |
RETURN ( __MKSMALLINT(EWOULDBLOCK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1702 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1703 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1704 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1705 |
#ifdef ENOMSG |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1706 |
if (sym == @symbol(ENOMSG)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1707 |
RETURN ( __MKSMALLINT(ENOMSG) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1708 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1709 |
#endif |
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 |
#ifdef ELOOP |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1712 |
if (sym == @symbol(ELOOP)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1713 |
RETURN ( __MKSMALLINT(ELOOP) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1714 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1715 |
#endif |
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 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1718 |
* some stream errors |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1719 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1720 |
#ifdef ETIME |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1721 |
if (sym == @symbol(ETIME)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1722 |
RETURN ( __MKSMALLINT(ETIME) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1723 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1724 |
#endif |
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 |
#ifdef ENOSR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1727 |
if (sym == @symbol(ENOSR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1728 |
RETURN ( __MKSMALLINT(ENOSR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1729 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1730 |
#endif |
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 |
#ifdef ENOSTR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1733 |
if (sym == @symbol(ENOSTR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1734 |
RETURN ( __MKSMALLINT(ENOSTR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1735 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1736 |
#endif |
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 |
#ifdef ECOMM |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1739 |
if (sym == @symbol(ECOMM)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1740 |
RETURN ( __MKSMALLINT(ECOMM) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1741 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1742 |
#endif |
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 |
#ifdef EPROTO |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1745 |
if (sym == @symbol(EPROTO)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1746 |
RETURN ( __MKSMALLINT(EPROTO) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1747 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1748 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1749 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1750 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1751 |
* nfs errors |
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 |
#ifdef ESTALE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1754 |
if (sym == @symbol(ESTALE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1755 |
RETURN ( __MKSMALLINT(ESTALE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1756 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1757 |
#endif |
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 |
#ifdef EREMOTE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1760 |
if (sym == @symbol(EREMOTE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1761 |
RETURN ( __MKSMALLINT(EREMOTE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1762 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1763 |
#endif |
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 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1766 |
* some networking errors |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1767 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1768 |
#ifdef EINPROGRESS |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1769 |
if (sym == @symbol(EINPROGRESS)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1770 |
RETURN ( __MKSMALLINT(EINPROGRESS) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1771 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1772 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1773 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1774 |
#ifdef EALREADY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1775 |
if (sym == @symbol(EALREADY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1776 |
RETURN ( __MKSMALLINT(EALREADY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1777 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1778 |
#endif |
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 |
#ifdef ENOTSOCK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1781 |
if (sym == @symbol(ENOTSOCK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1782 |
RETURN ( __MKSMALLINT(ENOTSOCK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1783 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1784 |
#endif |
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 |
#ifdef EDESTADDRREQ |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1787 |
if (sym == @symbol(EDESTADDRREQ)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1788 |
RETURN ( __MKSMALLINT(EDESTADDRREQ) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1789 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1790 |
#endif |
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 |
#ifdef EMSGSIZE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1793 |
if (sym == @symbol(EMSGSIZE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1794 |
RETURN ( __MKSMALLINT(EMSGSIZE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1795 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1796 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1797 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1798 |
#ifdef EPROTOTYPE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1799 |
if (sym == @symbol(EPROTOTYPE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1800 |
RETURN ( __MKSMALLINT(EPROTOTYPE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1801 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1802 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1803 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1804 |
#ifdef ENOPROTOOPT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1805 |
if (sym == @symbol(ENOPROTOOPT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1806 |
RETURN ( __MKSMALLINT(ENOPROTOOPT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1807 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1808 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1809 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1810 |
#ifdef EPROTONOSUPPORT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1811 |
if (sym == @symbol(EPROTONOSUPPORT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1812 |
RETURN ( __MKSMALLINT(EPROTONOSUPPORT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1813 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1814 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1815 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1816 |
#ifdef ESOCKTNOSUPPORT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1817 |
if (sym == @symbol(ESOCKTNOSUPPORT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1818 |
RETURN ( __MKSMALLINT(ESOCKTNOSUPPORT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1819 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1820 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1821 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1822 |
#ifdef EOPNOTSUPP |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1823 |
if (sym == @symbol(EOPNOTSUPP)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1824 |
RETURN ( __MKSMALLINT(EOPNOTSUPP) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1825 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1826 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1827 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1828 |
#ifdef EPFNOSUPPORT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1829 |
if (sym == @symbol(EPFNOSUPPORT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1830 |
RETURN ( __MKSMALLINT(EPFNOSUPPORT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1831 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1832 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1833 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1834 |
#ifdef EAFNOSUPPORT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1835 |
if (sym == @symbol(EAFNOSUPPORT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1836 |
RETURN ( __MKSMALLINT(EAFNOSUPPORT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1837 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1838 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1839 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1840 |
#ifdef EADDRINUSE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1841 |
if (sym == @symbol(EADDRINUSE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1842 |
RETURN ( __MKSMALLINT(EADDRINUSE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1843 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1844 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1845 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1846 |
#ifdef EADDRNOTAVAIL |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1847 |
if (sym == @symbol(EADDRNOTAVAIL)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1848 |
RETURN ( __MKSMALLINT(EADDRNOTAVAIL) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1849 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1850 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1851 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1852 |
#ifdef ETIMEDOUT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1853 |
if (sym == @symbol(ETIMEDOUT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1854 |
RETURN ( __MKSMALLINT(ETIMEDOUT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1855 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1856 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1857 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1858 |
#ifdef ECONNREFUSED |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1859 |
if (sym == @symbol(ECONNREFUSED)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1860 |
RETURN ( __MKSMALLINT(ECONNREFUSED) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1861 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1862 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1863 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1864 |
#ifdef ENETDOWN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1865 |
if (sym == @symbol(ENETDOWN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1866 |
RETURN ( __MKSMALLINT(ENETDOWN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1867 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1868 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1869 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1870 |
#ifdef ENETUNREACH |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1871 |
if (sym == @symbol(ENETUNREACH)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1872 |
RETURN ( __MKSMALLINT(ENETUNREACH) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1873 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1874 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1875 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1876 |
#ifdef ENETRESET |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1877 |
if (sym == @symbol(ENETRESET)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1878 |
RETURN ( __MKSMALLINT(ENETRESET) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1879 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1880 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1881 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1882 |
#ifdef ECONNABORTED |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1883 |
if (sym == @symbol(ECONNABORTED)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1884 |
RETURN ( __MKSMALLINT(ECONNABORTED) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1885 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1886 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1887 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1888 |
#ifdef ECONNRESET |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1889 |
if (sym == @symbol(ECONNRESET)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1890 |
RETURN ( __MKSMALLINT(ECONNRESET) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1891 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1892 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1893 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1894 |
#ifdef EISCONN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1895 |
if (sym == @symbol(EISCONN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1896 |
RETURN ( __MKSMALLINT(EISCONN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1897 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1898 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1899 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1900 |
#ifdef ENOTCONN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1901 |
if (sym == @symbol(ENOTCONN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1902 |
RETURN ( __MKSMALLINT(ENOTCONN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1903 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1904 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1905 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1906 |
#ifdef ESHUTDOWN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1907 |
if (sym == @symbol(ESHUTDOWN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1908 |
RETURN ( __MKSMALLINT(ESHUTDOWN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1909 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1910 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1911 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1912 |
#ifdef EHOSTDOWN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1913 |
if (sym == @symbol(EHOSTDOWN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1914 |
RETURN ( __MKSMALLINT(EHOSTDOWN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1915 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1916 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1917 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1918 |
#ifdef EHOSTUNREACH |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1919 |
if (sym == @symbol(EHOSTUNREACH)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1920 |
RETURN ( __MKSMALLINT(EHOSTUNREACH) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1921 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1922 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1923 |
%}. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1924 |
^ -1 |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1925 |
! |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1926 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1927 |
errorSymbolAndTextForNumber:errNr |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1928 |
"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
|
1929 |
(as returned by a system call). |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1930 |
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
|
1931 |
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
|
1932 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1933 |
|sym text| |
1 | 1934 |
|
77 | 1935 |
%{ |
1936 |
/* claus: |
|
1937 |
* I made this some primitive code, since errnos are not |
|
1938 |
* standard across unixes |
|
1939 |
*/ |
|
1940 |
char *msg = "unknown error"; |
|
1941 |
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
|
1942 |
OBJ eno = errNr; |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1943 |
|
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1944 |
if (__isSmallInteger(eno)) { |
1135 | 1945 |
switch (__intVal(eno)) { |
185 | 1946 |
/* |
1947 |
* POSIX errnos - these should be defined |
|
1948 |
*/ |
|
443 | 1949 |
#ifdef EPERM |
185 | 1950 |
case EPERM: |
1951 |
msg = "Operation not permitted"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1952 |
sym = @symbol(EPERM); |
185 | 1953 |
break; |
443 | 1954 |
#endif |
1955 |
#ifdef ENOENT |
|
185 | 1956 |
case ENOENT: |
1957 |
msg = "No such file or directory"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1958 |
sym = @symbol(ENOENT); |
185 | 1959 |
break; |
443 | 1960 |
#endif |
1961 |
#ifdef ESRCH |
|
185 | 1962 |
case ESRCH: |
1963 |
msg = "No such process"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1964 |
sym = @symbol(ESRCH); |
185 | 1965 |
break; |
443 | 1966 |
#endif |
1967 |
#ifdef EINTR |
|
185 | 1968 |
case EINTR: |
1969 |
msg = "Interrupted system call"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1970 |
sym = @symbol(EINTR); |
185 | 1971 |
break; |
443 | 1972 |
#endif |
1973 |
#ifdef EIO |
|
185 | 1974 |
case EIO: |
1975 |
msg = "I/O error"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1976 |
sym = @symbol(EIO); |
185 | 1977 |
break; |
443 | 1978 |
#endif |
1979 |
#ifdef ENXIO |
|
185 | 1980 |
case ENXIO: |
1981 |
msg = "No such device or address"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1982 |
sym = @symbol(ENXIO); |
185 | 1983 |
break; |
443 | 1984 |
#endif |
1985 |
#ifdef E2BIG |
|
185 | 1986 |
case E2BIG: |
1987 |
msg = "Arg list too long"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1988 |
sym = @symbol(E2BIG); |
185 | 1989 |
break; |
443 | 1990 |
#endif |
1991 |
#ifdef ENOEXEC |
|
185 | 1992 |
case ENOEXEC: |
1993 |
msg = "Exec format error"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1994 |
sym = @symbol(ENOEXEC); |
185 | 1995 |
break; |
443 | 1996 |
#endif |
1997 |
#ifdef EBADF |
|
185 | 1998 |
case EBADF: |
1999 |
msg = "Bad file number"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2000 |
sym = @symbol(EBADF); |
185 | 2001 |
break; |
443 | 2002 |
#endif |
2003 |
#ifdef ECHILD |
|
185 | 2004 |
case ECHILD: |
2005 |
msg = "No child processes"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2006 |
sym = @symbol(ECHILD); |
185 | 2007 |
break; |
443 | 2008 |
#endif |
77 | 2009 |
#if !defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN) |
185 | 2010 |
case EAGAIN: |
2011 |
msg = "Try again"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2012 |
sym = @symbol(EAGAIN); |
185 | 2013 |
break; |
77 | 2014 |
#endif |
443 | 2015 |
#ifdef ENOMEM |
185 | 2016 |
case ENOMEM: |
2017 |
msg = "Out of memory"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2018 |
sym = @symbol(ENOMEM); |
185 | 2019 |
break; |
443 | 2020 |
#endif |
2021 |
#ifdef EACCES |
|
185 | 2022 |
case EACCES: |
2023 |
msg = "Permission denied"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2024 |
sym = @symbol(EACCES); |
185 | 2025 |
break; |
443 | 2026 |
#endif |
2027 |
#ifdef EFAULT |
|
185 | 2028 |
case EFAULT: |
2029 |
msg = "Bad address"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2030 |
sym = @symbol(EFAULT); |
185 | 2031 |
break; |
443 | 2032 |
#endif |
2033 |
#ifdef EBUSY |
|
185 | 2034 |
case EBUSY: |
2035 |
msg = "Device or resource busy"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2036 |
sym = @symbol(EBUSY); |
185 | 2037 |
break; |
443 | 2038 |
#endif |
2039 |
#ifdef EEXIST |
|
185 | 2040 |
case EEXIST: |
2041 |
msg = "File exists"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2042 |
sym = @symbol(EEXIST); |
185 | 2043 |
break; |
443 | 2044 |
#endif |
2045 |
#ifdef EXDEV |
|
185 | 2046 |
case EXDEV: |
2047 |
msg = "Cross-device link"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2048 |
sym = @symbol(EXDEV); |
185 | 2049 |
break; |
443 | 2050 |
#endif |
2051 |
#ifdef ENODEV |
|
185 | 2052 |
case ENODEV: |
2053 |
msg = "No such device"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2054 |
sym = @symbol(ENODEV); |
185 | 2055 |
break; |
443 | 2056 |
#endif |
2057 |
#ifdef ENOTDIR |
|
185 | 2058 |
case ENOTDIR: |
2059 |
msg = "Not a directory"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2060 |
sym = @symbol(ENOTDIR); |
185 | 2061 |
break; |
443 | 2062 |
#endif |
2063 |
#ifdef EISDIR |
|
185 | 2064 |
case EISDIR: |
2065 |
msg = "Is a directory"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2066 |
sym = @symbol(EISDIR); |
185 | 2067 |
break; |
443 | 2068 |
#endif |
2069 |
#ifdef EINVAL |
|
185 | 2070 |
case EINVAL: |
2071 |
msg = "Invalid argument"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2072 |
sym = @symbol(EINVAL); |
185 | 2073 |
break; |
443 | 2074 |
#endif |
2075 |
#ifdef ENFILE |
|
185 | 2076 |
case ENFILE: |
2077 |
msg = "File table overflow"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2078 |
sym = @symbol(ENFILE); |
185 | 2079 |
break; |
443 | 2080 |
#endif |
2081 |
#ifdef EMFILE |
|
185 | 2082 |
case EMFILE: |
2083 |
msg = "Too many open files"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2084 |
sym = @symbol(EMFILE); |
185 | 2085 |
break; |
443 | 2086 |
#endif |
2087 |
#ifdef ENOTTY |
|
185 | 2088 |
case ENOTTY: |
2089 |
msg = "Not a typewriter"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2090 |
sym = @symbol(ENOTTY); |
185 | 2091 |
break; |
443 | 2092 |
#endif |
2093 |
#ifdef EFBIG |
|
185 | 2094 |
case EFBIG: |
2095 |
msg = "File too large"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2096 |
sym = @symbol(EFBIG); |
185 | 2097 |
break; |
443 | 2098 |
#endif |
2099 |
#ifdef ENOSPC |
|
185 | 2100 |
case ENOSPC: |
2101 |
msg = "No space left on device"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2102 |
sym = @symbol(ENOSPC); |
185 | 2103 |
break; |
443 | 2104 |
#endif |
2105 |
#ifdef ESPIPE |
|
185 | 2106 |
case ESPIPE: |
2107 |
msg = "Illegal seek"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2108 |
sym = @symbol(ESPIPE); |
185 | 2109 |
break; |
443 | 2110 |
#endif |
2111 |
#ifdef EROFS |
|
185 | 2112 |
case EROFS: |
2113 |
msg = "Read-only file system"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2114 |
sym = @symbol(EROFS); |
185 | 2115 |
break; |
443 | 2116 |
#endif |
2117 |
#ifdef EMLINK |
|
185 | 2118 |
case EMLINK: |
2119 |
msg = "Too many links"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2120 |
sym = @symbol(EMLINK); |
185 | 2121 |
break; |
443 | 2122 |
#endif |
2123 |
#ifdef EPIPE |
|
185 | 2124 |
case EPIPE: |
2125 |
msg = "Broken pipe"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2126 |
sym = @symbol(EPIPE); |
185 | 2127 |
break; |
443 | 2128 |
#endif |
2129 |
#ifdef EDOM |
|
185 | 2130 |
case EDOM: |
2131 |
msg = "Math argument out of domain"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2132 |
sym = @symbol(EDOM); |
185 | 2133 |
break; |
443 | 2134 |
#endif |
2135 |
#ifdef ERANGE |
|
185 | 2136 |
case ERANGE: |
2137 |
msg = "Math result not representable"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2138 |
sym = @symbol(ERANGE); |
185 | 2139 |
break; |
443 | 2140 |
#endif |
77 | 2141 |
#ifdef EDEADLK |
308 | 2142 |
# if EDEADLK != EWOULDBLOCK |
185 | 2143 |
case EDEADLK: |
2144 |
msg = "Resource deadlock would occur"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2145 |
sym = @symbol(EDEADLK); |
185 | 2146 |
break; |
308 | 2147 |
# endif |
77 | 2148 |
#endif |
2149 |
#ifdef ENAMETOOLONG |
|
185 | 2150 |
case ENAMETOOLONG: |
2151 |
msg = "File name too long"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2152 |
sym = @symbol(ENAMETOOLONG); |
185 | 2153 |
break; |
77 | 2154 |
#endif |
2155 |
#ifdef ENOLCK |
|
185 | 2156 |
case ENOLCK: |
2157 |
msg = "No record locks available"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2158 |
sym = @symbol(ENOLCK); |
185 | 2159 |
break; |
77 | 2160 |
#endif |
2161 |
#ifdef ENOSYS |
|
185 | 2162 |
case ENOSYS: |
2163 |
msg = "Function not implemented"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2164 |
sym = @symbol(ENOSYS); |
185 | 2165 |
break; |
77 | 2166 |
#endif |
359 | 2167 |
#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST) |
185 | 2168 |
case ENOTEMPTY: |
2169 |
msg = "Directory not empty"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2170 |
sym = @symbol(ENOTEMPTY); |
185 | 2171 |
break; |
77 | 2172 |
#endif |
2173 |
#ifdef EILSEQ |
|
185 | 2174 |
case EILSEQ: |
2175 |
msg = "Illegal byte sequence"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2176 |
sym = @symbol(EILSEQ); |
185 | 2177 |
break; |
77 | 2178 |
#endif |
185 | 2179 |
/* |
2180 |
* XPG3 errnos - defined on most systems |
|
2181 |
*/ |
|
77 | 2182 |
#ifdef ENOTBLK |
185 | 2183 |
case ENOTBLK: |
2184 |
msg = "Block device required"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2185 |
sym = @symbol(ENOTBLK); |
185 | 2186 |
break; |
77 | 2187 |
#endif |
2188 |
#ifdef ETXTBSY |
|
185 | 2189 |
case ETXTBSY: |
2190 |
msg = "Text file busy"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2191 |
sym = @symbol(ETXTBSY); |
185 | 2192 |
break; |
77 | 2193 |
#endif |
185 | 2194 |
/* |
2195 |
* some others |
|
2196 |
*/ |
|
77 | 2197 |
#ifdef EWOULDBLOCK |
185 | 2198 |
case EWOULDBLOCK: |
2199 |
msg = "Operation would block"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2200 |
sym = @symbol(EWOULDBLOCK); |
185 | 2201 |
break; |
77 | 2202 |
#endif |
2203 |
#ifdef ENOMSG |
|
185 | 2204 |
case ENOMSG: |
2205 |
msg = "No message of desired type"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2206 |
sym = @symbol(ENOMSG); |
185 | 2207 |
break; |
77 | 2208 |
#endif |
2209 |
#ifdef ELOOP |
|
185 | 2210 |
case ELOOP: |
2211 |
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
|
2212 |
sym = @symbol(ELOOP); |
185 | 2213 |
break; |
77 | 2214 |
#endif |
2215 |
||
185 | 2216 |
/* |
2217 |
* some stream errors |
|
2218 |
*/ |
|
77 | 2219 |
#ifdef ETIME |
185 | 2220 |
case ETIME: |
2221 |
msg = "Timer expired"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2222 |
sym = @symbol(ETIME); |
185 | 2223 |
break; |
77 | 2224 |
#endif |
2225 |
#ifdef ENOSR |
|
185 | 2226 |
case ENOSR: |
2227 |
msg = "Out of streams resources"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2228 |
sym = @symbol(ENOSR); |
185 | 2229 |
break; |
77 | 2230 |
#endif |
2231 |
#ifdef ENOSTR |
|
185 | 2232 |
case ENOSTR: |
2233 |
msg = "Device not a stream"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2234 |
sym = @symbol(ENOSTR); |
185 | 2235 |
break; |
77 | 2236 |
#endif |
2237 |
#ifdef ECOMM |
|
185 | 2238 |
case ECOMM: |
2239 |
msg = "Communication error on send"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2240 |
sym = @symbol(ECOMM); |
185 | 2241 |
break; |
77 | 2242 |
#endif |
2243 |
#ifdef EPROTO |
|
185 | 2244 |
case EPROTO: |
2245 |
msg = "Protocol error"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2246 |
sym = @symbol(EPROTO); |
185 | 2247 |
break; |
77 | 2248 |
#endif |
185 | 2249 |
/* |
2250 |
* nfs errors |
|
2251 |
*/ |
|
77 | 2252 |
#ifdef ESTALE |
185 | 2253 |
case ESTALE: |
2254 |
msg = "Stale NFS file handle"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2255 |
sym = @symbol(ESTALE); |
185 | 2256 |
break; |
77 | 2257 |
#endif |
2258 |
#ifdef EREMOTE |
|
185 | 2259 |
case EREMOTE: |
2260 |
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
|
2261 |
sym = @symbol(EREMOTE); |
185 | 2262 |
break; |
77 | 2263 |
#endif |
185 | 2264 |
/* |
2265 |
* some networking errors |
|
2266 |
*/ |
|
77 | 2267 |
#ifdef EINPROGRESS |
185 | 2268 |
case EINPROGRESS: |
2269 |
msg = "Operation now in progress"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2270 |
sym = @symbol(EINPROGRESS); |
185 | 2271 |
break; |
77 | 2272 |
#endif |
2273 |
#ifdef EALREADY |
|
185 | 2274 |
case EALREADY: |
2275 |
msg = "Operation already in progress"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2276 |
sym = @symbol(EALREADY); |
185 | 2277 |
break; |
77 | 2278 |
#endif |
2279 |
#ifdef ENOTSOCK |
|
185 | 2280 |
case ENOTSOCK: |
2281 |
msg = "Socket operation on non-socket"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2282 |
sym = @symbol(ENOTSOCK); |
185 | 2283 |
break; |
77 | 2284 |
#endif |
2285 |
#ifdef EDESTADDRREQ |
|
185 | 2286 |
case EDESTADDRREQ: |
2287 |
msg = "Destination address required"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2288 |
sym = @symbol(EDESTADDRREQ); |
185 | 2289 |
break; |
77 | 2290 |
#endif |
2291 |
#ifdef EMSGSIZE |
|
185 | 2292 |
case EMSGSIZE: |
2293 |
msg = "Message too long"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2294 |
sym = @symbol(EMSGSIZE); |
185 | 2295 |
break; |
77 | 2296 |
#endif |
2297 |
#ifdef EPROTOTYPE |
|
185 | 2298 |
case EPROTOTYPE: |
2299 |
msg = "Protocol wrong type for socket"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2300 |
sym = @symbol(EPROTOTYPE); |
185 | 2301 |
break; |
77 | 2302 |
#endif |
2303 |
#ifdef ENOPROTOOPT |
|
185 | 2304 |
case ENOPROTOOPT: |
2305 |
msg = "Protocol not available"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2306 |
sym = @symbol(ENOPROTOOPT); |
185 | 2307 |
break; |
77 | 2308 |
#endif |
2309 |
#ifdef EPROTONOSUPPORT |
|
185 | 2310 |
case EPROTONOSUPPORT: |
2311 |
msg = "Protocol not supported"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2312 |
sym = @symbol(EPROTONOSUPPORT); |
185 | 2313 |
break; |
77 | 2314 |
#endif |
2315 |
#ifdef ESOCKTNOSUPPORT |
|
185 | 2316 |
case ESOCKTNOSUPPORT: |
2317 |
msg = "Socket type not supported"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2318 |
sym = @symbol(ESOCKTNOSUPPORT); |
185 | 2319 |
break; |
77 | 2320 |
#endif |
2321 |
#ifdef EOPNOTSUPP |
|
185 | 2322 |
case EOPNOTSUPP: |
2323 |
msg = "Operation not supported on socket"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2324 |
sym = @symbol(EOPNOTSUPP); |
185 | 2325 |
break; |
77 | 2326 |
#endif |
2327 |
#ifdef EPFNOSUPPORT |
|
185 | 2328 |
case EPFNOSUPPORT: |
2329 |
msg = "Protocol family not supported"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2330 |
sym = @symbol(EPFNOSUPPORT); |
185 | 2331 |
break; |
77 | 2332 |
#endif |
2333 |
#ifdef EAFNOSUPPORT |
|
185 | 2334 |
case EAFNOSUPPORT: |
2335 |
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
|
2336 |
sym = @symbol(EAFNOSUPPORT); |
185 | 2337 |
break; |
77 | 2338 |
#endif |
2339 |
#ifdef EADDRINUSE |
|
185 | 2340 |
case EADDRINUSE: |
2341 |
msg = "Address already in use"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2342 |
sym = @symbol(EADDRINUSE); |
185 | 2343 |
break; |
77 | 2344 |
#endif |
2345 |
#ifdef EADDRNOTAVAIL |
|
185 | 2346 |
case EADDRNOTAVAIL: |
2347 |
msg = "Can\'t assign requested address"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2348 |
sym = @symbol(EADDRNOTAVAIL); |
185 | 2349 |
break; |
77 | 2350 |
#endif |
2351 |
#ifdef ETIMEDOUT |
|
185 | 2352 |
case ETIMEDOUT: |
2353 |
msg = "Connection timed out"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2354 |
sym = @symbol(ETIMEDOUT); |
185 | 2355 |
break; |
77 | 2356 |
#endif |
2357 |
#ifdef ECONNREFUSED |
|
185 | 2358 |
case ECONNREFUSED: |
2359 |
msg = "Connection refused"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2360 |
sym = @symbol(ECONNREFUSED); |
185 | 2361 |
break; |
77 | 2362 |
#endif |
362 | 2363 |
#ifdef ENETDOWN |
2364 |
case ENETDOWN: |
|
2365 |
msg = "Network is down"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2366 |
sym = @symbol(ENETDOWN); |
362 | 2367 |
break; |
2368 |
#endif |
|
2369 |
#ifdef ENETUNREACH |
|
2370 |
case ENETUNREACH: |
|
2371 |
msg = "Network is unreachable"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2372 |
sym = @symbol(ENETUNREACH); |
362 | 2373 |
break; |
2374 |
#endif |
|
2375 |
#ifdef ENETRESET |
|
2376 |
case ENETRESET: |
|
2377 |
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
|
2378 |
sym = @symbol(ENETRESET); |
362 | 2379 |
break; |
2380 |
#endif |
|
2381 |
#ifdef ECONNABORTED |
|
2382 |
case ECONNABORTED: |
|
2383 |
msg = "Software caused connection abort"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2384 |
sym = @symbol(ECONNABORTED); |
362 | 2385 |
break; |
2386 |
#endif |
|
2387 |
#ifdef ECONNRESET |
|
2388 |
case ECONNRESET: |
|
2389 |
msg = "Connection reset by peer"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2390 |
sym = @symbol(ECONNRESET); |
362 | 2391 |
break; |
2392 |
#endif |
|
2393 |
#ifdef EISCONN |
|
2394 |
case EISCONN: |
|
2395 |
msg = "Socket is already connected"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2396 |
sym = @symbol(EISCONN); |
362 | 2397 |
break; |
2398 |
#endif |
|
2399 |
#ifdef ENOTCONN |
|
2400 |
case ENOTCONN: |
|
2401 |
msg = "Socket is not connected"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2402 |
sym = @symbol(ENOTCONN); |
362 | 2403 |
break; |
2404 |
#endif |
|
2405 |
#ifdef ESHUTDOWN |
|
2406 |
case ESHUTDOWN: |
|
2407 |
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
|
2408 |
sym = @symbol(ESHUTDOWN); |
362 | 2409 |
break; |
2410 |
#endif |
|
2411 |
#ifdef EHOSTDOWN |
|
2412 |
case EHOSTDOWN: |
|
2413 |
msg = "Host is down"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2414 |
sym = @symbol(EHOSTDOWN); |
362 | 2415 |
break; |
2416 |
#endif |
|
2417 |
#ifdef EHOSTUNREACH |
|
2418 |
case EHOSTUNREACH: |
|
2419 |
msg = "No route to host"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2420 |
sym = @symbol(EHOSTUNREACH); |
362 | 2421 |
break; |
2422 |
#endif |
|
2423 |
||
185 | 2424 |
default: |
368 | 2425 |
{ |
809
5eef87c2907b
e convenient macro for register saving (sparc only)
Claus Gittinger <cg@exept.de>
parents:
805
diff
changeset
|
2426 |
__BEGIN_PROTECT_REGISTERS__ |
1135 | 2427 |
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
|
2428 |
__END_PROTECT_REGISTERS__ |
368 | 2429 |
} |
185 | 2430 |
msg = buffer; |
2431 |
break; |
|
2432 |
} |
|
77 | 2433 |
} |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2434 |
text = __MKSTRING(msg); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2435 |
%}. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2436 |
^ Array with:sym with:text |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2437 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2438 |
" |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2439 |
OperatingSystem errorSymbolAndTextForNumber:4 |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2440 |
" |
616 | 2441 |
! |
2442 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2443 |
errorSymbolForNumber:errNr |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2444 |
"return a symbol for a unix errorNumber |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2445 |
(as returned by a system call)." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2446 |
|
1153
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
2447 |
^ (self errorSymbolAndTextForNumber:errNr) at:1 |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2448 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2449 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2450 |
OperatingSystem errorTextForNumber:4 |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2451 |
" |
1153
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
2452 |
|
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
2453 |
"Modified: 12.4.1996 / 09:16:29 / stefan" |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2454 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2455 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2456 |
errorTextForNumber:errNr |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2457 |
"return a message string from a unix errorNumber |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2458 |
(as returned by a system call). |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2459 |
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
|
2460 |
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
|
2461 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2462 |
^ (self errorSymbolAndTextForNumber:errNr) at:2 |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2463 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2464 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2465 |
OperatingSystem errorTextForNumber:4 |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2466 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2467 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2468 |
|
616 | 2469 |
lastErrorNumber |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2470 |
"return the last errors number. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2471 |
See also: #lastErrorSymbol and #lastErrorString. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2472 |
Notice: having a single error number is a bad idea in a multithreaded |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2473 |
environment - this interface will change." |
616 | 2474 |
|
2475 |
^ LastErrorNumber |
|
2476 |
||
2477 |
" |
|
2478 |
OperatingSystem lastErrorNumber |
|
2479 |
" |
|
2480 |
! |
|
2481 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2482 |
lastErrorString |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2483 |
"return a message string describing the last error. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2484 |
See also: #lastErrorNumber and #lastErrorSymbol. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2485 |
Notice: having a single error number is a bad idea in a multithreaded |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2486 |
environment - this interface will change." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2487 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2488 |
^ self errorTextForNumber:LastErrorNumber |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2489 |
|
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 |
OperatingSystem lastErrorString |
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 |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2495 |
lastErrorSymbol |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2496 |
"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
|
2497 |
See also: #lastErrorNumber and #lastErrorString. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2498 |
Notice: having a single error number is a bad idea in a multithreaded |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2499 |
environment - this interface will change." |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2500 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2501 |
^ self errorSymbolForNumber:LastErrorNumber |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2502 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2503 |
" |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2504 |
OperatingSystem lastErrorSymbol |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2505 |
" |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2506 |
! |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2507 |
|
616 | 2508 |
lastExecStatus |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2509 |
"return the last execution status. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2510 |
Notice: having a single error number is a bad idea in a multithreaded |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2511 |
environment - this interface will change." |
616 | 2512 |
|
2513 |
^ LastExecStatus |
|
2514 |
||
2515 |
" |
|
2516 |
OperatingSystem lastExecStatus |
|
2517 |
" |
|
1 | 2518 |
! ! |
2519 |
||
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
2520 |
!OperatingSystem class methodsFor:'executing OS commands'! |
616 | 2521 |
|
2522 |
canExecuteCommand:aCommandString |
|
2523 |
"return true, if the OS can execute aCommand." |
|
2524 |
||
2525 |
|cmd| |
|
2526 |
||
2527 |
cmd := aCommandString asCollectionOfWords first. |
|
2528 |
^ (self pathOfCommand:cmd) notNil |
|
2529 |
||
2530 |
" |
|
2531 |
OperatingSystem canExecuteCommand:'fooBar' |
|
2532 |
OperatingSystem canExecuteCommand:'ls' |
|
2533 |
OperatingSystem canExecuteCommand:'cvs' |
|
2534 |
" |
|
2535 |
||
2536 |
"Created: 4.11.1995 / 19:13:54 / cg" |
|
68 | 2537 |
! |
2538 |
||
616 | 2539 |
exec:aPath withArguments:argArray |
2540 |
"execute the unix command specified by the argument, aPath, with |
|
2541 |
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
|
2542 |
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
|
2543 |
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
|
2544 |
to another program." |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2545 |
|
792 | 2546 |
^ 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
|
2547 |
! |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2548 |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2549 |
exec:aPath withArguments:argArray fileDescriptors:fdArray closeDescriptors:closeFdArray fork:doFork |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2550 |
"Internal combined fork & exec; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2551 |
If fork is false: |
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2552 |
execute the unix command specified by the argument, aPath, with |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2553 |
arguments in argArray (no arguments, if nil). |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2554 |
If successful, this method does not return and smalltalk is gone. |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2555 |
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
|
2556 |
if its true: |
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2557 |
for a child to do the above. |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2558 |
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
|
2559 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2560 |
fdArray contains the filedescriptors, to be used for the child (if fork is true). |
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2561 |
fdArray[1] = 15 -> use fd 15 as stdin. |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2562 |
If an element of the array is set to nil, the corresponding filedescriptor |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2563 |
will be closed for the child. |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2564 |
|
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2565 |
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
|
2566 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2567 |
Notice: this used to be two separate ST-methods; however, in order to use |
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2568 |
vfork on some machines, it had to be merged into one, to avoid write |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2569 |
accesses to ST/X memory from the vforked-child. The code below only does |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2570 |
read accesses." |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2571 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2572 |
%{ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2573 |
#ifndef MSDOS_LIKE |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2574 |
char **argv; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2575 |
int nargs, i, id; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2576 |
OBJ arg; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2577 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2578 |
if (__isString(aPath) && |
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2579 |
((argArray == nil) || __isArray(argArray)) && |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2580 |
((fdArray == nil) || __isArray(fdArray)) && |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2581 |
((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
|
2582 |
) { |
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2583 |
nargs = argArray == nil ? 0 : _arraySize(argArray); |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2584 |
argv = (char **) malloc(sizeof(char *) * (nargs + 1)); |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2585 |
if (argv) { |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2586 |
for (i=0; i < nargs; i++) { |
1135 | 2587 |
arg = __ArrayInstPtr(argArray)->a_element[i]; |
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2588 |
if (__isString(arg)) { |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2589 |
argv[i] = (char *) __stringVal(arg); |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2590 |
} else { |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2591 |
argv[i] = ""; |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2592 |
} |
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 |
argv[i] = NULL; |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2595 |
|
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2596 |
if (doFork == true) { |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2597 |
int nfd, nclose; |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2598 |
|
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2599 |
nfd = fdArray == nil ? 0 : _arraySize(fdArray); |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2600 |
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
|
2601 |
#ifdef HAS_VFORK |
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2602 |
id = vfork(); |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2603 |
#else |
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2604 |
id = fork(); |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2605 |
#endif |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2606 |
if (id == 0) { |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2607 |
/* |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2608 |
** In child. |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2609 |
** first: dup filedescriptors |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2610 |
*/ |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2611 |
for (i = 0; i < nfd; i++) { |
1135 | 2612 |
if (__isSmallInteger(__ArrayInstPtr(fdArray)->a_element[i]) && |
2613 |
__intVal(__ArrayInstPtr(fdArray)->a_element[i]) != i |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2614 |
) { |
1135 | 2615 |
dup2(__intVal(__ArrayInstPtr(fdArray)->a_element[i]), i); |
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2616 |
} |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2617 |
} |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2618 |
/* |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2619 |
** second: close unused filedescriptors |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2620 |
*/ |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2621 |
for (i = 0; i < nfd; i++) { |
1135 | 2622 |
if (__ArrayInstPtr(fdArray)->a_element[i] == nil) { |
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2623 |
close(i); |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2624 |
} |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2625 |
} |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2626 |
/* |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2627 |
** third: close filedescriptors |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2628 |
*/ |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2629 |
for (i = 0; i < nclose; i++) { |
1135 | 2630 |
if (__isSmallInteger(__ArrayInstPtr(closeFdArray)->a_element[i])) { |
2631 |
close(__intVal(__ArrayInstPtr(closeFdArray)->a_element[i])); |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2632 |
} |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2633 |
} |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2634 |
|
1135 | 2635 |
execv(__stringVal(aPath), argv); |
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2636 |
/* should not be reached */ |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2637 |
_exit(127); /* POSIX 2 compatible exit value */ |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2638 |
} |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2639 |
/* |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2640 |
** In parent: succes or failure |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2641 |
*/ |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2642 |
free(argv); |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2643 |
RETURN (__MKSMALLINT(id)); |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2644 |
} else { |
1135 | 2645 |
execv(__stringVal(aPath), argv); |
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2646 |
/* |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2647 |
* should not be reached |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2648 |
* (well, it is, if you pass a wrong command-path) |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2649 |
*/ |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2650 |
free(argv); |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2651 |
RETURN ( false ); |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2652 |
} |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2653 |
} |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2654 |
} |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2655 |
#endif |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2656 |
%}. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2657 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2658 |
path-argument not string |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2659 |
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
|
2660 |
or malloc failed |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2661 |
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
|
2662 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2663 |
^ self primitiveFailed |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2664 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2665 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2666 |
|id| |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2667 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2668 |
id := OperatingSystem fork. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2669 |
id == 0 ifTrue:[ |
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2670 |
"I am the child" |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2671 |
OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp'). |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2672 |
"not reached" |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2673 |
] |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2674 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2675 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2676 |
|id| |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2677 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2678 |
id := OperatingSystem fork. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2679 |
id == 0 ifTrue:[ |
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2680 |
"I am the child" |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2681 |
OperatingSystem exec:'/bin/sh' withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2'). |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2682 |
"not reached" |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2683 |
]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2684 |
id printNL. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2685 |
(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
|
2686 |
'killing ...' printNL. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2687 |
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
|
2688 |
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
|
2689 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2690 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2691 |
|
1076
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2692 |
exec:aPath withArguments:argArray fileDescriptors:fdArray fork:doFork |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2693 |
"Internal combined fork & exec; |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2694 |
If fork is false: |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2695 |
execute the unix command specified by the argument, aPath, with |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2696 |
arguments in argArray (no arguments, if nil). |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2697 |
If successful, this method does not return and smalltalk is gone. |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2698 |
If not successful, false is returned. Normal use is with forkForCommand. |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2699 |
if its true: |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2700 |
for a child to do the above. |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2701 |
The id of the child process is returned; -1 if fork failed. |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2702 |
|
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2703 |
fdArray contains the filedescriptors, to be used for the child (if fork is true). |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2704 |
fdArray[1] = 15 -> use fd 15 as stdin. |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2705 |
If an element of the array is set to nil, the corresponding filedescriptor |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2706 |
will be closed for the child. |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2707 |
|
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2708 |
Notice: this used to be two separate ST-methods; however, in order to use |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2709 |
vfork on some machines, it had to be merged into one, to avoid write |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2710 |
accesses to ST/X memory from the vforked-child. The code below only does |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2711 |
read accesses." |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2712 |
|
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2713 |
^ self exec:aPath withArguments:argArray fileDescriptors:fdArray closeDescriptors:nil fork:doFork |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2714 |
! |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2715 |
|
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2716 |
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
|
2717 |
"Internal combined fork & exec; |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2718 |
If fork is false: |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2719 |
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
|
2720 |
arguments in argArray (no arguments, if nil). |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2721 |
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
|
2722 |
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
|
2723 |
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
|
2724 |
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
|
2725 |
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
|
2726 |
|
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2727 |
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
|
2728 |
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
|
2729 |
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
|
2730 |
read accesses." |
616 | 2731 |
|
2732 |
%{ |
|
792 | 2733 |
#ifndef MSDOS_LIKE |
616 | 2734 |
char **argv; |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2735 |
int nargs, i, id; |
616 | 2736 |
OBJ arg; |
2737 |
||
2738 |
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
|
2739 |
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
|
2740 |
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
|
2741 |
if (argv) { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2742 |
for (i=0; i < nargs; i++) { |
1135 | 2743 |
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
|
2744 |
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
|
2745 |
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
|
2746 |
} else { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2747 |
argv[i] = ""; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2748 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2749 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2750 |
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
|
2751 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2752 |
if (doFork == true) { |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2753 |
#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
|
2754 |
id = vfork(); |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2755 |
#else |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2756 |
id = fork(); |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2757 |
#endif |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2758 |
if (id == 0) { |
1135 | 2759 |
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
|
2760 |
/* 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
|
2761 |
_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
|
2762 |
} |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2763 |
free(argv); |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2764 |
RETURN (__MKSMALLINT(id)); |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2765 |
} else { |
1135 | 2766 |
execv(__stringVal(aPath), argv); |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2767 |
/* |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2768 |
* should not be reached |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2769 |
* (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
|
2770 |
*/ |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2771 |
free(argv); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2772 |
RETURN ( false ); |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2773 |
} |
616 | 2774 |
} |
2775 |
} |
|
792 | 2776 |
#endif |
616 | 2777 |
%}. |
2778 |
" |
|
792 | 2779 |
path-argument not string |
2780 |
or argArray not an array/nil |
|
2781 |
or malloc failed |
|
2782 |
or not supported by OS |
|
616 | 2783 |
" |
2784 |
^ self primitiveFailed |
|
2785 |
||
2786 |
" |
|
2787 |
|id| |
|
2788 |
||
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2789 |
id := OperatingSystem fork. |
616 | 2790 |
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
|
2791 |
"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
|
2792 |
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
|
2793 |
"not reached" |
616 | 2794 |
] |
2795 |
" |
|
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2796 |
" |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2797 |
|id| |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2798 |
|
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2799 |
id := OperatingSystem fork. |
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2800 |
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
|
2801 |
"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
|
2802 |
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
|
2803 |
"not reached" |
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2804 |
]. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2805 |
id printNL. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2806 |
(Delay forSeconds:3.5) wait. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2807 |
'killing ...' printNL. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2808 |
OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2809 |
OperatingSystem sendSignal:(OperatingSystem sigKILL) to:id |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2810 |
" |
616 | 2811 |
! |
2812 |
||
2813 |
executeCommand:aCommandString |
|
2814 |
"execute the unix command specified by the argument, aCommandString. |
|
676 | 2815 |
The commandString is passed to a shell for execution - see the description of |
2816 |
'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
|
2817 |
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
|
2818 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2819 |
" 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
|
2820 |
^ 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
|
2821 |
until then:" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2822 |
|
616 | 2823 |
%{ |
2824 |
int status; |
|
2825 |
||
2826 |
if (__isString(aCommandString)) { |
|
2827 |
/* |
|
2828 |
* ST/X provides a modified (fixed) implementation of the |
|
2829 |
* system() libc-function, which is interruptable ... |
|
2830 |
*/ |
|
2831 |
# ifdef WANT_SYSTEM |
|
1135 | 2832 |
status = mySystem((char *) __stringVal(aCommandString)); |
616 | 2833 |
# else |
1135 | 2834 |
status = system((char *) __stringVal(aCommandString)); |
616 | 2835 |
# endif |
1135 | 2836 |
OperatingSystem_LastExecStatus = __MKSMALLINT(status); |
616 | 2837 |
if (status == 0) { |
2838 |
RETURN ( true ); |
|
2839 |
} |
|
1135 | 2840 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 2841 |
RETURN ( false ); |
2842 |
} |
|
2843 |
%}. |
|
792 | 2844 |
"/ |
2845 |
"/ invalid argument (non-string) |
|
2846 |
"/ |
|
2847 |
^ self primitiveFailed |
|
616 | 2848 |
|
2849 |
" |
|
805 | 2850 |
OperatingSystem executeCommand:'sleep 30'. |
616 | 2851 |
OperatingSystem executeCommand:'pwd'. |
2852 |
OperatingSystem executeCommand:'ls -l'. |
|
2853 |
OperatingSystem executeCommand:'invalidCommand'. |
|
2854 |
OperatingSystem executeCommand:'rm /tmp/foofoofoofoo'. |
|
2855 |
" |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2856 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2857 |
"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
|
2858 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2859 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2860 |
executeCommand:aCommandString onError:aBlock |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2861 |
"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
|
2862 |
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
|
2863 |
'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
|
2864 |
Return true if successful. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2865 |
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
|
2866 |
as argument." |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2867 |
|
1034 | 2868 |
|pid exitStatus sema| |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2869 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2870 |
sema := Semaphore new. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2871 |
|
1034 | 2872 |
[ |
2873 |
pid := self startProcess:aCommandString. |
|
2874 |
pid > 0 ifTrue:[ |
|
2875 |
Processor monitorPid:pid action:[ :stat | |
|
2876 |
stat stillAlive ifFalse:[ |
|
2877 |
exitStatus := stat. |
|
2878 |
sema signal |
|
2879 |
]. |
|
2880 |
]. |
|
2881 |
sema wait. |
|
2882 |
] ifFalse:[ |
|
2883 |
exitStatus := OSProcessStatus processCreationFailure. |
|
2884 |
]. |
|
2885 |
] valueUninterruptably. |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2886 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2887 |
exitStatus success ifFalse:[ |
1034 | 2888 |
^ aBlock value:exitStatus |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2889 |
]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2890 |
^ true. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2891 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2892 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2893 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2894 |
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
|
2895 |
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
|
2896 |
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
|
2897 |
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
|
2898 |
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
|
2899 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2900 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2901 |
"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
|
2902 |
"Modified: 28.12.1995 / 15:25:48 / stefan" |
1034 | 2903 |
"Modified: 28.2.1996 / 21:41:23 / cg" |
616 | 2904 |
! |
2905 |
||
2906 |
fork |
|
2907 |
"fork a new (HEAVY-weight) unix process. |
|
2908 |
Dont confuse this with Block>>fork, which creates |
|
2909 |
lightweight smalltalk processes. This method will return |
|
676 | 2910 |
0 to the child process, and a non-zero number (which is the childs |
2911 |
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
|
2912 |
|
676 | 2913 |
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
|
2914 |
#startProcess: and #executCommand: for higher level interfaces." |
68 | 2915 |
|
2916 |
%{ /* NOCONTEXT */ |
|
792 | 2917 |
#ifndef MSDOS_LIKE |
616 | 2918 |
|
2919 |
int pid; |
|
2920 |
||
2921 |
pid = fork(); |
|
1135 | 2922 |
RETURN ( __MKSMALLINT(pid) ); |
792 | 2923 |
#endif |
2924 |
%}. |
|
2925 |
"/ |
|
2926 |
"/ not supported by OS |
|
2927 |
"/ |
|
2928 |
^ self primitiveFailed |
|
2929 |
||
616 | 2930 |
" |
2931 |
|id| |
|
2932 |
||
2933 |
id := OperatingSystem fork. |
|
2934 |
id == 0 ifTrue:[ |
|
2935 |
OperatingSystem exit |
|
2936 |
] |
|
2937 |
" |
|
68 | 2938 |
! |
2939 |
||
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2940 |
getStatusOfProcess:aProcessId |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2941 |
"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
|
2942 |
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
|
2943 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2944 |
%{ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2945 |
#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
|
2946 |
int status; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2947 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2948 |
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
|
2949 |
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
|
2950 |
{ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2951 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2952 |
# 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
|
2953 |
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
|
2954 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2955 |
do { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2956 |
__BEGIN_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2957 |
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
|
2958 |
__END_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2959 |
if (child < 0 && errno != EINTR) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2960 |
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
|
2961 |
status = -1; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2962 |
break; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2963 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2964 |
} 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
|
2965 |
# else |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2966 |
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
|
2967 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2968 |
/* 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
|
2969 |
do { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2970 |
__BEGIN_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2971 |
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
|
2972 |
__END_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2973 |
} 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
|
2974 |
if (child != pid) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2975 |
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
|
2976 |
status = -1; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2977 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2978 |
# 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
|
2979 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2980 |
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
|
2981 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2982 |
#endif |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2983 |
%}. |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2984 |
self primitiveFailed |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2985 |
|
1034 | 2986 |
! |
2987 |
||
2988 |
pathOfCommand:aCommand |
|
2989 |
"find where aCommand's executable file is" |
|
2990 |
||
2991 |
|path f| |
|
2992 |
||
2993 |
path := self getEnvironment:'PATH'. |
|
2994 |
path notNil ifTrue:[ |
|
2995 |
(path asCollectionOfSubstringsSeparatedBy:$:) do:[:path | |
|
2996 |
(f := (path asFilename construct:aCommand)) isExecutable ifTrue:[ |
|
2997 |
^ f pathName |
|
2998 |
] |
|
2999 |
]. |
|
3000 |
]. |
|
3001 |
^ nil |
|
3002 |
||
3003 |
" |
|
3004 |
OperatingSystem pathOfCommand:'fooBar' |
|
3005 |
OperatingSystem pathOfCommand:'ls' |
|
3006 |
OperatingSystem pathOfCommand:'cvs' |
|
3007 |
" |
|
3008 |
! |
|
3009 |
||
3010 |
startProcess:aCommandString |
|
3011 |
"start executing the unix command as specified by the argument, aCommandString |
|
3012 |
as a separate process; do not wait for the command to finish. |
|
3013 |
The commandString is passed to a shell for execution - see the description of |
|
3014 |
'sh -c' in your UNIX manual. |
|
3015 |
Return the processId if successful, nil otherwise. |
|
3016 |
Use #waitForProcess: for synchronization and exec status return, |
|
3017 |
or #killProcess: to stop it." |
|
3018 |
||
3019 |
^ self |
|
3020 |
exec:'/bin/sh' |
|
3021 |
withArguments:(Array with:'sh' with:'-c' with:aCommandString) |
|
3022 |
fork:true. |
|
3023 |
||
3024 |
" |
|
3025 |
|pid| |
|
3026 |
||
3027 |
pid := OperatingSystem startProcess:'sleep 2; echo 1; sleep 2; echo 2'. |
|
3028 |
(Delay forSeconds:3) wait. |
|
3029 |
OperatingSystem killProcess:pid. |
|
3030 |
" |
|
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3031 |
! |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3032 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3033 |
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
|
3034 |
"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
|
3035 |
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
|
3036 |
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
|
3037 |
'sh -c' in your UNIX manual. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3038 |
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
|
3039 |
each may be nil. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3040 |
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
|
3041 |
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
|
3042 |
or #killProcess: to stop it." |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3043 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3044 |
|in out err| |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3045 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3046 |
anExternalInStream notNil ifTrue:[ |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3047 |
in := anExternalInStream fileDescriptor. |
1046 | 3048 |
] ifFalse:[ |
3049 |
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
|
3050 |
]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3051 |
anExternalOutStream notNil ifTrue:[ |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3052 |
out := anExternalOutStream fileDescriptor. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3053 |
]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3054 |
anExternalErrStream notNil ifTrue:[ |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3055 |
err := anExternalErrStream fileDescriptor. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3056 |
]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3057 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3058 |
^ self |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3059 |
exec:'/bin/sh' |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3060 |
withArguments:(Array with:'sh' with:'-c' with:aCommandString) |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3061 |
fileDescriptors:(Array with:in with:out with:err) |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3062 |
fork:true. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3063 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3064 |
"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
|
3065 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3066 |
OperatingSystem executeCommand:'ls -l > out'. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3067 |
" |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3068 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3069 |
"non-blocking (lower prio threads continue): |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3070 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3071 |
|in out err pid sema| |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3072 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3073 |
in := 'out' asFilename readStream. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3074 |
out := 'out2' asFilename writeStream. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3075 |
err := 'err' asFilename writeStream. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3076 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3077 |
sema := Semaphore new. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3078 |
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
|
3079 |
pid notNil ifTrue:[ |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3080 |
Processor monitorPid:pid action:[:OSstatus | sema signal ]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3081 |
]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3082 |
in close. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3083 |
out close. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3084 |
err close. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3085 |
sema wait. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3086 |
Transcript showCr:'finished' |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3087 |
" |
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 |
"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
|
3090 |
"Modified: 29.2.1996 / 12:49:14 / cg" |
616 | 3091 |
! ! |
3092 |
||
3093 |
!OperatingSystem class methodsFor:'file access'! |
|
3094 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3095 |
closeFd:anInteger |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3096 |
"low level close of a filedescriptor" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3097 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3098 |
%{ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3099 |
#if !defined(transputer) && !defined(MSDOS_LIKE) |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3100 |
if (__isSmallInteger(anInteger)) { |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3101 |
close(__intVal(anInteger)); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3102 |
RETURN(self); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3103 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3104 |
#endif |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3105 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3106 |
^ self primitiveFailed. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3107 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3108 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3109 |
createDirectory:newPathName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3110 |
"create a new directory with name 'newPathName'. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3111 |
Return true if successful, false if failed. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3112 |
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
|
3113 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3114 |
"since createDirectory is not used too often, |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3115 |
you'll forgive me using mkdir ..." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3116 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3117 |
^ self executeCommand:('mkdir 2>/dev/null ', newPathName) |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3118 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3119 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3120 |
OperatingSystem createDirectory:'foo' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3121 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3122 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3123 |
"Modified: 20.12.1995 / 11:24:13 / stefan" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3124 |
"Modified: 7.3.1996 / 15:28:19 / cg" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3125 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3126 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3127 |
linkFile:oldPath to:newPath |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3128 |
"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
|
3129 |
Return true if successful, false if not." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3130 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3131 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3132 |
#ifndef MSDOS_LIKE |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3133 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3134 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3135 |
if (__isString(oldPath) && __isString(newPath)) { |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3136 |
__BEGIN_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3137 |
do { |
1135 | 3138 |
ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath)); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3139 |
} while (ret < 0 && errno == EINTR); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3140 |
__END_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3141 |
if (ret < 0) { |
1135 | 3142 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3143 |
RETURN ( false ); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3144 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3145 |
RETURN (true); |
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 |
OperatingSystem linkFile:'foo' to:'bar' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3153 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3154 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3155 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3156 |
makePipe |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3157 |
"make a pipe, return array with two filedescriptors on success, |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3158 |
nil on failure. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3159 |
This is a lowLevel entry, not for public use. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3160 |
See ExternalStream>>makePipe for a more user-friendly, public interface." |
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 |
|fd1 fd2| |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3163 |
|
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 |
int fds[2]; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3166 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3167 |
if (pipe(fds) < 0) { |
1135 | 3168 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3169 |
RETURN ( nil ); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3170 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3171 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3172 |
fd1 = __MKSMALLINT(fds[0]); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3173 |
fd2 = __MKSMALLINT(fds[1]); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3174 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3175 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3176 |
^ Array with:fd1 with:fd2. |
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 |
|
1132 | 3179 |
recursiveCopyDirectory:sourcePathName to:destination |
3180 |
"copy the directory named 'sourcePathName' and all contained files/directories to 'destination'. |
|
3181 |
Return true if successful." |
|
3182 |
||
3183 |
^ self executeCommand:('cp -rf ' , sourcePathName, ' ', destination) |
|
3184 |
||
3185 |
"Modified: 7.3.1996 / 15:26:30 / cg" |
|
3186 |
! |
|
3187 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3188 |
recursiveCreateDirectory:dirName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3189 |
"create a directory - with all parent dirs if needed. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3190 |
Return true if successful, false otherwise. If false |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3191 |
is returned, a partial created tree may be left, |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3192 |
which is not cleaned-up here." |
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 |
self createDirectory:dirName. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3195 |
(self isDirectory:dirName) ifFalse:[ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3196 |
(self recursiveCreateDirectory:(self directoryNameOf:dirName)) ifFalse:[^ false]. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3197 |
^ self createDirectory:dirName |
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 |
^ true |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3200 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3201 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3202 |
OperatingSystem recursiveCreateDirectory:'foo/bar/baz' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3203 |
OperatingSystem recursiveRemoveDirectory:'foo' |
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 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3206 |
"Modified: 7.3.1996 / 15:26:22 / cg" |
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 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3209 |
recursiveRemoveDirectory:fullPathName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3210 |
"remove the directory named 'fullPathName' and all contained files/directories. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3211 |
Return true if successful." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3212 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3213 |
^ self executeCommand:('rm -rf ' , fullPathName) |
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 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3216 |
OperatingSystem recursiveCreateDirectory:'foo/bar/baz' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3217 |
OperatingSystem recursiveRemoveDirectory:'foo' |
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 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3220 |
"Modified: 7.3.1996 / 15:26:30 / cg" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3221 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3222 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3223 |
removeDirectory:fullPathName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3224 |
"remove the directory named 'fullPathName'. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3225 |
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
|
3226 |
This is a lowLevel entry - use Filename protocol for compatibility." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3227 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3228 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3229 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3230 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3231 |
if (__isString(fullPathName)) { |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3232 |
__BEGIN_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3233 |
do { |
1135 | 3234 |
ret = rmdir((char *) __stringVal(fullPathName)); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3235 |
} while (ret < 0 && errno == EINTR); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3236 |
__END_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3237 |
if (ret < 0) { |
1135 | 3238 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3239 |
RETURN ( false ); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3240 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3241 |
RETURN (true); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3242 |
} |
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 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3245 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3246 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3247 |
OperatingSystem createDirectory:'foo' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3248 |
OperatingSystem removeDirectory:'foo' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3249 |
" |
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 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3253 |
removeFile:fullPathName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3254 |
"remove the file named 'fullPathName'; return true if successful. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3255 |
This is a lowLevel entry - use Filename protocol for compatibility." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3256 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3257 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3258 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3259 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3260 |
if (__isString(fullPathName)) { |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3261 |
__BEGIN_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3262 |
do { |
1135 | 3263 |
ret = unlink((char *) __stringVal(fullPathName)); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3264 |
} while (ret < 0 && errno == EINTR); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3265 |
__END_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3266 |
if (ret < 0) { |
1135 | 3267 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3268 |
RETURN ( false ); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3269 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3270 |
RETURN (true); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3271 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3272 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3273 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3274 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3275 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3276 |
renameFile:oldPath to:newPath |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3277 |
"rename the file 'oldPath' to 'newPath'. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3278 |
Return true if successful, false if not" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3279 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3280 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3281 |
int ret, eno; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3282 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3283 |
if (__isString(oldPath) && __isString(newPath)) { |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3284 |
#if defined(HAS_RENAME) |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3285 |
__BEGIN_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3286 |
do { |
1135 | 3287 |
ret = rename((char *) __stringVal(oldPath), (char *) __stringVal(newPath)); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3288 |
} while (ret < 0 && errno == EINTR); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3289 |
__END_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3290 |
#else |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3291 |
# ifndef MSDOS_LIKE |
1135 | 3292 |
ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath)); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3293 |
if (ret >= 0) { |
1135 | 3294 |
ret = unlink((char *) __stringVal(oldPath)); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3295 |
if (ret < 0) { |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3296 |
eno = errno; |
1135 | 3297 |
unlink((char *) __stringVal(newPath)); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3298 |
errno = eno; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3299 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3300 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3301 |
# endif |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3302 |
#endif |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3303 |
if (ret < 0) { |
1135 | 3304 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3305 |
RETURN ( false ); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3306 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3307 |
RETURN (true); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3308 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3309 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3310 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3311 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3312 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3313 |
OperatingSystem renameFile:'foo' to:'bar' |
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 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3317 |
truncateFile:aPathName to:newSize |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3318 |
"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
|
3319 |
This may not be supported on all architectures. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3320 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3321 |
This is a low-level entry - use Filename protocol." |
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 |
#ifdef HAS_FTRUNCATE |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3325 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3326 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3327 |
if (__isString(aPathName) |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3328 |
&& __isSmallInteger(newSize)) { |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3329 |
__BEGIN_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3330 |
do { |
1135 | 3331 |
ret = truncate((char *) __stringVal(aPathName), __intVal(newSize)); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3332 |
} while (ret < 0 && errno == EINTR); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3333 |
__END_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3334 |
if (ret < 0) { |
1135 | 3335 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3336 |
RETURN ( false ); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3337 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3338 |
RETURN (true); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3339 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3340 |
#endif |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3341 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3342 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3343 |
! ! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3344 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3345 |
!OperatingSystem class methodsFor:'file access rights'! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3346 |
|
616 | 3347 |
accessMaskFor:aSymbol |
3348 |
"return the access bits mask for numbers as returned by |
|
3349 |
OperatingSystem>>accessModeOf: |
|
3350 |
and expected by OperatingSystem>>changeAccessModeOf:to:. |
|
3351 |
Since these numbers are OS dependent, always use the mask |
|
3352 |
(never hardcode 8rxxx into your code)." |
|
68 | 3353 |
|
3354 |
%{ /* NOCONTEXT */ |
|
616 | 3355 |
# ifndef S_IRUSR |
3356 |
/* posix systems should define these ... */ |
|
3357 |
# define S_IRUSR 0400 |
|
3358 |
# define S_IWUSR 0200 |
|
3359 |
# define S_IXUSR 0100 |
|
3360 |
# define S_IRGRP 0040 |
|
3361 |
# define S_IWGRP 0020 |
|
3362 |
# define S_IXGRP 0010 |
|
3363 |
# define S_IROTH 0004 |
|
3364 |
# define S_IWOTH 0002 |
|
3365 |
# define S_IXOTH 0001 |
|
3366 |
||
3367 |
# endif |
|
3368 |
||
3369 |
if (aSymbol == @symbol(readUser)) { |
|
1135 | 3370 |
RETURN ( __MKSMALLINT(S_IRUSR) ); |
616 | 3371 |
} |
3372 |
if (aSymbol == @symbol(writeUser)) { |
|
1135 | 3373 |
RETURN ( __MKSMALLINT(S_IWUSR) ); |
616 | 3374 |
} |
3375 |
if (aSymbol == @symbol(executeUser)) { |
|
1135 | 3376 |
RETURN ( __MKSMALLINT(S_IXUSR) ); |
616 | 3377 |
} |
3378 |
if (aSymbol == @symbol(readGroup)) { |
|
1135 | 3379 |
RETURN ( __MKSMALLINT(S_IRGRP) ); |
616 | 3380 |
} |
3381 |
if (aSymbol == @symbol(writeGroup)) { |
|
1135 | 3382 |
RETURN ( __MKSMALLINT(S_IWGRP) ); |
616 | 3383 |
} |
3384 |
if (aSymbol == @symbol(executeGroup)) { |
|
1135 | 3385 |
RETURN ( __MKSMALLINT(S_IXGRP) ); |
616 | 3386 |
} |
3387 |
if (aSymbol == @symbol(readOthers)) { |
|
1135 | 3388 |
RETURN ( __MKSMALLINT(S_IROTH) ); |
616 | 3389 |
} |
3390 |
if (aSymbol == @symbol(writeOthers)) { |
|
1135 | 3391 |
RETURN ( __MKSMALLINT(S_IWOTH) ); |
616 | 3392 |
} |
3393 |
if (aSymbol == @symbol(executeOthers)) { |
|
1135 | 3394 |
RETURN ( __MKSMALLINT(S_IXOTH) ); |
616 | 3395 |
} |
3396 |
%}. |
|
792 | 3397 |
^ self primitiveFailed |
616 | 3398 |
|
3399 |
" |
|
3400 |
OperatingSystem accessMaskFor:#readUser |
|
3401 |
" |
|
68 | 3402 |
! |
3403 |
||
616 | 3404 |
accessModeOf:aPathName |
3405 |
"return a number representing access rights rwxrwxrwx for owner, |
|
3406 |
group and others. Return nil if such a file does not exist. |
|
3407 |
Notice that the returned number is OS dependent - use the |
|
3408 |
modeMasks as returned by OperatingSystem>>accessMaskFor:" |
|
3409 |
||
3410 |
" |
|
3411 |
this could have been implemented as: |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3412 |
(self infoOf:aPathName) at:#mode |
616 | 3413 |
but for huge directory searches the code below is faster |
3414 |
" |
|
345 | 3415 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3416 |
%{ |
616 | 3417 |
struct stat buf; |
3418 |
int ret; |
|
3419 |
||
3420 |
if (__isString(aPathName)) { |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3421 |
__BEGIN_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3422 |
do { |
1135 | 3423 |
ret = stat((char *) __stringVal(aPathName), &buf); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3424 |
} while ((ret < 0) && (errno == EINTR)); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3425 |
__END_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3426 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3427 |
if (ret < 0) { |
1135 | 3428 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3429 |
RETURN ( nil ); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3430 |
} |
1135 | 3431 |
RETURN ( __MKSMALLINT(buf.st_mode & 0777) ); |
616 | 3432 |
} |
3433 |
%}. |
|
792 | 3434 |
^ self primitiveFailed |
616 | 3435 |
|
3436 |
" |
|
3437 |
(OperatingSystem accessModeOf:'/') printStringRadix:8 |
|
3438 |
" |
|
345 | 3439 |
! |
3440 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3441 |
changeAccessModeOf:aPathName to:modeBits |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3442 |
"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
|
3443 |
You should construct this mask using accessMaskFor, to be OS |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3444 |
independent. Return true if changed, |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3445 |
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
|
3446 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3447 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3448 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3449 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3450 |
if (__isString(aPathName) && __isSmallInteger(modeBits)) { |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3451 |
__BEGIN_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3452 |
do { |
1135 | 3453 |
ret = chmod((char *)__stringVal(aPathName), __intVal(modeBits)); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3454 |
} while (ret < 0 && errno == EINTR); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3455 |
__END_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3456 |
if (ret < 0) { |
1135 | 3457 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3458 |
RETURN ( false ); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3459 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3460 |
RETURN ( true ); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3461 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3462 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3463 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3464 |
! ! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3465 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3466 |
!OperatingSystem class methodsFor:'file queries'! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3467 |
|
616 | 3468 |
baseNameOf:aPathString |
3469 |
"return the baseName of the argument, aPathString |
|
3470 |
- thats the file/directory name without leading parent-dirs |
|
3471 |
(i.e. OperatingSystem baseNameOf:'/usr/lib/st/file' -> 'file' |
|
3472 |
and OperatingSystem baseNameOf:'/usr/lib' -> lib). |
|
3473 |
This method does not check if the path is valid |
|
3474 |
(i.e. if these directories really exist & is readable)." |
|
3475 |
||
3476 |
|prev index sep| |
|
3477 |
||
3478 |
sep := self fileSeparator. |
|
3479 |
((aPathString size == 1) and:[(aPathString at:1) == sep]) ifTrue:[ |
|
3480 |
^ aPathString |
|
3481 |
]. |
|
3482 |
prev := 1. |
|
3483 |
[true] whileTrue:[ |
|
3484 |
index := aPathString indexOf:sep startingAt:prev. |
|
3485 |
index == 0 ifTrue:[ |
|
3486 |
^ aPathString copyFrom:prev |
|
3487 |
]. |
|
3488 |
prev := index + 1 |
|
3489 |
] |
|
3490 |
||
3491 |
" |
|
3492 |
OperatingSystem baseNameOf:'/fee/foo/bar' |
|
3493 |
OperatingSystem baseNameOf:'foo/bar' |
|
3494 |
OperatingSystem baseNameOf:'../../foo/bar' |
|
3495 |
OperatingSystem baseNameOf:'hello' |
|
3496 |
" |
|
3497 |
! |
|
3498 |
||
3499 |
caseSensitiveFilenames |
|
3500 |
"return true, if the OS has caseSensitive file naming. |
|
3501 |
On MSDOS, this will return false. Since this is for Unix, we |
|
3502 |
return true." |
|
3503 |
||
3504 |
^ true |
|
3505 |
! |
|
3506 |
||
3507 |
compressPath:pathName |
|
3508 |
"return the pathName compressed - that is, remove all ..-entries |
|
3509 |
and . entries. This does not always (in case of symbolic links) |
|
3510 |
return the true pathName and is therefore used as a fallback |
|
3511 |
if realPath and popen failed." |
|
3512 |
||
3513 |
|names| |
|
3514 |
||
3515 |
names := pathName |
|
3516 |
asCollectionOfSubstringsSeparatedBy:self fileSeparator. |
|
3517 |
names := names asOrderedCollection. |
|
3518 |
" |
|
3519 |
cut off initial double-slashes |
|
3520 |
" |
|
3521 |
[names startsWith:#('' '')] whileTrue:[ |
|
3522 |
names removeFirst. |
|
3523 |
]. |
|
3524 |
" |
|
3525 |
cut off double-slashes at end |
|
3526 |
" |
|
3527 |
[names endsWith:#('')] whileTrue:[ |
|
3528 |
names removeLast. |
|
3529 |
]. |
|
3530 |
" |
|
3531 |
cut off current-dir at beginning |
|
3532 |
" |
|
3533 |
[(names size >= 2) and:[names startsWith:#('.')]] whileTrue:[ |
|
3534 |
names removeFirst. |
|
3535 |
]. |
|
3536 |
||
3537 |
" |
|
3538 |
cut off parent-dirs at end |
|
3539 |
" |
|
3540 |
[(names size > 2) |
|
3541 |
and:[(names endsWith:#('..')) |
|
3542 |
and:[((names at:(names size - 1)) startsWith:'.') not ]]] whileTrue:[ |
|
3543 |
names removeLast; removeLast |
|
3544 |
]. |
|
3545 |
||
3546 |
^ names asStringWith:self fileSeparator |
|
3547 |
from:1 |
|
3548 |
to:names size |
|
3549 |
compressTabs:false final:nil |
|
3550 |
||
3551 |
" |
|
3552 |
OperatingSystem compressPath:'./..' |
|
3553 |
OperatingSystem compressPath:'/foo/bar/baz/..' |
|
3554 |
OperatingSystem compressPath:'foo/bar/baz/..' |
|
3555 |
OperatingSystem compressPath:'foo/bar/baz/../' |
|
3556 |
OperatingSystem compressPath:'foo/bar/baz/..///' |
|
3557 |
OperatingSystem compressPath:'///foo/bar/baz/..///' |
|
3558 |
" |
|
68 | 3559 |
! |
3560 |
||
616 | 3561 |
directoryNameOf:aPathString |
3562 |
"return the directoryName of the argument, aPath |
|
3563 |
- thats the name of the directory where aPath is |
|
3564 |
(i.e. OperatingSystem directoryNameOf:'/usr/lib/st/file' -> '/usr/lib/st' |
|
3565 |
and OperatingSystem directoryNameOf:'/usr/lib' -> /usr'). |
|
3566 |
This method does not check if the path is valid |
|
3567 |
(i.e. if these directories really exist & are readable)." |
|
3568 |
||
3569 |
|last index sep sepString| |
|
3570 |
||
3571 |
sep := self fileSeparator. |
|
3572 |
sepString := sep asString. |
|
3573 |
(aPathString = sepString) ifTrue:[ |
|
3574 |
" |
|
3575 |
the trivial '/' case |
|
3576 |
" |
|
3577 |
^ aPathString |
|
3578 |
]. |
|
3579 |
(aPathString startsWith:sepString) ifFalse:[ |
|
3580 |
(aPathString endsWith:sepString) ifTrue:[ |
|
3581 |
^ aPathString copyTo:(aPathString size - 1) |
|
3582 |
]. |
|
3583 |
]. |
|
3584 |
last := 1. |
|
3585 |
[true] whileTrue:[ |
|
3586 |
index := aPathString indexOf:sep startingAt:(last + 1). |
|
3587 |
index == 0 ifTrue:[ |
|
3588 |
(last == 1) ifTrue:[ |
|
3589 |
(aPathString startsWith:sepString) ifTrue:[ |
|
3590 |
^ sepString |
|
3591 |
]. |
|
3592 |
^ '.' |
|
3593 |
]. |
|
3594 |
" |
|
3595 |
(aPathString startsWith:sepString) ifFalse:[ |
|
3596 |
(aPathString startsWith:('..' , sepString)) ifFalse:[ |
|
3597 |
^ './' , (aPathString copyTo:(last - 1)) |
|
3598 |
] |
|
3599 |
]. |
|
3600 |
" |
|
3601 |
^ aPathString copyTo:(last - 1) |
|
3602 |
]. |
|
3603 |
last := index. |
|
3604 |
] |
|
3605 |
||
3606 |
" |
|
3607 |
OperatingSystem directoryNameOf:'/fee/foo/bar' |
|
3608 |
OperatingSystem directoryNameOf:'foo/bar' |
|
3609 |
OperatingSystem directoryNameOf:'../../foo/bar' |
|
3610 |
OperatingSystem directoryNameOf:'bar' |
|
3611 |
OperatingSystem directoryNameOf:'/bar' |
|
3612 |
" |
|
3613 |
! |
|
3614 |
||
3615 |
fileSeparator |
|
3616 |
"return the character used to separate names in a path. |
|
3617 |
This character differs for MSDOS and other systems, |
|
3618 |
(but those are currently not supported - so this is some |
|
3619 |
preparation for the future)" |
|
3620 |
||
3621 |
^ $/ |
|
3622 |
! |
|
3623 |
||
3624 |
idOf:aPathName |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3625 |
"return the fileNumber (i.e. inode number) of a file. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3626 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3627 |
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
|
3628 |
some dummy id will be returned. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3629 |
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
|
3630 |
physically identical, even if found in different directories |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3631 |
(i.e. if they are hardLinked)." |
616 | 3632 |
|
3633 |
" |
|
3634 |
this could have been implemented as: |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3635 |
(self infoOf:aPathName) at:#id |
616 | 3636 |
but for huge directory searches the code below is faster |
3637 |
" |
|
68 | 3638 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3639 |
%{ |
616 | 3640 |
struct stat buf; |
3641 |
int ret; |
|
3642 |
||
3643 |
if (__isString(aPathName)) { |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3644 |
__BEGIN_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3645 |
do { |
1135 | 3646 |
ret = stat((char *) __stringVal(aPathName), &buf); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3647 |
} while (ret < 0 && errno == EINTR); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3648 |
__END_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3649 |
if (ret >= 0) { |
1135 | 3650 |
RETURN (__MKSMALLINT(buf.st_ino)); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3651 |
} |
1135 | 3652 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3653 |
RETURN (nil); |
616 | 3654 |
} |
68 | 3655 |
%} |
616 | 3656 |
. |
792 | 3657 |
^ self primitiveFailed |
616 | 3658 |
|
3659 |
"OperatingSystem idOf:'/'" |
|
68 | 3660 |
! |
3661 |
||
616 | 3662 |
infoOf:aPathName |
3663 |
"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
|
3664 |
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
|
3665 |
Return nil if such a file does not exist. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3666 |
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
|
3667 |
use #linkInfoOf: to get info about the link itself. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3668 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3669 |
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
|
3670 |
future without affecting existing applications." |
616 | 3671 |
|
3672 |
|info type mode uid gid size id |
|
3673 |
atimeLow atimeHi mtimeLow mtimeHi ctimeLow ctimeHi| |
|
3674 |
||
3675 |
%{ |
|
3676 |
struct stat buf; |
|
3677 |
int ret; |
|
3678 |
||
3679 |
if (__isString(aPathName)) { |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3680 |
__BEGIN_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3681 |
do { |
1135 | 3682 |
ret = stat((char *) __stringVal(aPathName), &buf); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3683 |
} while ((ret < 0) && (errno == EINTR)); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3684 |
__END_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3685 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3686 |
if (ret < 0) { |
1135 | 3687 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3688 |
RETURN ( nil ); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3689 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3690 |
switch (buf.st_mode & S_IFMT) { |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3691 |
case S_IFDIR: |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3692 |
type = @symbol(directory); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3693 |
break; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3694 |
case S_IFREG: |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3695 |
type = @symbol(regular); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3696 |
break; |
616 | 3697 |
#ifdef S_IFCHR |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3698 |
case S_IFCHR: |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3699 |
type = @symbol(characterSpecial); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3700 |
break; |
616 | 3701 |
#endif |
3702 |
#ifdef S_IFBLK |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3703 |
case S_IFBLK: |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3704 |
type = @symbol(blockSpecial); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3705 |
break; |
616 | 3706 |
#endif |
3707 |
#ifdef S_IFLNK |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3708 |
case S_IFLNK: |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3709 |
type = @symbol(symbolicLink); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3710 |
break; |
616 | 3711 |
#endif |
3712 |
#ifdef S_IFSOCK |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3713 |
case S_IFSOCK: |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3714 |
type = @symbol(socket); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3715 |
break; |
616 | 3716 |
#endif |
3717 |
#ifdef S_IFIFO |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3718 |
case S_IFIFO: |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3719 |
type = @symbol(fifo); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3720 |
break; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3721 |
#endif |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3722 |
default: |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3723 |
type = @symbol(unknown); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3724 |
break; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3725 |
} |
1135 | 3726 |
mode = __MKSMALLINT(buf.st_mode & 0777); |
3727 |
uid = __MKSMALLINT(buf.st_uid); |
|
3728 |
gid = __MKSMALLINT(buf.st_gid); |
|
3729 |
size = __MKSMALLINT(buf.st_size); |
|
3730 |
id = __MKSMALLINT(buf.st_ino); |
|
3731 |
atimeLow = __MKSMALLINT(buf.st_atime & 0xFFFF); |
|
3732 |
atimeHi = __MKSMALLINT((buf.st_atime >> 16) & 0xFFFF); |
|
3733 |
mtimeLow = __MKSMALLINT(buf.st_mtime & 0xFFFF); |
|
3734 |
mtimeHi = __MKSMALLINT((buf.st_mtime >> 16) & 0xFFFF); |
|
3735 |
ctimeLow = __MKSMALLINT(buf.st_ctime & 0xFFFF); |
|
3736 |
ctimeHi = __MKSMALLINT((buf.st_ctime >> 16) & 0xFFFF); |
|
616 | 3737 |
} |
3738 |
%}. |
|
3739 |
mode notNil ifTrue:[ |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3740 |
info := IdentityDictionary new. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3741 |
info at:#type put:type. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3742 |
info at:#mode put:mode. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3743 |
info at:#uid put:uid. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3744 |
info at:#gid put:gid. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3745 |
info at:#size put:size. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3746 |
info at:#id put:id. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3747 |
info at:#accessed put:(AbsoluteTime fromOSTimeLow:atimeLow and:atimeHi). |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3748 |
info at:#modified put:(AbsoluteTime fromOSTimeLow:mtimeLow and:mtimeHi). |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3749 |
info at:#statusChanged put:(AbsoluteTime fromOSTimeLow:ctimeLow and:ctimeHi). |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3750 |
^ info |
616 | 3751 |
]. |
792 | 3752 |
^ self primitiveFailed |
616 | 3753 |
|
3754 |
" |
|
3755 |
OperatingSystem infoOf:'/' |
|
3756 |
(OperatingSystem infoOf:'/') at:#uid |
|
3757 |
(OperatingSystem infoOf:'/') at:#accessed |
|
3758 |
" |
|
68 | 3759 |
! |
3760 |
||
616 | 3761 |
isDirectory:aPathName |
3762 |
"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
|
3763 |
(i.e. exists and is a directory). |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3764 |
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
|
3765 |
if you need to check for this, use #linkInfo:." |
68 | 3766 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3767 |
%{ |
616 | 3768 |
struct stat buf; |
3769 |
int ret; |
|
3770 |
||
3771 |
if (__isString(aPathName)) { |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3772 |
__BEGIN_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3773 |
do { |
1135 | 3774 |
ret = stat((char *) __stringVal(aPathName), &buf); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3775 |
} while ((ret < 0) && (errno == EINTR)); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3776 |
__END_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3777 |
if (ret < 0) { |
1135 | 3778 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3779 |
RETURN ( false ); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3780 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3781 |
RETURN ( ((buf.st_mode & S_IFMT) == S_IFDIR) ? true : false); |
616 | 3782 |
} |
3783 |
%}. |
|
792 | 3784 |
^ self primitiveFailed |
616 | 3785 |
|
3786 |
"an alternative implementation would be: |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3787 |
^ (self infoOf:aPathName) at:#type == #directory |
616 | 3788 |
" |
68 | 3789 |
! |
3790 |
||
616 | 3791 |
isExecutable:aPathName |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3792 |
"return true, if the given file is executable. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3793 |
For symbolic links, the pointed-to-file is checked." |
68 | 3794 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3795 |
%{ |
616 | 3796 |
int ret; |
3797 |
||
3798 |
if (__isString(aPathName)) { |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3799 |
__BEGIN_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3800 |
do { |
1135 | 3801 |
ret = access(__stringVal(aPathName), X_OK); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3802 |
} while ((ret < 0) && (errno == EINTR)); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3803 |
__END_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3804 |
if (ret < 0) { |
1135 | 3805 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3806 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3807 |
RETURN ( ((ret == 0) ? true : false) ); |
616 | 3808 |
} |
3809 |
%}. |
|
792 | 3810 |
^ self primitiveFailed |
68 | 3811 |
! |
3812 |
||
616 | 3813 |
isReadable:aPathName |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3814 |
"return true, if the file/dir 'aPathName' is readable. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3815 |
For symbolic links, the pointed-to-file is checked." |
68 | 3816 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3817 |
%{ |
616 | 3818 |
int ret; |
3819 |
||
3820 |
if (__isString(aPathName)) { |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3821 |
__BEGIN_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3822 |
do { |
1135 | 3823 |
ret = access(__stringVal(aPathName), R_OK); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3824 |
} while ((ret < 0) && (errno == EINTR)); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3825 |
__END_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3826 |
if (ret < 0) { |
1135 | 3827 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3828 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3829 |
RETURN ( ((ret == 0) ? true : false) ); |
616 | 3830 |
} |
3831 |
%}. |
|
792 | 3832 |
^ self primitiveFailed |
68 | 3833 |
! |
3834 |
||
616 | 3835 |
isSymbolicLink:aPathName |
3836 |
"return true, if the given file is a symbolic link" |
|
3837 |
||
3838 |
^ (self linkInfoOf:aPathName) notNil |
|
3839 |
||
3840 |
" |
|
3841 |
OperatingSystem isSymbolicLink:'Make.proto' |
|
3842 |
OperatingSystem isSymbolicLink:'Makefile' |
|
3843 |
" |
|
3844 |
! |
|
3845 |
||
3846 |
isValidPath:aPathName |
|
3847 |
"return true, if 'aPathName' is a valid path name |
|
3848 |
(i.e. the file or directory exists)" |
|
68 | 3849 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3850 |
%{ |
616 | 3851 |
struct stat buf; |
3852 |
int ret; |
|
3853 |
||
3854 |
if (__isString(aPathName) || __isSymbol(aPathName) ) { |
|
3855 |
__BEGIN_INTERRUPTABLE__ |
|
3856 |
do { |
|
1135 | 3857 |
ret = stat((char *) __stringVal(aPathName), &buf); |
616 | 3858 |
} while ((ret < 0) && (errno == EINTR)); |
3859 |
__END_INTERRUPTABLE__ |
|
3860 |
if (ret < 0) { |
|
1135 | 3861 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 3862 |
RETURN (false); |
3863 |
} |
|
3864 |
RETURN ( ret ? false : true ); |
|
3865 |
} |
|
792 | 3866 |
%}. |
3867 |
^ self primitiveFailed |
|
68 | 3868 |
! |
3869 |
||
616 | 3870 |
isWritable:aPathName |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3871 |
"return true, if the given file is writable. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3872 |
For symbolic links, the pointed-to-file is checked." |
68 | 3873 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3874 |
%{ |
616 | 3875 |
int ret; |
3876 |
||
3877 |
if (__isString(aPathName)) { |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3878 |
__BEGIN_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3879 |
do { |
1135 | 3880 |
ret = access(__stringVal(aPathName), W_OK); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3881 |
} while ((ret < 0) && (errno == EINTR)); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3882 |
__END_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3883 |
if (ret < 0) { |
1135 | 3884 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3885 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3886 |
RETURN ( ((ret == 0) ? true : false) ); |
616 | 3887 |
} |
3888 |
%}. |
|
792 | 3889 |
^ self primitiveFailed |
68 | 3890 |
! |
3891 |
||
616 | 3892 |
linkInfoOf:aPathName |
3893 |
"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
|
3894 |
IFF aPathName is a symbolic link. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3895 |
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
|
3896 |
|
616 | 3897 |
The contents of the dictionary gives info about the link itself, |
3898 |
on contrast to #infoOf:, which returns the info of the pointed to file |
|
3899 |
in case of a symbolic link." |
|
3900 |
||
3901 |
|info type mode uid gid size id atimeLow atimeHi mtimeLow mtimeHi ctimeLow ctimeHi |
|
3902 |
path| |
|
3903 |
||
3904 |
%{ /* STACK: 1200 */ |
|
792 | 3905 |
#ifdef S_IFLNK |
616 | 3906 |
struct stat buf; |
3907 |
int ret; |
|
3908 |
char pathBuffer[1024]; |
|
3909 |
||
3910 |
if (__isString(aPathName)) { |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3911 |
__BEGIN_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3912 |
do { |
1135 | 3913 |
ret = lstat((char *) __stringVal(aPathName), &buf); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3914 |
} while ((ret < 0) && (errno == EINTR)); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3915 |
__END_INTERRUPTABLE__ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3916 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3917 |
if (ret < 0) { |
1135 | 3918 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3919 |
RETURN ( nil ); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3920 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3921 |
switch (buf.st_mode & S_IFMT) { |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3922 |
default: |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3923 |
RETURN ( nil ); /* not a symbolic link */ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3924 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3925 |
case S_IFLNK: |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3926 |
type = @symbol(symbolicLink); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3927 |
break; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3928 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3929 |
|
1135 | 3930 |
mode = __MKSMALLINT(buf.st_mode & 0777); |
3931 |
uid = __MKSMALLINT(buf.st_uid); |
|
3932 |
gid = __MKSMALLINT(buf.st_gid); |
|
3933 |
size = __MKSMALLINT(buf.st_size); |
|
3934 |
id = __MKSMALLINT(buf.st_ino); |
|
3935 |
atimeLow = __MKSMALLINT(buf.st_atime & 0xFFFF); |
|
3936 |
atimeHi = __MKSMALLINT((buf.st_atime >> 16) & 0xFFFF); |
|
3937 |
mtimeLow = __MKSMALLINT(buf.st_mtime & 0xFFFF); |
|
3938 |
mtimeHi = __MKSMALLINT((buf.st_mtime >> 16) & 0xFFFF); |
|
3939 |
ctimeLow = __MKSMALLINT(buf.st_ctime & 0xFFFF); |
|
3940 |
ctimeHi = __MKSMALLINT((buf.st_ctime >> 16) & 0xFFFF); |
|
3941 |
if ((ret = readlink((char *) __stringVal(aPathName), pathBuffer, sizeof(pathBuffer))) < 0) { |
|
3942 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3943 |
RETURN ( nil ); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3944 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3945 |
pathBuffer[ret] = '\0'; /* readlink does not 0-terminate */ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3946 |
path = __MKSTRING(pathBuffer COMMA_CON); |
616 | 3947 |
} |
792 | 3948 |
#else |
3949 |
RETURN ( nil ); |
|
3950 |
#endif |
|
616 | 3951 |
%}. |
3952 |
mode notNil ifTrue:[ |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3953 |
info := IdentityDictionary new. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3954 |
info at:#type put:type. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3955 |
info at:#mode put:mode. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3956 |
info at:#uid put:uid. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3957 |
info at:#gid put:gid. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3958 |
info at:#size put:size. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3959 |
info at:#id put:id. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3960 |
info at:#path put:path. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3961 |
info at:#accessed put:(AbsoluteTime fromOSTimeLow:atimeLow and:atimeHi). |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3962 |
info at:#modified put:(AbsoluteTime fromOSTimeLow:mtimeLow and:mtimeHi). |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3963 |
info at:#statusChanged put:(AbsoluteTime fromOSTimeLow:ctimeLow and:ctimeHi). |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3964 |
^ info |
616 | 3965 |
]. |
792 | 3966 |
^ self primitiveFailed |
616 | 3967 |
|
3968 |
" |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3969 |
OperatingSystem infoOf:'Make.proto' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3970 |
OperatingSystem linkInfoOf:'Make.proto' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3971 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3972 |
OperatingSystem infoOf:'resources/motif.style' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3973 |
OperatingSystem linkInfoOf:'resources/motif.style' |
616 | 3974 |
" |
3975 |
! |
|
3976 |
||
3977 |
parentDirectoryName |
|
3978 |
"return the name used to refer to parent directories. |
|
3979 |
In MSDOS, Unix and other systems this is '..', but maybe different |
|
3980 |
for other systems. |
|
3981 |
(but those are currently not supported - so this is some |
|
3982 |
preparation for the future)" |
|
3983 |
||
3984 |
^ '..' |
|
68 | 3985 |
! |
3986 |
||
616 | 3987 |
pathNameOf:pathName |
3988 |
"return the pathName of the argument, aPathString, |
|
3989 |
- thats the full pathname of the directory, starting at '/'. |
|
3990 |
This method needs the path to be valid |
|
3991 |
(i.e. all directories must exist, be readable and executable). |
|
3992 |
Notice: if symbolic links are involved, the result may look different |
|
3993 |
from what you expect." |
|
3994 |
||
3995 |
|p path command| |
|
3996 |
||
3997 |
"some systems have a convenient function for this ..." |
|
3998 |
path := self primPathNameOf:pathName. |
|
3999 |
||
4000 |
path isNil ifTrue:[ |
|
4001 |
(self isValidPath:pathName) ifFalse:[^ pathName]. |
|
4002 |
||
4003 |
(SlowFork==true or:[ForkFailed]) ifFalse:[ |
|
4004 |
PipeStream openErrorSignal handle:[:ex | |
|
4005 |
ForkFailed := true. |
|
4006 |
'OS: cannot fork/popen' errorPrintNL. |
|
4007 |
ex return. |
|
4008 |
] do:[ |
|
4009 |
"have to fall back ..." |
|
4010 |
command := 'cd ' , pathName , '; pwd'. |
|
4011 |
p := PipeStream readingFrom:command. |
|
4012 |
]. |
|
4013 |
||
4014 |
(p isNil or:[p atEnd]) ifTrue:[ |
|
4015 |
('OS: PipeStream for <' , command , '> failed') errorPrintNL. |
|
4016 |
] ifFalse:[ |
|
4017 |
path := p nextLine. |
|
4018 |
p close. |
|
4019 |
]. |
|
4020 |
]. |
|
4021 |
path isNil ifTrue:[ |
|
4022 |
path := pathName |
|
4023 |
]. |
|
4024 |
(SlowFork==true or:[ForkFailed]) ifTrue:[ |
|
4025 |
path := self compressPath:path |
|
4026 |
] |
|
4027 |
]. |
|
4028 |
^ path. |
|
4029 |
||
4030 |
" |
|
4031 |
OperatingSystem pathNameOf:'.' |
|
4032 |
OperatingSystem pathNameOf:'../smalltalk/../smalltalk' |
|
4033 |
OperatingSystem pathNameOf:'../../..' |
|
4034 |
OperatingSystem pathNameOf:'..' |
|
4035 |
" |
|
359 | 4036 |
! |
4037 |
||
616 | 4038 |
primPathNameOf:pathName |
4039 |
"return the pathName of the argument, aPathString, |
|
4040 |
- thats the full pathname of the directory, starting at '/'. |
|
4041 |
This method here returns nil, if the OS does not provide a |
|
4042 |
realPath library function. |
|
4043 |
Notice: if symbolic links are involved, the result may look different |
|
4044 |
from what you expect." |
|
4045 |
||
4046 |
|path| |
|
4047 |
||
4048 |
"some systems have a convenient function for this ..." |
|
4049 |
%{ /* STACK: 16000 */ |
|
4050 |
#ifdef HAS_REALPATH |
|
4051 |
char nameBuffer[MAXPATHLEN + 1]; |
|
4052 |
||
4053 |
if (__isString(pathName)) { |
|
1135 | 4054 |
if (realpath(__stringVal(pathName), nameBuffer)) { |
830 | 4055 |
RETURN ( __MKSTRING(nameBuffer COMMA_CON) ); |
616 | 4056 |
} |
4057 |
} |
|
4058 |
#endif |
|
4059 |
%}. |
|
4060 |
^ nil |
|
359 | 4061 |
! |
4062 |
||
616 | 4063 |
timeOfLastAccess:aPathName |
4064 |
"return the time, when the file was last accessed. |
|
4065 |
For nonexistent files, nil is returned." |
|
4066 |
||
4067 |
"could be implemented as: |
|
4068 |
(self infoOf:aPathName) at:#accessed |
|
4069 |
" |
|
4070 |
|timeLow timeHi| |
|
4071 |
%{ |
|
4072 |
struct stat buf; |
|
4073 |
time_t mtime; |
|
4074 |
int ret; |
|
4075 |
||
4076 |
if (__isString(aPathName)) { |
|
4077 |
__BEGIN_INTERRUPTABLE__ |
|
4078 |
do { |
|
1135 | 4079 |
ret = stat((char *) __stringVal(aPathName), &buf); |
616 | 4080 |
} while (ret < 0 && errno == EINTR); |
4081 |
__END_INTERRUPTABLE__ |
|
4082 |
if (ret < 0) { |
|
1135 | 4083 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 4084 |
RETURN (nil); |
4085 |
} |
|
1135 | 4086 |
timeLow = __MKSMALLINT(buf.st_atime & 0xFFFF); |
4087 |
timeHi = __MKSMALLINT((buf.st_atime >> 16) & 0xFFFF); |
|
616 | 4088 |
} |
792 | 4089 |
%}. |
616 | 4090 |
timeLow notNil ifTrue:[^ AbsoluteTime fromOSTimeLow:timeLow and:timeHi]. |
792 | 4091 |
^ self primitiveFailed |
616 | 4092 |
|
4093 |
" |
|
4094 |
OperatingSystem timeOfLastAccess:'/' |
|
4095 |
" |
|
359 | 4096 |
! |
4097 |
||
616 | 4098 |
timeOfLastChange:aPathName |
4099 |
"return the time, when the file was last changed. |
|
4100 |
For nonexistent files, nil is returned." |
|
4101 |
||
4102 |
"could be implemented as: |
|
4103 |
(self infoOf:aPathName) at:#modified |
|
4104 |
" |
|
4105 |
||
4106 |
|timeLow timeHi| |
|
4107 |
%{ |
|
4108 |
struct stat buf; |
|
4109 |
int ret; |
|
4110 |
time_t mtime; |
|
4111 |
||
4112 |
if (__isString(aPathName)) { |
|
4113 |
__BEGIN_INTERRUPTABLE__ |
|
4114 |
do { |
|
1135 | 4115 |
ret = stat((char *) __stringVal(aPathName), &buf); |
616 | 4116 |
} while (ret < 0 && errno == EINTR); |
4117 |
__END_INTERRUPTABLE__ |
|
4118 |
if (ret < 0) { |
|
1135 | 4119 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 4120 |
RETURN ( nil ); |
4121 |
} |
|
1135 | 4122 |
timeLow = __MKSMALLINT(buf.st_mtime & 0xFFFF); |
4123 |
timeHi = __MKSMALLINT((buf.st_mtime >> 16) & 0xFFFF); |
|
616 | 4124 |
} |
792 | 4125 |
%}. |
616 | 4126 |
timeLow notNil ifTrue:[^ AbsoluteTime fromOSTimeLow:timeLow and:timeHi]. |
792 | 4127 |
^ self primitiveFailed |
616 | 4128 |
|
4129 |
" |
|
4130 |
OperatingSystem timeOfLastChange:'/' |
|
4131 |
" |
|
4132 |
! |
|
4133 |
||
4134 |
typeOf:aPathName |
|
4135 |
"return the type of a file as a symbol" |
|
4136 |
||
4137 |
" |
|
4138 |
this could have been implemented as: |
|
4139 |
(self infoOf:aPathName) at:#type |
|
4140 |
but for huge directory searches the code below is faster |
|
4141 |
" |
|
359 | 4142 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4143 |
%{ |
616 | 4144 |
struct stat buf; |
4145 |
int ret; |
|
4146 |
||
4147 |
if (__isString(aPathName)) { |
|
4148 |
__BEGIN_INTERRUPTABLE__ |
|
4149 |
do { |
|
1135 | 4150 |
ret = stat((char *) __stringVal(aPathName), &buf); |
616 | 4151 |
} while (ret < 0 && errno == EINTR); |
4152 |
__END_INTERRUPTABLE__ |
|
4153 |
if (ret < 0) { |
|
1135 | 4154 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 4155 |
RETURN ( nil ); |
4156 |
} |
|
4157 |
switch (buf.st_mode & S_IFMT) { |
|
4158 |
case S_IFDIR: |
|
4159 |
RETURN ( @symbol(directory) ); |
|
4160 |
case S_IFREG: |
|
4161 |
RETURN ( @symbol(regular) ); |
|
4162 |
#ifdef S_IFCHR |
|
4163 |
case S_IFCHR: |
|
4164 |
RETURN ( @symbol(characterSpecial) ); |
|
4165 |
#endif |
|
4166 |
#ifdef S_IFBLK |
|
4167 |
case S_IFBLK: |
|
4168 |
RETURN ( @symbol(blockSpecial) ); |
|
4169 |
#endif |
|
4170 |
#ifdef S_IFLNK |
|
4171 |
case S_IFLNK: |
|
4172 |
RETURN ( @symbol(symbolicLink) ); |
|
4173 |
#endif |
|
4174 |
#ifdef S_IFSOCK |
|
4175 |
case S_IFSOCK: |
|
4176 |
RETURN ( @symbol(socket) ); |
|
4177 |
#endif |
|
4178 |
#ifdef S_IFIFO |
|
4179 |
case S_IFIFO: |
|
4180 |
RETURN ( @symbol(fifo) ); |
|
4181 |
#endif |
|
4182 |
default: |
|
4183 |
RETURN ( @symbol(unknown) ); |
|
4184 |
} |
|
4185 |
} |
|
4186 |
%}. |
|
792 | 4187 |
^ self primitiveFailed |
616 | 4188 |
|
4189 |
" |
|
4190 |
OperatingSystem typeOf:'/' |
|
4191 |
OperatingSystem typeOf:'.' |
|
4192 |
OperatingSystem typeOf:'Make.proto' |
|
4193 |
" |
|
68 | 4194 |
! ! |
4195 |
||
63 | 4196 |
!OperatingSystem class methodsFor:'interrupts & signals'! |
4197 |
||
10 | 4198 |
blockInterrupts |
95 | 4199 |
"disable interrupt processing - if disabled, incoming |
4200 |
interrupts will be registered and handled as soon as |
|
4201 |
interrupts are reenabled by OperatingSystemclass>>unblockInterrupts. |
|
4202 |
Returns the previous blocking status i.e. true if interrupts |
|
4203 |
where already blocked. You need this information for proper |
|
4204 |
unblocking, in case of nested block/unblock calls." |
|
4205 |
||
4206 |
%{ /* NOCONTEXT */ |
|
710 | 4207 |
RETURN ( __BLOCKINTERRUPTS() ); |
10 | 4208 |
%} |
4209 |
! |
|
4210 |
||
616 | 4211 |
defaultSignal:signalNumber |
4212 |
"revert to the default action on arrival of a (Unix-)signal. |
|
4213 |
Dont confuse Unix signals with smalltalk signals. |
|
4214 |
WARNING: for some signals, it is no good idea to revert to default; |
|
4215 |
for example, the default for SIGINT (i.e. ^C) is to exit; while the |
|
4216 |
default for SIGQUIT (^ \) is to dump core. |
|
4217 |
Also, NOTICE that signal numbers are not portable between unix |
|
4218 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
4219 |
a signal." |
|
4220 |
||
4221 |
%{ /* NOCONTEXT */ |
|
4222 |
||
4223 |
if (__isSmallInteger(signalNumber)) { |
|
831 | 4224 |
#ifdef SIG_DFL |
1135 | 4225 |
signal(__intVal(signalNumber), SIG_DFL); |
616 | 4226 |
RETURN (self); |
831 | 4227 |
#endif |
616 | 4228 |
} |
4229 |
%}. |
|
4230 |
" |
|
4231 |
this error is triggered on non-integer argument |
|
4232 |
" |
|
792 | 4233 |
^ self primitiveFailed |
616 | 4234 |
|
4235 |
"you better save a snapshot image before trying this ..." |
|
4236 |
" |
|
4237 |
'if you hit ^C now, Smalltalk will exit immediately' printNewline. |
|
4238 |
OperatingSystem defaultSignal:(OperatingSystem sigINT). |
|
4239 |
1 to:1000000 do:[:i| ]. |
|
4240 |
OperatingSystem enableSignal:(OperatingSystem sigINT). |
|
4241 |
'normal ^C handling again.' printNewline |
|
4242 |
" |
|
4243 |
! |
|
4244 |
||
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4245 |
disableChildSignalInterrupts |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4246 |
"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
|
4247 |
(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
|
4248 |
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
|
4249 |
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
|
4250 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4251 |
^ 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
|
4252 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4253 |
"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
|
4254 |
! |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4255 |
|
616 | 4256 |
disableIOInterruptsOn:fd |
4257 |
"turn off IO interrupts for a filedescriptor" |
|
4258 |
||
4259 |
%{ /* NOCONTEXT */ |
|
4260 |
||
4261 |
int ret, flags, f; |
|
4262 |
||
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4263 |
#if (defined(F_GETFL) && defined(F_SETFL) && defined(FASYNC)) || defined(SYSV4) |
616 | 4264 |
if (__isSmallInteger(fd)) { |
1135 | 4265 |
f = __intVal(fd); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4266 |
# if defined(SYSV4) |
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
756
diff
changeset
|
4267 |
ret = ioctl(f, I_SETSIG, 0); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4268 |
# else /*! SYSV4*/ |
616 | 4269 |
flags = fcntl(f, F_GETFL, 0); |
4270 |
/* |
|
4271 |
* if already clear, there is no need for this syscall ... |
|
4272 |
*/ |
|
4273 |
if (flags & FASYNC) { |
|
4274 |
ret = fcntl(f, F_SETFL, flags & ~FASYNC); |
|
4275 |
if (ret >= 0) ret = flags; |
|
4276 |
} else { |
|
4277 |
ret = flags; |
|
4278 |
} |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4279 |
# endif /* !SYSV4 */ |
1135 | 4280 |
RETURN ( __MKSMALLINT(ret) ); |
616 | 4281 |
} |
4282 |
#endif |
|
4283 |
%}. |
|
4284 |
" |
|
4285 |
this error is triggered on non-integer argument |
|
4286 |
or if the OS does not support IO interrupts. |
|
4287 |
" |
|
792 | 4288 |
^ self primitiveFailed |
10 | 4289 |
! |
4290 |
||
63 | 4291 |
disableSignal:signalNumber |
95 | 4292 |
"disable (Unix-) signal processing for signalNumber. |
4293 |
Dont confuse Unix signals with smalltalk signals. |
|
63 | 4294 |
WARNING: for some signals, it is no good idea to disable |
95 | 4295 |
them; for example, disabling the SIGINT signal turns off ^C |
63 | 4296 |
handling. |
68 | 4297 |
Also, NOTICE that signal numbers are not portable between unix |
4298 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
4299 |
a signal. |
|
63 | 4300 |
Use only for fully debugged stand alone applications." |
4301 |
||
4302 |
%{ /* NOCONTEXT */ |
|
4303 |
||
252 | 4304 |
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
|
4305 |
int sigNo = __intVal(signalNumber); |
831 | 4306 |
|
4307 |
if (sigNo == 0) { |
|
4308 |
RETURN (self); |
|
4309 |
} |
|
4310 |
#ifdef SIG_IGN |
|
4311 |
signal(sigNo, SIG_IGN); |
|
185 | 4312 |
RETURN (self); |
831 | 4313 |
#endif |
63 | 4314 |
} |
68 | 4315 |
%}. |
4316 |
" |
|
4317 |
this error is triggered on non-integer argument |
|
4318 |
" |
|
792 | 4319 |
^ self primitiveFailed |
68 | 4320 |
|
4321 |
" |
|
4322 |
'now, ^C is totally ignored ...' printNewline. |
|
4323 |
OperatingSystem disableSignal:(OperatingSystem sigINT). |
|
4324 |
1 to:1000000 do:[:i| ]. |
|
4325 |
OperatingSystem enableSignal:(OperatingSystem sigINT). |
|
4326 |
'^C handled again.' printNewline |
|
4327 |
" |
|
4328 |
! |
|
4329 |
||
616 | 4330 |
disableTimer |
831 | 4331 |
"disable timer interrupts. |
4332 |
WARNING: |
|
4333 |
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
|
4334 |
disabled, because no scheduling or timeouts are possible." |
616 | 4335 |
|
4336 |
%{ /* NOCONTEXT */ |
|
4337 |
||
4338 |
#if defined(ITIMER_REAL) |
|
4339 |
struct itimerval dt; |
|
4340 |
||
4341 |
dt.it_interval.tv_sec = 0; |
|
4342 |
dt.it_interval.tv_usec = 0; |
|
4343 |
dt.it_value.tv_sec = 0; |
|
4344 |
dt.it_value.tv_usec = 0; |
|
4345 |
setitimer(ITIMER_REAL, &dt, 0); |
|
4346 |
RETURN (true); |
|
831 | 4347 |
#endif /* ITIMER_REAL */ |
616 | 4348 |
%} |
4349 |
. |
|
4350 |
^ false |
|
4351 |
! |
|
4352 |
||
4353 |
disableUserInterrupts |
|
4354 |
"disable userInterrupt processing; |
|
4355 |
when disabled, no ^C processing takes place. |
|
831 | 4356 |
WARNING: |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4357 |
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
|
4358 |
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
|
4359 |
We recommend setting up a handler for the signal instead of disabling it." |
831 | 4360 |
|
4361 |
self disableSignal:(self sigBREAK). |
|
4362 |
self disableSignal:(self sigINT). |
|
616 | 4363 |
! |
4364 |
||
4365 |
enableAbortInterrupts |
|
4366 |
"enable abort signalhandling, and make it a regular signalInterrupt. |
|
4367 |
(the default will dump core and exit - which is not a good idea for |
|
4368 |
end-user applications ...). |
|
4369 |
This is especially useful, if linked-in C-libraries call abort() ..." |
|
4370 |
||
831 | 4371 |
self enableSignal:(self sigABRT) |
616 | 4372 |
! |
4373 |
||
4374 |
enableChildSignalInterrupts |
|
4375 |
"enable childSignal interrupts |
|
4376 |
(SIGCHLD, if the architecture supports it). |
|
831 | 4377 |
After enabling, these signals will send the message |
616 | 4378 |
'childSignalInterrupt' to the ChildSignalInterruptHandler object." |
4379 |
||
831 | 4380 |
self enableSignal:(self sigCHLD) |
616 | 4381 |
! |
4382 |
||
4383 |
enableFpExceptionInterrupts |
|
4384 |
"enable floating point exception interrupts (if the |
|
4385 |
architecture supports it). |
|
831 | 4386 |
After enabling, fpu-exceptions will send the message |
616 | 4387 |
'fpuExceptionInterrupt' to the FPUExceptionInterruptHandler object." |
4388 |
||
831 | 4389 |
self enableSignal:(self sigFP) |
616 | 4390 |
! |
4391 |
||
4392 |
enableHardSignalInterrupts |
|
4393 |
"enable hard signal exception interrupts (trap, buserror & segm. violation). |
|
831 | 4394 |
After enabling, these exceptions will send the message |
616 | 4395 |
'signalInterrupt' to the SignalInterruptHandler object." |
68 | 4396 |
|
855
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
4397 |
"/ 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
|
4398 |
"/ 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
|
4399 |
|
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
4400 |
"/ ... 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
|
4401 |
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
|
4402 |
|
640
be94dfc60eaa
Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents:
630
diff
changeset
|
4403 |
self enableSignal:(self sigBUS). |
be94dfc60eaa
Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents:
630
diff
changeset
|
4404 |
self enableSignal:(self sigSEGV) |
616 | 4405 |
! |
4406 |
||
4407 |
enableIOInterruptsOn:fd |
|
4408 |
"turn on IO interrupts for a filedescriptor" |
|
4409 |
||
4410 |
%{ /* NOCONTEXT */ |
|
4411 |
||
4412 |
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
|
4413 |
#ifndef __signalIoInterrupt |
616 | 4414 |
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
|
4415 |
#endif |
616 | 4416 |
static int firstCall = 1; |
4417 |
||
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4418 |
#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
|
4419 |
/* |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4420 |
* SIGIO/SIGPOLL - data available for I/O |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4421 |
* (used to wake up waiting processes) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4422 |
*/ |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4423 |
#ifdef SIGIO |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4424 |
# define THESIGNAL SIGIO |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4425 |
#else |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4426 |
# ifdef SIGPOLL |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4427 |
# define THESIGNAL SIGPOLL |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4428 |
# else |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4429 |
# ifdef SIGURG |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4430 |
# define THESIGNAL SIGURG |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4431 |
# endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4432 |
# endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4433 |
#endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4434 |
|
616 | 4435 |
if (__isSmallInteger(fd)) { |
4436 |
if (firstCall) { |
|
762
cea705669628
ok, stefan was right: HAS_SIGACTION works
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
4437 |
#ifdef HAS_SIGACTION |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4438 |
struct sigaction act; |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4439 |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4440 |
/* |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4441 |
* Do not add SA_RESTART here. A signal can cause a |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4442 |
* thread switch, another thread can do a garbage collect |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4443 |
* and restarted system calls may write into old |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4444 |
* (collected) addresses. |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4445 |
*/ |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4446 |
|
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4447 |
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
|
4448 |
sigemptyset(&act.sa_mask); |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4449 |
act.sa_handler = __signalIoInterrupt; |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4450 |
sigaction(THESIGNAL, &act, 0); |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4451 |
#else |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4452 |
# ifdef HAS_SIGVEC |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4453 |
struct sigvec vec; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4454 |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4455 |
vec.sv_flags = SV_INTERRUPT; |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4456 |
sigemptyset(&vec.sv_mask); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4457 |
vec.sv_handler = __signalIoInterrupt; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4458 |
sigvec(THESIGNAL, &vec, NULL); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4459 |
# else |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4460 |
signal(THESIGNAL, __signalIoInterrupt); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4461 |
# endif |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4462 |
#endif |
616 | 4463 |
firstCall = 0; |
4464 |
} |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4465 |
#undef THESIGNAL |
616 | 4466 |
|
1135 | 4467 |
f = __intVal(fd); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4468 |
# if defined(SYSV4) |
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
756
diff
changeset
|
4469 |
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
|
4470 |
# else /*! SYSV4*/ |
616 | 4471 |
flags = fcntl(f, F_GETFL, 0); |
4472 |
/* |
|
4473 |
* if already set, there is no need for this syscall ... |
|
4474 |
*/ |
|
4475 |
if (flags & FASYNC) { |
|
4476 |
ret = flags; |
|
4477 |
} else { |
|
4478 |
ret = fcntl(f, F_SETFL, flags | FASYNC); |
|
4479 |
if (ret >= 0) ret = flags; |
|
4480 |
} |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4481 |
# endif /*!SYSV4*/ |
1135 | 4482 |
RETURN ( __MKSMALLINT(ret) ); |
68 | 4483 |
} |
616 | 4484 |
#endif |
68 | 4485 |
%}. |
4486 |
" |
|
4487 |
this error is triggered on non-integer argument |
|
616 | 4488 |
or if the system does not support SIGIO |
68 | 4489 |
" |
792 | 4490 |
^ self primitiveFailed |
616 | 4491 |
! |
4492 |
||
4493 |
enableQuitInterrupts |
|
4494 |
"enable quitInterrupt (usually ^\) handling, and make it a userInterrupt. |
|
4495 |
(the default will dump core and exit - which is not a good idea for |
|
4496 |
end-user applications ...)" |
|
4497 |
||
831 | 4498 |
self enableSignal:(self sigQUIT) |
68 | 4499 |
! |
4500 |
||
4501 |
enableSignal:signalNumber |
|
95 | 4502 |
"enable (Unix-)signal processing for signalNumber. |
4503 |
Dont confuse Unix signals with smalltalk signals. |
|
68 | 4504 |
The signal will be delivered to one of the standard handlers |
4505 |
(SIGINT, SIGQUIT, etc) or to a general handler, which |
|
4506 |
sends #signalInterrupt:. |
|
4507 |
||
4508 |
NOTICE that signal numbers are not portable between unix |
|
4509 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
4510 |
a signal." |
|
4511 |
||
4512 |
%{ /* NOCONTEXT */ |
|
4513 |
||
4514 |
#ifdef NSIG |
|
4515 |
# define SIG_LIMIT NSIG |
|
4516 |
#else |
|
4517 |
# ifdef SIGUSR2 |
|
4518 |
# define SIG_LIMIT SIGUSR2 |
|
4519 |
# else |
|
4520 |
# ifdef SIGUSR |
|
4521 |
# define SIG_LIMIT SIGUSR |
|
4522 |
# endif |
|
4523 |
# endif |
|
4524 |
#endif |
|
4525 |
||
4526 |
#if defined(SIGPOLL) && !defined(SIGIO) |
|
4527 |
# define SIGIO SIGPOLL |
|
4528 |
#endif |
|
4529 |
||
4530 |
#ifdef SIGCHLD |
|
4531 |
# define CHILD_SIGNAL SIGCHLD |
|
4532 |
#else |
|
4533 |
# ifdef SIGCLD |
|
4534 |
# define CHILD_SIGNAL SIGCLD |
|
4535 |
# endif |
|
4536 |
#endif |
|
4537 |
||
4538 |
int sigNr; |
|
443 | 4539 |
#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
|
4540 |
# ifndef __signalUserInterrupt |
831 | 4541 |
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
|
4542 |
# endif |
443 | 4543 |
#endif |
4544 |
#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
|
4545 |
# ifndef __signalFpExceptionInterrupt |
831 | 4546 |
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
|
4547 |
# endif |
443 | 4548 |
#endif |
4549 |
#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
|
4550 |
# ifndef __signalIoInterrupt |
831 | 4551 |
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
|
4552 |
# endif |
443 | 4553 |
#endif |
68 | 4554 |
#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
|
4555 |
# ifndef __signalChildInterrupt |
831 | 4556 |
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
|
4557 |
# endif |
68 | 4558 |
#endif |
443 | 4559 |
#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
|
4560 |
# ifndef __signalPIPEInterrupt |
831 | 4561 |
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
|
4562 |
# endif |
443 | 4563 |
#endif |
4564 |
#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
|
4565 |
# ifndef __signalBUSInterrupt |
831 | 4566 |
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
|
4567 |
# endif |
443 | 4568 |
#endif |
4569 |
#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
|
4570 |
# ifndef __signalSEGVInterrupt |
831 | 4571 |
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
|
4572 |
# endif |
443 | 4573 |
#endif |
4574 |
#ifdef SIGALRM |
|
831 | 4575 |
# 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
|
4576 |
# ifndef __signalTimerInterrupt |
831 | 4577 |
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
|
4578 |
# endif |
831 | 4579 |
# endif |
4580 |
#endif |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4581 |
#ifndef __signalInterrupt |
831 | 4582 |
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
|
4583 |
#endif |
831 | 4584 |
void (*handler)(SIGHANDLER_ARG); |
68 | 4585 |
|
252 | 4586 |
if (__isSmallInteger(signalNumber) |
1135 | 4587 |
&& ((sigNr = __intVal(signalNumber)) >= 0) |
831 | 4588 |
#ifdef SIG_LIMIT |
4589 |
&& (sigNr <= SIG_LIMIT) |
|
4590 |
#endif |
|
4591 |
) { |
|
185 | 4592 |
/* |
4593 |
* standard signals are forced into standard handlers |
|
4594 |
* - all others go into general signalInterrupt |
|
4595 |
*/ |
|
68 | 4596 |
#if defined(SIGPOLL) && defined(SIGIO) |
185 | 4597 |
if (sigNr == SIGPOLL) |
4598 |
sigNr = SIGIO; |
|
68 | 4599 |
#endif |
185 | 4600 |
switch (sigNr) { |
831 | 4601 |
case 0: |
4602 |
/* enabling a non-supported signal */ |
|
4603 |
RETURN (self); |
|
4604 |
||
4605 |
#ifdef SIGBREAK |
|
4606 |
case SIGBREAK: |
|
4607 |
#endif |
|
443 | 4608 |
#ifdef SIGINT |
185 | 4609 |
case SIGINT: |
443 | 4610 |
#endif |
4611 |
#ifdef SIGQUIT |
|
185 | 4612 |
case SIGQUIT: |
443 | 4613 |
#endif |
831 | 4614 |
#if defined(SIGINT) || defined(SIGQUIT) || defined(SIGBREAK) |
329 | 4615 |
handler = __signalUserInterrupt; |
185 | 4616 |
break; |
443 | 4617 |
#endif |
4618 |
||
4619 |
#ifdef SIGFPE |
|
185 | 4620 |
case SIGFPE: |
329 | 4621 |
handler = __signalFpExceptionInterrupt; |
185 | 4622 |
break; |
443 | 4623 |
#endif |
4624 |
||
4625 |
#ifdef SIGPIPE |
|
185 | 4626 |
case SIGPIPE: |
329 | 4627 |
handler = __signalPIPEInterrupt; |
185 | 4628 |
break; |
443 | 4629 |
#endif |
68 | 4630 |
#ifdef SIGBUS |
185 | 4631 |
case SIGBUS: |
329 | 4632 |
handler = __signalBUSInterrupt; |
185 | 4633 |
break; |
68 | 4634 |
#endif |
443 | 4635 |
#ifdef SIGSEGV |
185 | 4636 |
case SIGSEGV: |
329 | 4637 |
handler = __signalSEGVInterrupt; |
185 | 4638 |
break; |
443 | 4639 |
#endif |
68 | 4640 |
#ifdef SIGIO |
185 | 4641 |
case SIGIO: |
329 | 4642 |
handler = __signalIoInterrupt; |
185 | 4643 |
break; |
68 | 4644 |
#endif |
4645 |
||
4646 |
#ifdef CHILD_SIGNAL |
|
185 | 4647 |
case CHILD_SIGNAL: |
329 | 4648 |
handler = __signalChildInterrupt; |
185 | 4649 |
break; |
68 | 4650 |
#endif |
443 | 4651 |
#ifdef SIGALRM |
831 | 4652 |
# ifndef WIN32 |
185 | 4653 |
case SIGALRM: |
329 | 4654 |
handler = __signalTimerInterrupt; |
185 | 4655 |
break; |
831 | 4656 |
# endif |
443 | 4657 |
#endif |
185 | 4658 |
|
4659 |
default: |
|
329 | 4660 |
handler = __signalInterrupt; |
185 | 4661 |
break; |
4662 |
} |
|
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4663 |
|
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4664 |
{ |
762
cea705669628
ok, stefan was right: HAS_SIGACTION works
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
4665 |
#ifdef HAS_SIGACTION |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4666 |
struct sigaction act; |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4667 |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4668 |
/* |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4669 |
* Do not add SA_RESTART here. A signal can cause a |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4670 |
* thread switch, another thread can do a garbage collect |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4671 |
* and restarted system calls may write into old |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4672 |
* (collected) addresses. |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4673 |
*/ |
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4674 |
|
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4675 |
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
|
4676 |
sigemptyset(&act.sa_mask); |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4677 |
act.sa_handler = handler; |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4678 |
sigaction(sigNr, &act, 0); |
213 | 4679 |
#else |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4680 |
# ifdef HAS_SIGVEC |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4681 |
struct sigvec vec; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4682 |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4683 |
vec.sv_flags = SV_INTERRUPT; |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4684 |
sigemptyset(&vec.sv_mask); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4685 |
vec.sv_handler = handler; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4686 |
sigvec(sigNr, &vec, NULL); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4687 |
# else |
831 | 4688 |
(void) signal(sigNr, handler); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4689 |
# endif |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4690 |
#endif |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4691 |
} |
213 | 4692 |
|
185 | 4693 |
/* |
4694 |
* maybe, we should return the old enable-status |
|
4695 |
* as boolean here ... |
|
4696 |
*/ |
|
4697 |
RETURN (self); |
|
68 | 4698 |
} |
4699 |
%}. |
|
4700 |
||
4701 |
" |
|
4702 |
this error is triggered on non-integer argument, or |
|
4703 |
if the signal number is not in the valid range (1..NSIG) |
|
4704 |
" |
|
792 | 4705 |
^ self primitiveFailed |
63 | 4706 |
! |
4707 |
||
831 | 4708 |
enableTimer:milliSeconds |
616 | 4709 |
"trigger a timerInterrupt, to be signalled after some (real) time." |
4710 |
||
4711 |
%{ /* NOCONTEXT */ |
|
831 | 4712 |
int millis; |
4713 |
||
4714 |
millis = __intVal(milliSeconds); |
|
616 | 4715 |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4716 |
#if defined(ITIMER_REAL) |
831 | 4717 |
{ |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4718 |
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
|
4719 |
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
|
4720 |
#ifndef __signalTimerInterrupt |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4721 |
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
|
4722 |
#endif |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4723 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4724 |
if (firstCall) { |
831 | 4725 |
# ifdef HAS_SIGACTION |
4726 |
struct sigaction act; |
|
4727 |
||
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4728 |
act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */ |
831 | 4729 |
sigemptyset(&act.sa_mask); |
4730 |
act.sa_handler = __signalTimerInterrupt; |
|
4731 |
sigaction(SIGALRM, &act, 0); |
|
4732 |
# else |
|
4733 |
# 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
|
4734 |
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
|
4735 |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4736 |
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
|
4737 |
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
|
4738 |
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
|
4739 |
sigvec(SIGALRM, &vec, NULL); |
831 | 4740 |
# else |
4741 |
signal(SIGALRM, __signalTimerInterrupt); |
|
4742 |
# endif |
|
4743 |
# endif |
|
4744 |
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
|
4745 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4746 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4747 |
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
|
4748 |
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
|
4749 |
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
|
4750 |
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
|
4751 |
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
|
4752 |
RETURN (true); |
831 | 4753 |
} |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4754 |
#else |
831 | 4755 |
# ifdef WIN32 |
4756 |
{ |
|
4757 |
/* |
|
4758 |
* two mechanisms - which one to use ? |
|
4759 |
*/ |
|
4760 |
# define USE_TimerProc |
|
4761 |
# ifdef USE_TimerProc |
|
4762 |
||
4763 |
extern VOID CALLBACK __win32TimerProc(HWND, UINT, UINT, DWORD); |
|
4764 |
SetTimer(NULL, 0, millis, __win32TimerProc); |
|
4765 |
||
4766 |
# else /* USE_TimeProc */ |
|
4767 |
||
4768 |
extern void CALLBACK __win32TimeProc(UINT, UINT, DWORD, DWORD, DWORD, DWORD); |
|
4769 |
timeSetEvent(millis, 5, __win32TimeProc, 0, TIME_ONESHOT); |
|
4770 |
# endif |
|
640
be94dfc60eaa
Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents:
630
diff
changeset
|
4771 |
} |
831 | 4772 |
# endif /* WIN32 */ |
4773 |
#endif /* ITIMER_REAL */ |
|
4774 |
%}. |
|
616 | 4775 |
^ false |
4776 |
! |
|
4777 |
||
1 | 4778 |
enableUserInterrupts |
4779 |
"enable userInterrupt (^C) handling; |
|
95 | 4780 |
when enabled, ^C in the terminal window will send the message |
4781 |
'userInterrupt' to the UserInterruptHandler object." |
|
1 | 4782 |
|
831 | 4783 |
self enableSignal:(self sigINT). |
4784 |
self enableSignal:(self sigBREAK). |
|
63 | 4785 |
! |
4786 |
||
616 | 4787 |
interruptPending |
4788 |
"return true, if an interrupt is pending. The returned value is |
|
4789 |
invalid if interrupts are not currently blocked, since otherwise |
|
4790 |
the interrupt is usually already handled before arriving here, |
|
4791 |
or may be served while returning from here." |
|
4792 |
||
4793 |
%{ /* NOCONTEXT */ |
|
4794 |
extern OBJ __INTERRUPTPENDING(); |
|
4795 |
||
4796 |
RETURN ( __INTERRUPTPENDING() ); |
|
4797 |
%} |
|
1 | 4798 |
! |
4799 |
||
704 | 4800 |
killProcess:processId |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
4801 |
"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
|
4802 |
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
|
4803 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4804 |
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
|
4805 |
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
|
4806 |
OperatingSystem>>getStatusOfProcess:aProcessId." |
704 | 4807 |
|
4808 |
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
|
4809 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
4810 |
"Modified: 28.12.1995 / 15:06:18 / stefan" |
704 | 4811 |
! |
4812 |
||
616 | 4813 |
nameForSignal:aSignalNumber |
4814 |
"for a given Unix signalnumber, return a descriptive string" |
|
4815 |
||
4816 |
aSignalNumber == self sigHUP ifTrue:[^ 'hangup']. |
|
4817 |
aSignalNumber == self sigINT ifTrue:[^ 'interrupt']. |
|
4818 |
aSignalNumber == self sigKILL ifTrue:[^ 'kill']. |
|
4819 |
aSignalNumber == self sigQUIT ifTrue:[^ 'quit']. |
|
4820 |
aSignalNumber == self sigILL ifTrue:[^ 'illegal instruction']. |
|
4821 |
aSignalNumber == self sigTRAP ifTrue:[^ 'trap']. |
|
4822 |
aSignalNumber == self sigABRT ifTrue:[^ 'abort']. |
|
4823 |
aSignalNumber == self sigIOT ifTrue:[^ 'iot trap']. |
|
4824 |
aSignalNumber == self sigEMT ifTrue:[^ 'emt trap']. |
|
4825 |
aSignalNumber == self sigFP ifTrue:[^ 'fp exception']. |
|
4826 |
aSignalNumber == self sigBUS ifTrue:[^ 'bus error']. |
|
4827 |
aSignalNumber == self sigSEGV ifTrue:[^ 'segmentation violation']. |
|
4828 |
aSignalNumber == self sigSYS ifTrue:[^ 'bad system call']. |
|
4829 |
aSignalNumber == self sigPIPE ifTrue:[^ 'broken pipe']. |
|
4830 |
aSignalNumber == self sigALRM ifTrue:[^ 'alarm timer']. |
|
4831 |
aSignalNumber == self sigTERM ifTrue:[^ 'termination']. |
|
4832 |
aSignalNumber == self sigSTOP ifTrue:[^ 'stop']. |
|
4833 |
aSignalNumber == self sigTSTP ifTrue:[^ 'tty stop']. |
|
4834 |
aSignalNumber == self sigCONT ifTrue:[^ 'continue']. |
|
4835 |
aSignalNumber == self sigCHLD ifTrue:[^ 'child death']. |
|
4836 |
aSignalNumber == self sigTTIN ifTrue:[^ 'background tty input']. |
|
4837 |
aSignalNumber == self sigTTOU ifTrue:[^ 'background tty output']. |
|
4838 |
aSignalNumber == self sigIO ifTrue:[^ 'io available']. |
|
4839 |
aSignalNumber == self sigXCPU ifTrue:[^ 'cpu time expired']. |
|
4840 |
aSignalNumber == self sigXFSZ ifTrue:[^ 'file size limit']. |
|
4841 |
aSignalNumber == self sigVTALRM ifTrue:[^ 'virtual alarm timer']. |
|
4842 |
aSignalNumber == self sigPROF ifTrue:[^ 'profiling timer']. |
|
4843 |
aSignalNumber == self sigWINCH ifTrue:[^ 'winsize changed']. |
|
4844 |
aSignalNumber == self sigLOST ifTrue:[^ 'resource lost']. |
|
4845 |
aSignalNumber == self sigUSR1 ifTrue:[^ 'user signal 1']. |
|
4846 |
aSignalNumber == self sigUSR2 ifTrue:[^ 'user signal 2']. |
|
4847 |
aSignalNumber == self sigMSG ifTrue:[^ 'HFT message']. |
|
4848 |
aSignalNumber == self sigPWR ifTrue:[^ 'power-fail']. |
|
4849 |
aSignalNumber == self sigPRE ifTrue:[^ 'programming exception']. |
|
4850 |
aSignalNumber == self sigGRANT ifTrue:[^ 'HFT access wanted']. |
|
4851 |
aSignalNumber == self sigRETRACT ifTrue:[^ 'HFT access relinquish']. |
|
4852 |
aSignalNumber == self sigSOUND ifTrue:[^ 'HFT sound complete']. |
|
4853 |
aSignalNumber == self sigDANGER ifTrue:[^ 'low on paging space']. |
|
4854 |
||
4855 |
"notice: many systems map SIGPOLL and/or SIGUSR onto SIGIO |
|
4856 |
therefore, keep SIGIO always above the two below" |
|
4857 |
aSignalNumber == self sigPOLL ifTrue:[^ 'io available']. |
|
4858 |
aSignalNumber == self sigURG ifTrue:[^ 'urgent']. |
|
4859 |
||
4860 |
^ 'unknown signal' |
|
4861 |
||
68 | 4862 |
" |
616 | 4863 |
OperatingSystem nameForSignal:9 |
4864 |
OperatingSystem nameForSignal:(OperatingSystem sigPOLL) |
|
68 | 4865 |
" |
616 | 4866 |
! |
4867 |
||
4868 |
operatingSystemSignal:signalNumber |
|
4869 |
"return the signal to be raised when an |
|
4870 |
operatingSystem-signal occurs, or nil" |
|
4871 |
||
4872 |
OSSignals notNil ifTrue:[ |
|
4873 |
^ OSSignals at:signalNumber ifAbsent:[nil] |
|
4874 |
]. |
|
4875 |
^ nil |
|
10 | 4876 |
! |
4877 |
||
616 | 4878 |
operatingSystemSignal:signalNumber install:aSignal |
4879 |
"install a signal to be raised when an operatingSystem-signal occurs" |
|
4880 |
||
4881 |
OSSignals isNil ifTrue:[ |
|
4882 |
OSSignals := Array new:32 |
|
4883 |
]. |
|
4884 |
OSSignals at:signalNumber put:aSignal |
|
4885 |
! |
|
4886 |
||
4887 |
sendSignal:signalNumber to:processId |
|
4888 |
"send a unix signal to some process (maybe myself). |
|
4889 |
Returns false if any error occurred, true otherwise. |
|
4890 |
||
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4891 |
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
|
4892 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4893 |
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
|
4894 |
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
|
4895 |
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
|
4896 |
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
|
4897 |
|
616 | 4898 |
%{ |
792 | 4899 |
#ifndef MSDOS_LIKE |
616 | 4900 |
if (__bothSmallInteger(signalNumber, processId)) { |
4901 |
if (kill(__intVal(processId), __intVal(signalNumber)) < 0) { |
|
1135 | 4902 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 4903 |
RETURN ( false ); |
216 | 4904 |
} |
616 | 4905 |
RETURN ( true ); |
10 | 4906 |
} |
792 | 4907 |
#endif |
68 | 4908 |
%}. |
792 | 4909 |
"/ |
4910 |
"/ either invalid argument (non-integers) |
|
4911 |
"/ or not supported by OS |
|
4912 |
"/ |
|
4913 |
^ self primitiveFailed |
|
1 | 4914 |
! |
4915 |
||
4916 |
startSpyTimer |
|
63 | 4917 |
"trigger a spyInterrupt, to be signalled after some short (virtual) time. |
359 | 4918 |
This is used by the old MessageTally for profiling. |
63 | 4919 |
Should be changed to use real profiling timer if available. |
68 | 4920 |
On systems, where no virtual timer is available, use the real timer |
359 | 4921 |
(which is of course less correct). |
4922 |
OBSOLETE: the new messageTally runs as a high prio process, not using |
|
4923 |
spy interrupts." |
|
1 | 4924 |
|
4925 |
%{ /* NOCONTEXT */ |
|
4926 |
||
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4927 |
#ifndef __spyInterrupt |
329 | 4928 |
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
|
4929 |
#endif |
10 | 4930 |
#if defined(ITIMER_VIRTUAL) |
1 | 4931 |
struct itimerval dt; |
4932 |
||
13 | 4933 |
# ifdef SIGVTALRM |
329 | 4934 |
signal(SIGVTALRM, __spyInterrupt); |
13 | 4935 |
# else |
329 | 4936 |
signal(SIGALRM, __spyInterrupt); |
13 | 4937 |
# endif |
4938 |
||
348 | 4939 |
dt.it_interval.tv_sec = 0; |
4940 |
dt.it_interval.tv_usec = 0; |
|
4941 |
dt.it_value.tv_sec = 0; |
|
4942 |
dt.it_value.tv_usec = 1000; /* 1000 Hz */ |
|
4943 |
setitimer(ITIMER_VIRTUAL, &dt, 0); |
|
4944 |
||
13 | 4945 |
RETURN (true); |
1 | 4946 |
#endif |
4947 |
%} |
|
13 | 4948 |
. |
4949 |
^ false |
|
1 | 4950 |
! |
4951 |
||
4952 |
stopSpyTimer |
|
359 | 4953 |
"stop spy timing - disable spy timer. |
4954 |
OBSOLETE: the new messageTally runs as a high prio process, not using |
|
4955 |
spy interrupts." |
|
1 | 4956 |
|
4957 |
%{ /* NOCONTEXT */ |
|
4958 |
||
10 | 4959 |
#if defined(ITIMER_VIRTUAL) |
1 | 4960 |
struct itimerval dt; |
4961 |
||
4962 |
dt.it_interval.tv_sec = 0; |
|
4963 |
dt.it_interval.tv_usec = 0; |
|
4964 |
dt.it_value.tv_sec = 0; |
|
4965 |
dt.it_value.tv_usec = 0; |
|
4966 |
setitimer(ITIMER_VIRTUAL, &dt, 0); |
|
13 | 4967 |
RETURN (true); |
10 | 4968 |
#endif |
4969 |
%} |
|
13 | 4970 |
. |
4971 |
^ false |
|
10 | 4972 |
! |
4973 |
||
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
4974 |
terminateProcess:processId |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
4975 |
"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
|
4976 |
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
|
4977 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4978 |
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
|
4979 |
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
|
4980 |
OperatingSystem>>getStatusOfProcess:aProcessId." |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
4981 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
4982 |
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
|
4983 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
4984 |
"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
|
4985 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
4986 |
|
616 | 4987 |
unblockInterrupts |
4988 |
"enable interrupt processing - if any interrupts are pending, |
|
4989 |
these will be handled immediately. |
|
4990 |
When unblocking interrupts, take care of nested block/unblock |
|
4991 |
calls - you must only unblock after a blockcall if they where |
|
4992 |
really not blocked before. See OperatingSystemclass>>blockInterrupts." |
|
4993 |
%{ |
|
4994 |
__UNBLOCKINTERRUPTS(); |
|
1040
60e4c4bbbca2
return nil from unblockInterrupts (thats what the inlined code returns)
Claus Gittinger <cg@exept.de>
parents:
1034
diff
changeset
|
4995 |
RETURN (nil); |
616 | 4996 |
%} |
4997 |
! ! |
|
4998 |
||
4999 |
!OperatingSystem class methodsFor:'misc'! |
|
5000 |
||
5001 |
exit |
|
710 | 5002 |
"shutdown smalltalk immediately - this method does not return. |
5003 |
Return 'good'-status (0) to the parent unix process." |
|
616 | 5004 |
|
5005 |
%{ /* NOCONTEXT */ |
|
5006 |
__mainExit(0); |
|
5007 |
%} |
|
5008 |
"OperatingSystem exit - dont evaluate this" |
|
5009 |
! |
|
5010 |
||
5011 |
exit:exitCode |
|
5012 |
"shutdown smalltalk immediately - |
|
5013 |
returning an exit-code to the parent unix process." |
|
5014 |
||
5015 |
%{ /* NOCONTEXT */ |
|
5016 |
int code = 1; |
|
5017 |
||
5018 |
if (__isSmallInteger(exitCode)) { |
|
1135 | 5019 |
code = __intVal(exitCode); |
616 | 5020 |
} |
5021 |
__mainExit(code); |
|
5022 |
%} |
|
5023 |
"OperatingSystem exit:1 - dont evaluate this" |
|
5024 |
! |
|
5025 |
||
5026 |
exitWithCoreDump |
|
5027 |
"shutdown smalltalk immediately - dumping core. |
|
5028 |
This always returns 'bad'-status to the parent unix process. |
|
5029 |
Notice, that no cleanup is performed at all - you may have to |
|
5030 |
manually remove any tempfiles. |
|
5031 |
Use this only for debugging ST/X itself" |
|
5032 |
||
5033 |
%{ /* NOCONTEXT */ |
|
5034 |
abort(); |
|
5035 |
%} |
|
831 | 5036 |
" |
5037 |
OperatingSystem exitWithCoreDump - dont evaluate this |
|
5038 |
" |
|
616 | 5039 |
! |
5040 |
||
5041 |
slowFork:aBoolean |
|
5042 |
SlowFork := aBoolean |
|
5043 |
! ! |
|
5044 |
||
5045 |
!OperatingSystem class methodsFor:'os queries'! |
|
5046 |
||
5047 |
getCPUDefine |
|
831 | 5048 |
"return a string which was used to identify this CPU type when STX was |
616 | 5049 |
compiled, and which should be passed down when compiling methods. |
831 | 5050 |
For example, on linux, this may be '-Di386'; on a vax, this would be '-Dvax'. |
5051 |
This is normally not of interest to 'normal' users; however, it is passed |
|
5052 |
down to the c-compiler when methods are incrementally compiled to machine code." |
|
616 | 5053 |
|
5054 |
%{ /* NOCONTEXT */ |
|
831 | 5055 |
# ifndef CPU_DEFINE |
5056 |
# define CPU_DEFINE "-DunknownCPU" |
|
5057 |
# endif |
|
5058 |
||
616 | 5059 |
RETURN ( __MKSTRING(CPU_DEFINE COMMA_CON)); |
5060 |
%} |
|
5061 |
" |
|
5062 |
OperatingSystem getCPUDefine |
|
5063 |
" |
|
5064 |
! |
|
5065 |
||
5066 |
getCPUType |
|
5067 |
"return a string giving the type of machine we're running on. |
|
831 | 5068 |
Here, the machine for which ST/X was compiled is returned |
5069 |
(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
|
5070 |
This may normally not be of any interest to you ..." |
616 | 5071 |
|
5072 |
|cpu| |
|
5073 |
||
5074 |
%{ /* NOCONTEXT */ |
|
5075 |
||
5076 |
# ifdef vax |
|
5077 |
# define CPU_STRING "vax" |
|
5078 |
# endif |
|
5079 |
# ifdef mips |
|
5080 |
# define CPU_STRING "mips" |
|
5081 |
# endif |
|
5082 |
# ifdef i386 |
|
5083 |
# define CPU_STRING "i386" |
|
5084 |
# endif |
|
5085 |
# ifdef ns32k |
|
5086 |
# define CPU_STRING "ns32k" |
|
5087 |
# endif |
|
5088 |
# ifdef mc68k |
|
5089 |
# define CPU_STRING "mc68k" |
|
5090 |
# endif |
|
5091 |
# ifdef mc88k |
|
5092 |
# define CPU_STRING "mc88k" |
|
5093 |
# endif |
|
5094 |
# ifdef sparc |
|
5095 |
# define CPU_STRING "sparc" |
|
5096 |
# endif |
|
5097 |
# ifdef hppa |
|
5098 |
# define CPU_STRING "hppa" |
|
5099 |
# endif |
|
5100 |
# ifdef rs6000 |
|
5101 |
# define CPU_STRING "rs6000" |
|
5102 |
# endif |
|
831 | 5103 |
# ifdef powerPC |
5104 |
# define CPU_STRING "powerPC" |
|
5105 |
# endif |
|
616 | 5106 |
# ifdef alpha |
5107 |
# define CPU_STRING "alpha" |
|
5108 |
# endif |
|
5109 |
# ifdef transputer |
|
5110 |
# define CPU_STRING "transputer" |
|
5111 |
# endif |
|
5112 |
# ifdef ibm370 |
|
5113 |
# define CPU_STRING "ibm370" |
|
5114 |
# endif |
|
5115 |
||
5116 |
# ifndef CPU_STRING |
|
5117 |
# define CPU_STRING "unknown" |
|
5118 |
# endif |
|
5119 |
||
830 | 5120 |
cpu = __MKSTRING(CPU_STRING COMMA_CON); |
616 | 5121 |
# undef CPU_STRING |
831 | 5122 |
%}. |
616 | 5123 |
^ cpu |
5124 |
||
5125 |
" |
|
5126 |
OperatingSystem getCPUType |
|
5127 |
" |
|
5128 |
||
5129 |
"examples: are we running on a ss-10/solaris ?" |
|
5130 |
" |
|
5131 |
(OperatingSystem getCPUType = 'sparc') |
|
5132 |
and:[OperatingSystem getOSType = 'solaris'] |
|
5133 |
" |
|
5134 |
||
5135 |
"or on a pc/solaris ?" |
|
5136 |
" |
|
5137 |
(OperatingSystem getCPUType = 'i386') |
|
5138 |
and:[OperatingSystem getOSType = 'solaris'] |
|
5139 |
" |
|
5140 |
! |
|
5141 |
||
5142 |
getCommandOutputFrom:aCommand |
|
5143 |
"execute a simple command (such as hostname) and |
|
5144 |
return the commands output as a string" |
|
5145 |
||
5146 |
|p result| |
|
5147 |
||
5148 |
ForkFailed ifFalse:[ |
|
5149 |
PipeStream openErrorSignal handle:[:ex | |
|
5150 |
ForkFailed := true. |
|
5151 |
'OS: cannot fork/popen' errorPrintNL. |
|
5152 |
ex return. |
|
5153 |
] do:[ |
|
5154 |
p := PipeStream readingFrom:aCommand. |
|
5155 |
p notNil ifTrue:[ |
|
5156 |
result := p nextLine. |
|
5157 |
p close |
|
5158 |
] |
|
5159 |
] |
|
5160 |
]. |
|
5161 |
^ result |
|
5162 |
! |
|
5163 |
||
5164 |
getDomainName |
|
5165 |
"return the domain this host is in. |
|
5166 |
Notice: |
|
5167 |
not all systems support this; on some, 'unknown' is returned." |
|
5168 |
||
5169 |
|name| |
|
5170 |
||
5171 |
DomainName notNil ifTrue:[ |
|
5172 |
^ DomainName |
|
5173 |
]. |
|
5174 |
||
5175 |
%{ /* STACK: 2048 */ |
|
5176 |
#if defined(HAS_GETDOMAINNAME) |
|
5177 |
char buffer[128]; |
|
5178 |
||
5179 |
if (getdomainname(buffer, sizeof(buffer)) == 0) { |
|
830 | 5180 |
name = __MKSTRING(buffer COMMA_CON); |
616 | 5181 |
} |
5182 |
#else |
|
5183 |
# if defined(HAS_UNAME) && defined(HAS_UTS_DOMAINNAME) |
|
5184 |
struct utsname ubuff; |
|
5185 |
||
5186 |
if (uname(&ubuff) >= 0) { |
|
830 | 5187 |
name = __MKSTRING(ubuff.domainname COMMA_CON); |
616 | 5188 |
} |
5189 |
# endif |
|
5190 |
#endif |
|
5191 |
%}. |
|
5192 |
name isNil ifTrue:[ |
|
5193 |
name := self getEnvironment:'DOMAIN'. |
|
5194 |
name isNil ifTrue:[ |
|
5195 |
name := self getCommandOutputFrom:'domainname' |
|
5196 |
] |
|
5197 |
]. |
|
5198 |
name isNil ifTrue:[ |
|
5199 |
'OS: cannot find out domainname' errorPrintNL. |
|
5200 |
name := 'unknown'. |
|
5201 |
]. |
|
5202 |
DomainName := name. |
|
5203 |
^ name |
|
5204 |
||
5205 |
" |
|
5206 |
OperatingSystem getDomainName |
|
5207 |
" |
|
5208 |
! |
|
5209 |
||
5210 |
getEnvironment:aStringOrSymbol |
|
5211 |
"get an environment string" |
|
10 | 5212 |
|
5213 |
%{ /* NOCONTEXT */ |
|
5214 |
||
616 | 5215 |
char *env; |
5216 |
||
5217 |
if (__isString(aStringOrSymbol) || __isSymbol(aStringOrSymbol)) { |
|
1135 | 5218 |
env = (char *)getenv(__stringVal(aStringOrSymbol)); |
616 | 5219 |
if (env) { |
830 | 5220 |
RETURN ( __MKSTRING(env COMMA_CON) ); |
616 | 5221 |
} |
5222 |
} |
|
5223 |
%} |
|
5224 |
. |
|
5225 |
^ nil |
|
5226 |
||
5227 |
" |
|
5228 |
OperatingSystem getEnvironment:'LANG' |
|
5229 |
OperatingSystem getEnvironment:'LOGIN' |
|
5230 |
OperatingSystem getEnvironment:'HOME' |
|
5231 |
OperatingSystem getEnvironment:'NNTPSERVER' |
|
5232 |
OperatingSystem getEnvironment:'MAIL' |
|
5233 |
OperatingSystem getEnvironment:'PATH' |
|
5234 |
" |
|
5235 |
! |
|
5236 |
||
5237 |
getHostName |
|
5238 |
"return the hostname we are running on - if there is |
|
5239 |
a HOST environment variable, we are much faster here ... |
|
5240 |
Notice: |
|
5241 |
not all systems support this; on some, 'unknown' is returned." |
|
5242 |
||
5243 |
|name| |
|
5244 |
||
5245 |
HostName notNil ifTrue:[ |
|
5246 |
^ HostName |
|
5247 |
]. |
|
5248 |
||
5249 |
%{ /* STACK: 2048 */ |
|
5250 |
#if defined(HAS_GETHOSTNAME) |
|
5251 |
char buffer[128]; |
|
5252 |
||
5253 |
if (gethostname(buffer, sizeof(buffer)) == 0) { |
|
830 | 5254 |
name = __MKSTRING(buffer COMMA_CON); |
616 | 5255 |
} |
5256 |
#else |
|
5257 |
# if defined(HAS_UNAME) |
|
5258 |
struct utsname ubuff; |
|
5259 |
||
5260 |
if (uname(&ubuff) >= 0) { |
|
830 | 5261 |
name = __MKSTRING(ubuff.nodename COMMA_CON); |
616 | 5262 |
} |
831 | 5263 |
# else |
5264 |
# ifdef WIN32 |
|
5265 |
char buffer[128]; |
|
5266 |
int buffSize = sizeof(buffer); |
|
5267 |
||
5268 |
if (GetComputerName(buffer, &buffSize) == TRUE) { |
|
1135 | 5269 |
name = __MKSTRING(buffer COMMA_CON); |
831 | 5270 |
} |
5271 |
# endif |
|
1 | 5272 |
# endif |
616 | 5273 |
#endif |
5274 |
%}. |
|
5275 |
name isNil ifTrue:[ |
|
5276 |
name := self getEnvironment:'HOST'. |
|
5277 |
name isNil ifTrue:[ |
|
5278 |
name := self getCommandOutputFrom:'hostname' |
|
5279 |
] |
|
5280 |
]. |
|
5281 |
name isNil ifTrue:[ |
|
5282 |
'OS: cannot find out hostname' errorPrintNL. |
|
5283 |
name := 'unknown'. |
|
5284 |
]. |
|
5285 |
HostName := name. |
|
5286 |
^ name |
|
5287 |
||
5288 |
" |
|
5289 |
OperatingSystem getHostName |
|
5290 |
" |
|
5291 |
! |
|
5292 |
||
1034 | 5293 |
getLocaleInfo |
5294 |
"return a dictionary filled with values from the locale information; |
|
5295 |
Not all fields may be present, depending on the OS's setup and capabilities. |
|
5296 |
Possible fields are: |
|
5297 |
decimalPoint <String> |
|
5298 |
||
5299 |
thousandsSep <String> |
|
5300 |
||
5301 |
internationalCurrencySymbol <String> |
|
5302 |
||
5303 |
currencySymbol <String> |
|
5304 |
||
5305 |
monetaryDecimalPoint <String> |
|
5306 |
||
5307 |
monetaryThousandsSeparator <String> |
|
5308 |
||
5309 |
positiveSign <String> |
|
5310 |
||
5311 |
negativeSign <String> |
|
5312 |
||
5313 |
internationalFractionalDigits <Integer> |
|
5314 |
||
5315 |
fractionalDigits <Integer> |
|
5316 |
||
5317 |
positiveSignPrecedesCurrencySymbol <Boolean> |
|
5318 |
||
5319 |
negativeSignPrecedesCurrencySymbol <Boolean> |
|
5320 |
||
5321 |
positiveSignSeparatedBySpaceFromCurrencySymbol <Boolean> |
|
5322 |
||
5323 |
negativeSignSeparatedBySpaceFromCurrencySymbol <Boolean> |
|
5324 |
||
5325 |
positiveSignPosition <Symbol> |
|
5326 |
one of: #parenthesesAround, |
|
5327 |
#signPrecedes, |
|
5328 |
#signSuceeds, |
|
5329 |
#signPrecedesCurrencySymbol, |
|
5330 |
#signSuceedsCurrencySymbol |
|
5331 |
||
5332 |
negativeSignPosition <like above> |
|
5333 |
||
5334 |
it is up to the application to deal with undefined values. |
|
5335 |
||
5336 |
Notice, that (for now), the system does not use this information; |
|
5337 |
it should be used by applications as required. |
|
5338 |
" |
|
5339 |
||
5340 |
|info val| |
|
5341 |
||
5342 |
LocaleInfo notNil ifTrue:[ |
|
5343 |
"/ return the internal info; useful on systems which do not |
|
5344 |
"/ support this. |
|
5345 |
^ LocaleInfo |
|
5346 |
]. |
|
5347 |
||
5348 |
info := IdentityDictionary new. |
|
5349 |
%{ |
|
5350 |
char *decimalPoint; /* something like "." (US) or "," (german) */ |
|
5351 |
char *thousandsSep; /* something like "," (US) or "." (german) */ |
|
5352 |
char *intCurrencySymbol; /* international currency symbol; something like "USD " "DM " */ |
|
5353 |
char *currencySymbol; /* local currency symbol; something like "USD " "DM " */ |
|
5354 |
char *monDecimalPoint; /* money: decimal point */ |
|
5355 |
char *monThousandsSep; /* money: thousands sep */ |
|
5356 |
char *positiveSign; |
|
5357 |
char *negativeSign; |
|
5358 |
int intFractDigits; /* money: international digits after decPoint */ |
|
5359 |
int fractDigits; /* money: local digits after decPoint */ |
|
5360 |
int csPosPrecedes; /* money: 1 if currency symbol precedes a positive value; 0 if it sceeds */ |
|
5361 |
int csNegPrecedes; /* money: 1 if currency symbol precedes a negative value; 0 if it sceeds */ |
|
5362 |
int csPosSepBySpace; /* money: 1 if currency symbol should be separated by a space from a positive value; 0 if no space */ |
|
5363 |
int csNegSepBySpace; /* money: 1 if currency symbol should be separated by a space from a negative value; 0 if no space */ |
|
5364 |
int csPosSignPosition; /* money: 0: ()'s around the value & currency symbol */ |
|
5365 |
int csNegSignPosition; /* 1: sign precedes the value & currency symbol */ |
|
5366 |
/* 2: sign succeeds the value & currency symbol */ |
|
5367 |
/* 3: sign immediately precedes the currency symbol */ |
|
5368 |
/* 4: sign immediately suceeds the currency symbol */ |
|
5369 |
||
5370 |
#if defined(HAS_LOCALECONV) |
|
5371 |
struct lconv *conf; |
|
5372 |
||
5373 |
conf = localeconv(); |
|
5374 |
if (conf) { |
|
5375 |
decimalPoint = conf->decimal_point; |
|
5376 |
thousandsSep = conf->thousands_sep; |
|
5377 |
intCurrencySymbol = conf->int_curr_symbol; |
|
5378 |
currencySymbol = conf->currency_symbol; |
|
5379 |
monDecimalPoint = conf->mon_decimal_point; |
|
5380 |
monThousandsSep = conf->mon_thousands_sep; |
|
5381 |
positiveSign = conf->positive_sign; |
|
5382 |
negativeSign = conf->negative_sign; |
|
5383 |
intFractDigits = conf->int_frac_digits; |
|
5384 |
fractDigits = conf->frac_digits; |
|
5385 |
csPosPrecedes = conf->p_cs_precedes; |
|
5386 |
csNegPrecedes = conf->n_cs_precedes; |
|
5387 |
csPosSepBySpace = conf->p_sep_by_space; |
|
5388 |
csNegSepBySpace = conf->n_sep_by_space; |
|
5389 |
csPosSignPosition = conf->p_sign_posn; |
|
5390 |
csNegSignPosition = conf->n_sign_posn; |
|
5391 |
} |
|
5392 |
#else |
|
5393 |
decimalPoint = (char *)0; |
|
5394 |
thousandsSep = (char *)0; |
|
5395 |
intCurrencySymbol = (char *)0; |
|
5396 |
currencySymbol = (char *)0; |
|
5397 |
monDecimalPoint = (char *)0; |
|
5398 |
monThousandsSep = (char *)0; |
|
5399 |
positiveSign = (char *)0; |
|
5400 |
negativeSign =(char *)0; |
|
5401 |
intFractDigits = -1; |
|
5402 |
fractDigits = -1; |
|
5403 |
csPosPrecedes = -1; |
|
5404 |
csNegPrecedes = -1; |
|
5405 |
csPosSepBySpace = -1; |
|
5406 |
csNegSepBySpace = -1; |
|
5407 |
csPosSignPosition = -1; |
|
5408 |
csNegSignPosition = -1; |
|
5409 |
#endif |
|
5410 |
if (decimalPoint) { |
|
5411 |
val = __MKSTRING(decimalPoint); |
|
5412 |
__AT_PUT_(info, @symbol(decimalPoint), val); |
|
5413 |
} |
|
5414 |
if (thousandsSep) { |
|
5415 |
val = __MKSTRING(thousandsSep); |
|
5416 |
__AT_PUT_(info, @symbol(thousandsSeparator), val); |
|
5417 |
} |
|
5418 |
if (intCurrencySymbol) { |
|
5419 |
val = __MKSTRING(intCurrencySymbol); |
|
5420 |
__AT_PUT_(info, @symbol(internationCurrencySymbol), val); |
|
5421 |
} |
|
5422 |
if (currencySymbol) { |
|
5423 |
val = __MKSTRING(currencySymbol); |
|
5424 |
__AT_PUT_(info, @symbol(currencySymbol), val); |
|
5425 |
} |
|
5426 |
if (monDecimalPoint) { |
|
5427 |
val = __MKSTRING(monDecimalPoint); |
|
5428 |
__AT_PUT_(info, @symbol(monetaryDecimalPoint), val); |
|
5429 |
} |
|
5430 |
if (monThousandsSep) { |
|
5431 |
val = __MKSTRING(monThousandsSep); |
|
5432 |
__AT_PUT_(info, @symbol(monetaryThousandsSeparator), val); |
|
5433 |
} |
|
5434 |
if (positiveSign) { |
|
5435 |
val = __MKSTRING(positiveSign); |
|
5436 |
__AT_PUT_(info, @symbol(positiveSign), val); |
|
5437 |
} |
|
5438 |
if (negativeSign) { |
|
5439 |
val = __MKSTRING(negativeSign); |
|
5440 |
__AT_PUT_(info, @symbol(negativeSign), val); |
|
5441 |
} |
|
5442 |
if (intFractDigits >= 0) { |
|
5443 |
__AT_PUT_(info, @symbol(internationalFractionalDigits), __MKSMALLINT(intFractDigits)); |
|
5444 |
} |
|
5445 |
if (fractDigits >= 0) { |
|
5446 |
__AT_PUT_(info, @symbol(fractionalDigits), __MKSMALLINT(fractDigits)); |
|
5447 |
} |
|
5448 |
if (csPosPrecedes >= 0) { |
|
5449 |
if (csPosPrecedes == 0) { |
|
5450 |
val = false; |
|
5451 |
} else { |
|
5452 |
val = true; |
|
5453 |
} |
|
5454 |
__AT_PUT_(info, @symbol(positiveSignPrecedesCurrencySymbol), val ); |
|
5455 |
} |
|
5456 |
if (csNegPrecedes >= 0) { |
|
5457 |
if (csNegPrecedes == 0) { |
|
5458 |
val = false; |
|
5459 |
} else { |
|
5460 |
val = true; |
|
5461 |
} |
|
5462 |
__AT_PUT_(info, @symbol(negativeSignPrecedesCurrencySymbol), val ); |
|
5463 |
} |
|
5464 |
if (csPosSepBySpace >= 0) { |
|
5465 |
if (csPosSepBySpace == 0) { |
|
5466 |
val = false; |
|
5467 |
} else { |
|
5468 |
val = true; |
|
5469 |
} |
|
5470 |
__AT_PUT_(info, @symbol(positiveSignSeparatedBySpaceFromCurrencySymbol), val); |
|
5471 |
} |
|
5472 |
if (csNegSepBySpace >= 0) { |
|
5473 |
if (csNegSepBySpace == 0) { |
|
5474 |
val = false; |
|
5475 |
} else { |
|
5476 |
val = true; |
|
5477 |
} |
|
5478 |
__AT_PUT_(info, @symbol(negativeSignSeparatedBySpaceFromCurrencySymbol), val); |
|
5479 |
} |
|
5480 |
switch (csPosSignPosition) { |
|
5481 |
case 0: |
|
5482 |
val = @symbol(parenthesesAround); |
|
5483 |
break; |
|
5484 |
||
5485 |
case 1: |
|
5486 |
val = @symbol(signPrecedes); |
|
5487 |
break; |
|
5488 |
||
5489 |
case 2: |
|
5490 |
val = @symbol(signSuceeds); |
|
5491 |
break; |
|
5492 |
||
5493 |
case 3: |
|
5494 |
val = @symbol(signPrecedesCurrencySymbol); |
|
5495 |
break; |
|
5496 |
||
5497 |
case 4: |
|
5498 |
val = @symbol(signSuceedsCurrencySymbol); |
|
5499 |
break; |
|
5500 |
||
5501 |
default: |
|
5502 |
val = nil; |
|
5503 |
} |
|
5504 |
if (val != nil) { |
|
5505 |
__AT_PUT_(info, @symbol(positiveSignPosition), val); |
|
5506 |
} |
|
5507 |
||
5508 |
switch (csNegSignPosition) { |
|
5509 |
case 0: |
|
5510 |
val = @symbol(parenthesesAround); |
|
5511 |
break; |
|
5512 |
||
5513 |
case 1: |
|
5514 |
val = @symbol(signPrecedes); |
|
5515 |
break; |
|
5516 |
||
5517 |
case 2: |
|
5518 |
val = @symbol(signSuceeds); |
|
5519 |
break; |
|
5520 |
||
5521 |
case 3: |
|
5522 |
val = @symbol(signPrecedesCurrencySymbol); |
|
5523 |
break; |
|
5524 |
||
5525 |
case 4: |
|
5526 |
val = @symbol(signSuceedsCurrencySymbol); |
|
5527 |
break; |
|
5528 |
||
5529 |
default: |
|
5530 |
val = nil; |
|
5531 |
} |
|
5532 |
if (val != nil) { |
|
5533 |
__AT_PUT_(info, @symbol(negativeSignPosition), val); |
|
5534 |
} |
|
5535 |
%}. |
|
5536 |
^ info |
|
5537 |
||
5538 |
" |
|
5539 |
OperatingSystem getLocaleInfo |
|
5540 |
" |
|
5541 |
||
5542 |
"Created: 23.12.1995 / 14:19:20 / cg" |
|
5543 |
! |
|
5544 |
||
616 | 5545 |
getOSDefine |
5546 |
"return a string which was used to identify this machine when stx was |
|
5547 |
compiled, and which should be passed down when compiling methods. |
|
5548 |
For example, on linux, this is '-DLINUX'." |
|
5549 |
||
5550 |
%{ /* NOCONTEXT */ |
|
831 | 5551 |
#ifdef WIN32 |
5552 |
# ifndef OS_DEFINE |
|
5553 |
# define OS_DEFINE "-DWIN32" |
|
5554 |
# endif |
|
5555 |
#endif |
|
5556 |
||
616 | 5557 |
#ifndef OS_DEFINE |
5558 |
# define OS_DEFINE "-DunknownOS" |
|
5559 |
#endif |
|
831 | 5560 |
|
616 | 5561 |
RETURN ( __MKSTRING(OS_DEFINE COMMA_CON)); |
5562 |
%} |
|
5563 |
" |
|
5564 |
OperatingSystem getOSDefine |
|
5565 |
" |
|
5566 |
! |
|
5567 |
||
5568 |
getOSType |
|
5569 |
"return a string giving the type of OS we're running on. |
|
5570 |
This can be used to adapt programs to certain environment |
|
5571 |
differences (for example: mail-lock strategy ...)" |
|
5572 |
||
5573 |
|os| |
|
5574 |
||
5575 |
%{ /* NOCONTEXT */ |
|
5576 |
||
5577 |
# ifdef MSDOS |
|
5578 |
# define OS_STRING "msdos" |
|
5579 |
# endif |
|
5580 |
||
831 | 5581 |
# ifdef WIN32 |
5582 |
char *OS_STRING = "win32"; |
|
5583 |
||
5584 |
# endif |
|
5585 |
||
616 | 5586 |
# ifdef MSWINDOWS |
5587 |
# define OS_STRING "mswindows" |
|
5588 |
# endif |
|
5589 |
||
5590 |
# ifdef NT |
|
5591 |
# define OS_STRING "nt" |
|
5592 |
# endif |
|
5593 |
||
5594 |
# ifdef VMS |
|
5595 |
# define OS_STRING "vms" |
|
5596 |
# endif |
|
5597 |
||
5598 |
# ifdef MVS |
|
5599 |
# define OS_STRING "mvs" |
|
5600 |
# endif |
|
5601 |
||
5602 |
# ifdef OS2 |
|
5603 |
# define OS_STRING "os2" |
|
5604 |
# endif |
|
5605 |
||
5606 |
# ifdef sinix |
|
5607 |
# define OS_STRING "sinix" |
|
5608 |
# endif |
|
5609 |
||
5610 |
# ifdef ultrix |
|
5611 |
# define OS_STRING "ultrix" |
|
5612 |
# endif |
|
5613 |
||
5614 |
# ifdef sco |
|
5615 |
# define OS_STRING "sco" |
|
5616 |
# endif |
|
5617 |
||
5618 |
# ifdef hpux |
|
5619 |
# define OS_STRING "hpux" |
|
5620 |
# endif |
|
5621 |
||
5622 |
# ifdef LINUX |
|
5623 |
# define OS_STRING "linux" |
|
5624 |
# endif |
|
5625 |
||
5626 |
# ifdef sunos |
|
5627 |
# define OS_STRING "sunos" |
|
5628 |
# endif |
|
5629 |
||
5630 |
# ifdef solaris |
|
5631 |
# define OS_STRING "solaris" |
|
5632 |
# endif |
|
5633 |
||
5634 |
# ifdef IRIS |
|
5635 |
# define OS_STRING "irix" |
|
5636 |
# endif |
|
5637 |
||
5638 |
# ifdef aix |
|
5639 |
# define OS_STRING "aix" |
|
5640 |
# endif |
|
5641 |
||
5642 |
# ifdef realIX |
|
5643 |
# define OS_STRING "realIX" |
|
5644 |
# endif |
|
5645 |
||
5646 |
/* |
|
5647 |
* no concrete info; become somewhat vague ... |
|
5648 |
*/ |
|
5649 |
# ifndef OS_STRING |
|
5650 |
# ifdef MACH |
|
5651 |
# define OS_STRING "mach" |
|
5652 |
# endif |
|
5653 |
# endif |
|
5654 |
||
5655 |
# ifndef OS_STRING |
|
5656 |
# ifdef BSD |
|
5657 |
# define OS_STRING "bsd" |
|
5658 |
# endif |
|
5659 |
||
5660 |
# ifdef SYSV |
|
5661 |
# ifdef SYSV3 |
|
5662 |
# define OS_STRING "sys5_3" |
|
5663 |
# else |
|
5664 |
# ifdef SYSV4 |
|
5665 |
# define OS_STRING "sys5_4" |
|
5666 |
# else |
|
5667 |
# define OS_STRING "sys5" |
|
5668 |
# endif |
|
5669 |
# endif |
|
5670 |
# endif |
|
5671 |
# endif |
|
5672 |
||
5673 |
/* |
|
5674 |
* become very vague ... |
|
5675 |
*/ |
|
5676 |
# ifndef OS_STRING |
|
5677 |
# ifdef POSIX |
|
5678 |
# define OS_STRING "posix" |
|
5679 |
# endif |
|
5680 |
# endif |
|
5681 |
# ifndef OS_STRING |
|
5682 |
# ifdef UNIX |
|
5683 |
# define OS_STRING "unix" |
|
5684 |
# endif |
|
5685 |
# endif |
|
5686 |
||
5687 |
# ifndef OS_STRING |
|
5688 |
# define OS_STRING "unknown" |
|
5689 |
# endif |
|
5690 |
||
830 | 5691 |
os = __MKSTRING(OS_STRING COMMA_CON); |
616 | 5692 |
# undef OS_STRING |
831 | 5693 |
%}. |
616 | 5694 |
^ os |
5695 |
||
5696 |
"OperatingSystem getOSType" |
|
5697 |
! |
|
5698 |
||
5699 |
getProcessId |
|
5700 |
"return the (unix-)processId" |
|
5701 |
||
5702 |
%{ /* NOCONTEXT */ |
|
5703 |
||
5704 |
int pid = 0; |
|
5705 |
#ifdef UNIX_LIKE |
|
5706 |
pid = getpid(); |
|
5707 |
#endif |
|
1135 | 5708 |
RETURN ( __MKSMALLINT(pid) ); |
616 | 5709 |
%} |
5710 |
" |
|
5711 |
OperatingSystem getProcessId |
|
5712 |
" |
|
5713 |
! |
|
5714 |
||
5715 |
getSystemID |
|
5716 |
"if supported by the OS, return the systemID; |
|
5717 |
a unique per machine identification. |
|
5718 |
WARNING: |
|
5719 |
not all systems support this; on some, 'unknown' is returned." |
|
5720 |
||
5721 |
%{ /* NO_CONTEXT */ |
|
5722 |
#if defined(IRIX5) && !defined(HAS_GETHOSTID) |
|
5723 |
char idBuffer[MAXSYSIDSIZE]; |
|
5724 |
int retVal; |
|
5725 |
OBJ arr; |
|
5726 |
||
5727 |
if ((retVal = syssgi(SGI_SYSID, idBuffer)) == 0) { |
|
5728 |
arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(MAXSYSIDSIZE); |
|
5729 |
bcopy(idBuffer, __ByteArrayInstPtr(arr)->ba_element, MAXSYSIDSIZE); |
|
5730 |
RETURN (arr); |
|
5731 |
} |
|
5732 |
#endif |
|
5733 |
#if defined(HAS_GETHOSTID) |
|
5734 |
int runningId; |
|
5735 |
OBJ arr; |
|
5736 |
||
5737 |
runningId = gethostid(); |
|
5738 |
arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(4); |
|
5739 |
*(int *)(__ByteArrayInstPtr(arr)->ba_element) = runningId; |
|
5740 |
RETURN (arr); |
|
5741 |
#endif |
|
5742 |
%}. |
|
5743 |
^ 'unknown' |
|
5744 |
||
5745 |
" |
|
5746 |
OperatingSystem getSystemID |
|
5747 |
" |
|
5748 |
! |
|
5749 |
||
5750 |
getSystemInfo |
|
831 | 5751 |
"return info on the system weare running on. |
5752 |
If the system supports the uname system call, that info is returned; |
|
616 | 5753 |
otherwise, some simulated info is returned. |
831 | 5754 |
|
616 | 5755 |
WARNING: |
831 | 5756 |
Do not depend on the amount and contents of the returned information, some |
5757 |
systems may return more/less than others. Also, the contents depends on the |
|
5758 |
OS, for example, linux returns 'ix86', while WIN32 returns 'x86'. |
|
5759 |
||
5760 |
This method is mainly provided to augment error reports with some system |
|
5761 |
information. |
|
5762 |
(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
|
5763 |
may be based upon this info) |
616 | 5764 |
|
5765 |
The returned info may (or may not) contain: |
|
831 | 5766 |
#system -> some operating system identification (irix, Linux, nt, win32s ...) |
5767 |
#version -> OS version (some os version identification) |
|
5768 |
#release -> OS release (3.5, 1.2.1 ...) |
|
5769 |
#node -> some host identification (hostname) |
|
5770 |
#domain -> domain name (hosts domain) |
|
5771 |
#machine -> type of machine (i586, mips ...) |
|
616 | 5772 |
" |
5773 |
||
5774 |
|sys node rel ver mach dom mtyp brel info| |
|
5775 |
||
1060
119d45f975e1
increased getSystemInfos stack - just to make certain
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
5776 |
%{ /* STACK: 4096 */ |
616 | 5777 |
#if defined(HAS_UNAME) |
5778 |
struct utsname ubuff; |
|
5779 |
||
5780 |
if (uname(&ubuff) >= 0) { |
|
830 | 5781 |
sys = __MKSTRING(ubuff.sysname COMMA_CON); |
5782 |
node = __MKSTRING(ubuff.nodename COMMA_CON); |
|
5783 |
rel = __MKSTRING(ubuff.release COMMA_CON); |
|
5784 |
ver = __MKSTRING(ubuff.version COMMA_CON); |
|
5785 |
mach = __MKSTRING(ubuff.machine COMMA_CON); |
|
616 | 5786 |
# ifdef HAS_UTS_DOMAINNAME |
830 | 5787 |
dom = __MKSTRING(ubuff.domainname COMMA_CON); |
616 | 5788 |
# endif |
5789 |
} |
|
831 | 5790 |
#else /* no uname */ |
5791 |
# ifdef WIN32 |
|
5792 |
||
5793 |
char vsnBuffer[32]; |
|
5794 |
char *s; |
|
5795 |
int winVer; |
|
5796 |
DWORD vsn; |
|
5797 |
SYSTEM_INFO sysInfo; |
|
5798 |
||
5799 |
vsn = GetVersion(); |
|
5800 |
||
5801 |
if (HIWORD(vsn) & 0x8000) { |
|
5802 |
s = "win32s"; |
|
5803 |
} else { |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5804 |
s = "nt"; |
831 | 5805 |
} |
5806 |
sys = __MKSTRING(s COMMA_CON); |
|
5807 |
winVer = LOWORD(vsn); |
|
5808 |
sprintf(vsnBuffer, "%d.%d", LOBYTE(winVer), HIBYTE(winVer)); |
|
5809 |
rel = __MKSTRING(vsnBuffer COMMA_CON); |
|
5810 |
||
5811 |
GetSystemInfo(&sysInfo); |
|
5812 |
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
|
5813 |
sprintf(vsnBuffer, "%d", sysInfo.dwProcessorType); |
831 | 5814 |
mach = __MKSTRING(vsnBuffer COMMA_CON); |
5815 |
} |
|
5816 |
||
5817 |
# endif /* WIN32 */ |
|
5818 |
#endif /* no uname */ |
|
616 | 5819 |
%}. |
5820 |
sys isNil ifTrue:[ |
|
5821 |
sys := self getSystemType. |
|
5822 |
]. |
|
5823 |
node isNil ifTrue:[ |
|
5824 |
node := self getHostName |
|
5825 |
]. |
|
5826 |
dom isNil ifTrue:[ |
|
5827 |
dom := self getDomainName |
|
5828 |
]. |
|
831 | 5829 |
mach isNil ifTrue:[ |
5830 |
mach := self getCPUType |
|
5831 |
]. |
|
616 | 5832 |
|
5833 |
info := IdentityDictionary new. |
|
5834 |
info at:#system put:sys. |
|
5835 |
info at:#node put:node. |
|
5836 |
rel notNil ifTrue:[info at:#release put:rel]. |
|
5837 |
ver notNil ifTrue:[info at:#version put:ver]. |
|
5838 |
mach notNil ifTrue:[info at:#machine put:mach]. |
|
5839 |
dom notNil ifTrue:[info at:#domain put:dom]. |
|
5840 |
^ info |
|
5841 |
||
5842 |
" |
|
5843 |
OperatingSystem getSystemInfo |
|
5844 |
" |
|
5845 |
! |
|
5846 |
||
5847 |
getSystemType |
|
5848 |
"return a string giving the type of system we're running on. |
|
5849 |
This is almost the same as getOSType, but the returned string |
|
5850 |
is slightly different for some systems (i.e. iris vs. irix). |
|
5851 |
Dont depend on this - use getOSType. I dont really see a point |
|
831 | 5852 |
here ... |
5853 |
(except for slight differences between next/mach and other machs)" |
|
616 | 5854 |
|
5855 |
|sys| |
|
5856 |
||
5857 |
%{ |
|
5858 |
# ifdef NEXT |
|
5859 |
# define SYS_STRING "next" |
|
5860 |
# endif |
|
5861 |
||
5862 |
# ifdef IRIS |
|
5863 |
# define SYS_STRING "iris" |
|
5864 |
# endif |
|
5865 |
||
831 | 5866 |
# ifdef WIN32 |
5867 |
# define SYS_STRING "win32" |
|
5868 |
# endif |
|
5869 |
||
616 | 5870 |
# ifdef SYS_STRING |
830 | 5871 |
sys = __MKSTRING(SYS_STRING COMMA_CON); |
616 | 5872 |
# undef SYS_STRING |
5873 |
# endif |
|
831 | 5874 |
%}. |
616 | 5875 |
sys isNil ifTrue:[ |
5876 |
^ self getOSType |
|
5877 |
]. |
|
5878 |
^ sys |
|
5879 |
||
5880 |
" |
|
5881 |
OperatingSystem getSystemType |
|
5882 |
" |
|
5883 |
! |
|
5884 |
||
5885 |
isBSDlike |
|
5886 |
"return true, if the OS we're running on is a 'real' unix." |
|
5887 |
||
5888 |
%{ /* NOCONTEXT */ |
|
5889 |
||
5890 |
#if defined(BSD) || defined(MACH) || defined(SYSV4) |
|
5891 |
RETURN ( true ); |
|
13 | 5892 |
#endif |
831 | 5893 |
%}. |
13 | 5894 |
^ false |
10 | 5895 |
! |
5896 |
||
616 | 5897 |
isMSDOSlike |
5898 |
"return true, if the OS we're running on is dos like |
|
5899 |
(in contrast to unix-like)." |
|
5900 |
||
5901 |
%{ /* NOCONTEXT */ |
|
5902 |
||
5903 |
#if defined(MSDOS_LIKE) |
|
5904 |
RETURN ( true ); |
|
5905 |
#endif |
|
831 | 5906 |
%}. |
616 | 5907 |
^ false |
5908 |
! |
|
5909 |
||
831 | 5910 |
isMSWINDOWSlike |
5911 |
"return true, if the OS we're running on is MS-Windows like." |
|
5912 |
||
5913 |
%{ /* NOCONTEXT */ |
|
5914 |
||
5915 |
#if defined(WIN32) |
|
5916 |
RETURN ( true ); |
|
5917 |
#endif |
|
5918 |
||
5919 |
%}. |
|
5920 |
^ false |
|
5921 |
! |
|
5922 |
||
5923 |
isOS2like |
|
5924 |
"return true, if the OS we're running on is OS2 like" |
|
5925 |
||
5926 |
%{ /* NOCONTEXT */ |
|
5927 |
||
5928 |
#if defined(OS2) |
|
5929 |
RETURN (true); |
|
5930 |
#endif |
|
5931 |
||
5932 |
%}. |
|
5933 |
^ false |
|
5934 |
! |
|
5935 |
||
1034 | 5936 |
isUNIXlike |
5937 |
"return true, if the OS we're running on is a unix like." |
|
5938 |
||
5939 |
%{ /* NOCONTEXT */ |
|
5940 |
||
5941 |
#if !defined(UNIX_LIKE) |
|
5942 |
RETURN ( false ); |
|
5943 |
#endif |
|
5944 |
%}. |
|
5945 |
^ true |
|
5946 |
! |
|
5947 |
||
616 | 5948 |
maxFileNameLength |
5949 |
"return the max number of characters in a filename. |
|
831 | 5950 |
CAVEAT: |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5951 |
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
|
5952 |
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
|
5953 |
We return a somewhat conservative number here." |
10 | 5954 |
|
5955 |
%{ /* NOCONTEXT */ |
|
616 | 5956 |
|
5957 |
/* |
|
5958 |
* XXX: newer systems provide a query function for this ... use it |
|
5959 |
*/ |
|
5960 |
# if defined(BSD) || defined(SYSV4) || defined(LONGFILENAMES) |
|
831 | 5961 |
RETURN ( __MKSMALLINT(255) ); |
616 | 5962 |
# endif |
5963 |
||
5964 |
# ifdef realIX |
|
831 | 5965 |
RETURN ( __MKSMALLINT(127) ); |
616 | 5966 |
# endif |
5967 |
||
5968 |
# ifdef SYSV |
|
831 | 5969 |
RETURN ( __MKSMALLINT(14) ); |
616 | 5970 |
# endif |
5971 |
||
5972 |
# ifdef MSDOS |
|
831 | 5973 |
RETURN ( __MKSMALLINT(9) ); |
616 | 5974 |
# endif |
5975 |
||
831 | 5976 |
# ifdef WIN32 |
616 | 5977 |
/* |
5978 |
* mhmh - depends on the filesystem type |
|
5979 |
*/ |
|
831 | 5980 |
RETURN ( __MKSMALLINT(9) ); |
616 | 5981 |
# endif |
5982 |
%}. |
|
5983 |
"unix default" |
|
831 | 5984 |
|
616 | 5985 |
^ 14 |
5986 |
! |
|
5987 |
||
1034 | 5988 |
setLocaleInfo:anInfoDictionary |
5989 |
"set the locale information; if set, this oerrides the OS's settings. |
|
5990 |
(internal in ST/X only - the OS's settings remain unaffected) |
|
5991 |
See description of fields in #getLocaleInfo. |
|
5992 |
||
5993 |
Notice, that (for now), the system does not use this information; |
|
5994 |
it should be used by applications as required." |
|
5995 |
||
5996 |
LocaleInfo := anInfoDictionary |
|
5997 |
||
5998 |
" |
|
5999 |
|d| |
|
6000 |
||
6001 |
d := IdentityDictionary new. |
|
6002 |
d at:#decimalPoint put:'.' . |
|
6003 |
d at:#thousandsSeparator put:',' . |
|
6004 |
d at:#currencySymbol put:'USD' . |
|
6005 |
d at:#monetaryDecimalPoint put:'.' . |
|
6006 |
d at:#monetaryThousandsSeparator put:'.' . |
|
6007 |
d at:#fractionalDigits put:2 . |
|
6008 |
d at:#positiveSign put:'+' . |
|
6009 |
d at:#negativeSign put:'-' . |
|
6010 |
d at:#positiveSignPrecedesCurrencySymbol put:true . |
|
6011 |
d at:#negativeSignPrecedesCurrencySymbol put:false . |
|
6012 |
OperatingSystem setLocaleInfo:d |
|
6013 |
" |
|
6014 |
! |
|
6015 |
||
616 | 6016 |
supportsIOInterrupts |
6017 |
"return true, if the OS supports IO availability interrupts |
|
6018 |
(i.e. SIGPOLL/SIGIO). |
|
6019 |
||
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6020 |
Currently, this mechanism does work for SYSV4 only ..." |
616 | 6021 |
|
6022 |
%{ /* NOCONTEXT */ |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
6023 |
#if defined(SYSV4) && defined(USE_SIGIO) && 0 |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6024 |
|
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6025 |
# if defined(SIGPOLL) || defined(SIGIO) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6026 |
# 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
|
6027 |
/* |
765
93bdb4f0e095
no, SIGIO does not work on SGI ...
Claus Gittinger <cg@exept.de>
parents:
764
diff
changeset
|
6028 |
* 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
|
6029 |
* (not even on SGI ...) |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6030 |
*/ |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6031 |
# if !defined(NEXT) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6032 |
RETURN (true); |
616 | 6033 |
# endif |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6034 |
# endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6035 |
# endif |
616 | 6036 |
|
10 | 6037 |
#endif |
831 | 6038 |
%}. |
13 | 6039 |
^ false |
123 | 6040 |
! |
6041 |
||
616 | 6042 |
supportsNonBlockingIO |
6043 |
"return true, if the OS supports nonblocking IO." |
|
6044 |
||
6045 |
%{ /* NOCONTEXT */ |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6046 |
#if defined(F_GETFL) && defined(F_SETFL) && defined(FNDELAY) |
616 | 6047 |
RETURN (true); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6048 |
#endif |
831 | 6049 |
%}. |
616 | 6050 |
^ false |
123 | 6051 |
! |
6052 |
||
616 | 6053 |
supportsSelect |
6054 |
"return true, if the OS supports selecting on multiple |
|
6055 |
filedescriptors via select." |
|
6056 |
||
6057 |
%{ /* NOCONTEXT */ |
|
831 | 6058 |
#if defined(WIN32) |
6059 |
RETURN (false); |
|
6060 |
#endif |
|
616 | 6061 |
#if defined(sco) |
6062 |
/* |
|
831 | 6063 |
* sco has a select, but its broken: always waiting 1 second |
616 | 6064 |
*/ |
6065 |
RETURN(false); |
|
6066 |
#endif |
|
6067 |
%} |
|
6068 |
. |
|
6069 |
^ true |
|
6070 |
! ! |
|
6071 |
||
6072 |
!OperatingSystem class methodsFor:'shared memory access'! |
|
6073 |
||
6074 |
shmAttach:id address:addr flags:flags |
|
6075 |
%{ /* NOCONTEXT */ |
|
6076 |
#ifdef WANT_SHM |
|
6077 |
void *address, *shmaddr; |
|
6078 |
int shmflg, shmid; |
|
6079 |
||
6080 |
if (__isSmallInteger(addr) |
|
6081 |
&& __bothSmallInteger(flags, id)) { |
|
6082 |
shmaddr = (void *) __intVal(addr); |
|
6083 |
shmflg = __intVal(flags); |
|
6084 |
shmid = __intVal(id); |
|
6085 |
||
6086 |
address = shmat(shmid, shmaddr, shmflg); |
|
6087 |
if (address != (void *)-1) { |
|
6088 |
RETURN (__MKEXTERNALBYTES(addr)); |
|
6089 |
} |
|
1135 | 6090 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 6091 |
RETURN (nil); |
6092 |
} |
|
6093 |
#endif |
|
6094 |
%}. |
|
792 | 6095 |
^ self primitiveFailed |
370 | 6096 |
! |
6097 |
||
616 | 6098 |
shmDetach:addr |
6099 |
%{ /* NOCONTEXT */ |
|
6100 |
#ifdef WANT_SHM |
|
6101 |
void *shmaddr; |
|
6102 |
int rslt; |
|
6103 |
||
6104 |
if (__isSmallInteger(addr)) { |
|
6105 |
shmaddr = (void *) __intVal(addr); |
|
6106 |
||
6107 |
rslt = shmdt(shmaddr); |
|
6108 |
if (rslt != -1) { |
|
6109 |
RETURN (true); |
|
370 | 6110 |
} |
1135 | 6111 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 6112 |
RETURN (false); |
370 | 6113 |
} |
616 | 6114 |
#endif |
6115 |
%}. |
|
792 | 6116 |
^ self primitiveFailed |
616 | 6117 |
! |
6118 |
||
6119 |
shmGet:key size:size flags:flags |
|
6120 |
"low level entry to shmget system call. |
|
6121 |
This is not for public use |
|
6122 |
- use the provided wrapper class SharedExternalBytes instead." |
|
6123 |
||
6124 |
%{ /* NOCONTEXT */ |
|
6125 |
#ifdef WANT_SHM |
|
6126 |
if (__bothSmallInteger(key, size) |
|
6127 |
&& __isSmallInteger(flags)) { |
|
6128 |
int rslt; |
|
6129 |
||
6130 |
rslt = shmget(__intVal(key), __intVal(size), __intVal(flags)); |
|
6131 |
if (rslt != -1) { |
|
6132 |
RETURN (__MKSMALLINT(rslt)); |
|
6133 |
} |
|
1135 | 6134 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 6135 |
RETURN (nil); |
6136 |
} |
|
6137 |
#endif |
|
370 | 6138 |
%}. |
792 | 6139 |
^ self primitiveFailed |
1 | 6140 |
! ! |
6141 |
||
6142 |
!OperatingSystem class methodsFor:'time and date'! |
|
6143 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6144 |
computeDatePartsOf:osTimeLow and:osTimeHi for:aBlock |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6145 |
"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
|
6146 |
osTimeHi and evaluate the argument, a 3-arg block with these. |
241 | 6147 |
Conversion is to localtime including any daylight saving adjustments. |
63 | 6148 |
|
6149 |
This method was added to avoid LargeInteger arithmetic and to be |
|
6150 |
independent of how the OperatingSystem represents time; |
|
6151 |
the time-parts expected are those returned by getTimeParts." |
|
1 | 6152 |
|
6153 |
|year month day| |
|
6154 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6155 |
((osTimeLow isMemberOf:SmallInteger) |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6156 |
and:[osTimeHi isMemberOf:SmallInteger]) ifFalse:[ |
185 | 6157 |
^ self primitiveFailed |
1 | 6158 |
]. |
6159 |
%{ |
|
6160 |
struct tm *tmPtr; |
|
6161 |
long t; |
|
6162 |
||
1135 | 6163 |
t = (__intVal(osTimeHi) << 16) | __intVal(osTimeLow); |
1 | 6164 |
tmPtr = localtime(&t); |
1135 | 6165 |
year = __MKSMALLINT(tmPtr->tm_year + 1900); |
6166 |
month = __MKSMALLINT(tmPtr->tm_mon + 1); |
|
6167 |
day = __MKSMALLINT(tmPtr->tm_mday); |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6168 |
%}. |
1 | 6169 |
aBlock value:year value:month value:day |
6170 |
! |
|
6171 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6172 |
computeDatePartsOf:osTimeParts for:aBlock |
616 | 6173 |
"compute year, month and day from the ostime in timeParts, |
6174 |
and evaluate the argument, a 3-arg block with these. |
|
6175 |
Conversion is to localtime including any daylight saving adjustments." |
|
6176 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6177 |
^ self |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6178 |
computeDatePartsOf:(osTimeParts at:1) |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6179 |
and:(osTimeParts at:2) |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6180 |
for:aBlock |
1 | 6181 |
! |
6182 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6183 |
computeTimeAndDateFrom:osTimeParts |
63 | 6184 |
"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
|
6185 |
containing year, month, day, hour, minute and seconds, |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6186 |
offset to UTC and a daylight savings time flag. |
241 | 6187 |
Conversion is to localtime including any daylight saving adjustments." |
63 | 6188 |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6189 |
|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
|
6190 |
|
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6191 |
low := osTimeParts at:1. |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6192 |
hi := osTimeParts at:2. |
63 | 6193 |
%{ |
6194 |
struct tm *tmPtr; |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6195 |
struct tm *gmTmPtr; |
63 | 6196 |
long t; |
6197 |
||
811 | 6198 |
#ifdef ultrix /* mhmh - isnt this ifdef BSD ? */ |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6199 |
# define TIMEZONE tmPtr->tm_gmtoff |
811 | 6200 |
#else |
831 | 6201 |
# ifdef MSDOS_LIKE |
6202 |
define TIMEZONE 0 |
|
6203 |
# else |
|
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6204 |
# define TIMEZONE timezone |
831 | 6205 |
# endif |
811 | 6206 |
#endif |
6207 |
||
252 | 6208 |
if (__bothSmallInteger(low, hi)) { |
1135 | 6209 |
t = (__intVal(hi) << 16) | __intVal(low); |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6210 |
tmPtr = localtime(&t); |
1135 | 6211 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
6212 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
|
6213 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
|
6214 |
||
6215 |
year = __MKSMALLINT(tmPtr->tm_year + 1900); |
|
6216 |
month = __MKSMALLINT(tmPtr->tm_mon + 1); |
|
6217 |
day = __MKSMALLINT(tmPtr->tm_mday); |
|
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6218 |
|
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6219 |
if (tmPtr->tm_isdst == 0) { |
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6220 |
dst = false; |
1135 | 6221 |
utcOffset = __MKSMALLINT(TIMEZONE); |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6222 |
} else { |
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6223 |
dst = true; |
800
067094efdaed
use HAS_ALTZONE / HAS_DAYLIGHT
Claus Gittinger <cg@exept.de>
parents:
798
diff
changeset
|
6224 |
#ifdef HAS_ALTZONE |
1135 | 6225 |
utcOffset = __MKSMALLINT(altzone); |
800
067094efdaed
use HAS_ALTZONE / HAS_DAYLIGHT
Claus Gittinger <cg@exept.de>
parents:
798
diff
changeset
|
6226 |
#else |
1135 | 6227 |
utcOffset = __MKSMALLINT(TIMEZONE) + 3600; |
800
067094efdaed
use HAS_ALTZONE / HAS_DAYLIGHT
Claus Gittinger <cg@exept.de>
parents:
798
diff
changeset
|
6228 |
#endif |
067094efdaed
use HAS_ALTZONE / HAS_DAYLIGHT
Claus Gittinger <cg@exept.de>
parents:
798
diff
changeset
|
6229 |
} |
63 | 6230 |
} |
241 | 6231 |
%}. |
63 | 6232 |
year notNil ifTrue:[ |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6233 |
"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
|
6234 |
ret := Array new:8. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6235 |
ret at:1 put:year. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6236 |
ret at:2 put:month. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6237 |
ret at:3 put:day. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6238 |
ret at:4 put:hours. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6239 |
ret at:5 put:minutes. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6240 |
ret at:6 put:seconds. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6241 |
ret at:7 put:utcOffset. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6242 |
ret at:8 put:dst. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6243 |
^ ret |
63 | 6244 |
]. |
6245 |
^ self primitiveFailed |
|
6246 |
! |
|
6247 |
||
241 | 6248 |
computeTimePartsFromYear:y month:m day:d hour:h minute:min seconds:s |
6249 |
"return an Array containing the OS-dependent time for the given |
|
6250 |
time and day. The arguments are assumed to be in localtime including |
|
6251 |
any daylight saving adjustings." |
|
6252 |
||
6253 |
|low hi| |
|
6254 |
||
6255 |
%{ |
|
6256 |
struct tm tm; |
|
6257 |
long t; |
|
6258 |
||
252 | 6259 |
if (__bothSmallInteger(y, m) |
6260 |
&& __bothSmallInteger(d, h) |
|
6261 |
&& __bothSmallInteger(min, s)) { |
|
6262 |
tm.tm_hour = __intVal(h); |
|
6263 |
tm.tm_min = __intVal(min); |
|
6264 |
tm.tm_sec = __intVal(s); |
|
6265 |
||
6266 |
tm.tm_year = __intVal(y) - 1900; |
|
6267 |
tm.tm_mon = __intVal(m) - 1; |
|
6268 |
tm.tm_mday = __intVal(d); |
|
241 | 6269 |
tm.tm_isdst = -1; |
6270 |
||
6271 |
t = mktime(&tm); |
|
1135 | 6272 |
low = __MKSMALLINT(t & 0xFFFF); |
6273 |
hi = __MKSMALLINT((t >> 16) & 0xFFFF); |
|
241 | 6274 |
} |
6275 |
%}. |
|
6276 |
low notNil ifTrue:[ |
|
6277 |
^ Array with:low with:hi |
|
6278 |
]. |
|
6279 |
^ self primitiveFailed |
|
6280 |
! |
|
6281 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6282 |
computeTimePartsOf:osTimeLow and:osTimeHi for:aBlock |
616 | 6283 |
"compute hours, minutes and seconds from the time-parts timeLow and |
6284 |
timeHi and evaluate the argument, a 3-arg block with these. |
|
6285 |
Conversion is to localtime including any daylight saving adjustments. |
|
6286 |
||
6287 |
This method was added to avoid LargeInteger arithmetic and to be |
|
6288 |
independent of how the OperatingSystem represents time; |
|
6289 |
the time-parts expected are those returned by getTimeParts." |
|
6290 |
||
6291 |
|hours minutes seconds| |
|
6292 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6293 |
((osTimeLow isMemberOf:SmallInteger) |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6294 |
and:[osTimeHi isMemberOf:SmallInteger]) ifFalse:[ |
616 | 6295 |
^ self primitiveFailed |
6296 |
]. |
|
6297 |
%{ |
|
6298 |
struct tm *tmPtr; |
|
6299 |
long t; |
|
6300 |
||
1135 | 6301 |
t = (__intVal(osTimeHi) << 16) | __intVal(osTimeLow); |
616 | 6302 |
tmPtr = localtime(&t); |
1135 | 6303 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
6304 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
|
6305 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6306 |
%}. |
616 | 6307 |
aBlock value:hours value:minutes value:seconds |
6308 |
! |
|
6309 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6310 |
computeTimePartsOf:osTimeParts for:aBlock |
616 | 6311 |
"compute hour, minute and seconds from the ostime in timeParts, |
6312 |
and evaluate the argument, a 3-arg block with these. |
|
6313 |
Conversion is to localtime including any daylight saving adjustments." |
|
6314 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6315 |
^ self |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6316 |
computeTimePartsOf:(osTimeParts at:1) |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6317 |
and:(osTimeParts at:2) |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6318 |
for:aBlock |
275 | 6319 |
! |
6320 |
||
1 | 6321 |
getMillisecondTime |
185 | 6322 |
"This returns the millisecond timers value. |
6323 |
The range is limited to 0..1fffffff (i.e. the SmallInteger range) to avoid |
|
6324 |
LargeInteger arithmetic when doing timeouts and delays. |
|
792 | 6325 |
Since this value is wrapping around in regular intervals, this can only be used for |
185 | 6326 |
short relative time deltas. |
6327 |
Use the millisecondTimeXXX:-methods to compare and add time deltas - these know about the wrap. |
|
6328 |
||
6329 |
BAD DESIGN: |
|
6330 |
This should be changed to return some instance of RelativeTime, |
|
6331 |
and these computations moved there. |
|
95 | 6332 |
|
6333 |
Dont use this method in application code since it is an internal (private) |
|
6334 |
interface. For compatibility with ST-80, use Time millisecondClockValue. |
|
6335 |
" |
|
1 | 6336 |
|
6337 |
%{ /* NOCONTEXT */ |
|
6338 |
||
6339 |
long t; |
|
185 | 6340 |
#if !defined(HAS_GETTIMEOFDAY) && defined(SYSV) && defined(HZ) |
6341 |
/* |
|
6342 |
* sys5 time |
|
6343 |
*/ |
|
1 | 6344 |
long ticks; |
6345 |
struct tms tb; |
|
6346 |
||
6347 |
ticks = times(&tb); |
|
6348 |
t = (ticks * 1000) / HZ; |
|
792 | 6349 |
#else |
6350 |
# ifdef MSDOS_LIKE |
|
6351 |
struct _timeb timebuffer; |
|
6352 |
||
6353 |
_ftime(&timebuffer); |
|
6354 |
t = (timebuffer.time * 1000) + timebuffer.millitm; |
|
6355 |
# else /* assume HAS_GETTIMEOFDAY */ |
|
185 | 6356 |
/* |
6357 |
* bsd time |
|
6358 |
*/ |
|
1 | 6359 |
struct timeval tb; |
6360 |
struct timezone tzb; |
|
6361 |
||
6362 |
gettimeofday(&tb, &tzb); |
|
6363 |
t = tb.tv_sec*1000 + tb.tv_usec/1000; |
|
792 | 6364 |
# endif |
68 | 6365 |
#endif |
1135 | 6366 |
RETURN ( __MKSMALLINT(t & 0x1FFFFFFF) ); |
1 | 6367 |
%} |
6368 |
! |
|
6369 |
||
616 | 6370 |
getTime |
6371 |
"return current Time in some OS dependent representation. |
|
6372 |
(on unix, its the seconds since 1970). |
|
6373 |
||
831 | 6374 |
WARNING: |
6375 |
this is OperatingSystem dependent |
|
6376 |
- 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
|
6377 |
Better yet, use Date>>today or Time>>now for fully ST-80 compatible code." |
831 | 6378 |
|
6379 |
^ (OperatingSystem getTimeInto:[:low :hi | hi*16r10000 + low]) |
|
616 | 6380 |
|
6381 |
" |
|
6382 |
OperatingSystem getTime |
|
6383 |
" |
|
6384 |
! |
|
6385 |
||
6386 |
getTimeHi |
|
6387 |
"return hi 16 bits of current time. |
|
6388 |
||
6389 |
OBSOLETE: Dont use this method, use getTimeParts. |
|
6390 |
This method will NOT always return the correct time |
|
6391 |
if used together with getTimeHi, since a wrap between |
|
6392 |
the two getTimeXXX sends could occur. |
|
6393 |
WARNING: this method will vanish - dont use it." |
|
6394 |
||
6395 |
%{ /* NOCONTEXT */ |
|
6396 |
||
1135 | 6397 |
RETURN ( __MKSMALLINT((time(0) >> 16) & 0xFFFF) ); |
616 | 6398 |
%} |
6399 |
||
6400 |
"OperatingSystem getTimeHi" |
|
6401 |
! |
|
6402 |
||
6403 |
getTimeInto:aBlock |
|
6404 |
"evaluate the argument aBlock, passing the time-parts of |
|
6405 |
the current time as arguments. |
|
6406 |
See comment in 'OperatingSystem>>getTimeParts' on what to |
|
6407 |
do with those parts." |
|
6408 |
||
6409 |
|low hi| |
|
6410 |
%{ |
|
6411 |
int now; |
|
6412 |
||
6413 |
now = time(0); |
|
1135 | 6414 |
hi = __MKSMALLINT((now >> 16) & 0xFFFF); |
6415 |
low = __MKSMALLINT(now & 0xFFFF); |
|
831 | 6416 |
%}. |
6417 |
^ aBlock value:low value:hi |
|
6418 |
||
6419 |
" |
|
6420 |
OperatingSystem getTimeInto:[:low :hi | low printNewline. hi printNewline] |
|
6421 |
" |
|
616 | 6422 |
! |
6423 |
||
6424 |
getTimeLow |
|
6425 |
"return low 16 bits of current time. |
|
6426 |
||
6427 |
OBSOLETE: Dont use this method, use getTimeParts. |
|
6428 |
This method will not always return the correct time |
|
6429 |
if used together with getTimeHi, since a wrap between |
|
6430 |
the two getTimeXXX sends could occur. |
|
6431 |
WARNING: this method will vanish - dont use it." |
|
6432 |
||
6433 |
%{ /* NOCONTEXT */ |
|
6434 |
||
1135 | 6435 |
RETURN ( __MKSMALLINT(time(0) & 0xFFFF) ); |
616 | 6436 |
%} |
6437 |
||
831 | 6438 |
" |
6439 |
OperatingSystem getTimeLow |
|
6440 |
" |
|
616 | 6441 |
! |
6442 |
||
6443 |
getTimeParts |
|
6444 |
"return the current time as an array of 2 integers representing |
|
6445 |
the current time (usually low 16bits / hi 16 bits) in some OS |
|
6446 |
dependent way. |
|
6447 |
||
6448 |
On unix, the values represent the seconds since 1970, on other |
|
6449 |
systems this may be different. |
|
6450 |
WARNING: |
|
6451 |
for portability, never use these values directly, but pass them |
|
6452 |
to #computeTimeParts and/or #computeDatePartsOf:, which know how to |
|
6453 |
interpret them. |
|
6454 |
Better yet, use Date>>today and Time>>now for ST-80 compatibility." |
|
6455 |
||
6456 |
|low hi| |
|
6457 |
%{ |
|
6458 |
int now; |
|
6459 |
||
6460 |
now = time(0); |
|
1135 | 6461 |
hi = __MKSMALLINT((now >> 16) & 0xFFFF); |
6462 |
low = __MKSMALLINT(now & 0xFFFF); |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6463 |
%}. |
616 | 6464 |
^ Array with:low with:hi |
6465 |
||
831 | 6466 |
" |
6467 |
OperatingSystem getTimeParts |
|
6468 |
" |
|
616 | 6469 |
! |
6470 |
||
6471 |
maximumMillisecondTimeDelta |
|
6472 |
"this returns the maximum delta supported by millisecondCounter |
|
6473 |
based methods. The returned value is half the value at which the |
|
6474 |
timer wraps." |
|
6475 |
||
6476 |
%{ /* NOCONTEXT */ |
|
1135 | 6477 |
RETURN ( __MKSMALLINT(0x0FFFFFFF) ); |
616 | 6478 |
%} |
6479 |
! |
|
6480 |
||
6481 |
millisecondDelay:millis |
|
6482 |
"delay execution for millis milliseconds or until the next event |
|
6483 |
arrives. |
|
6484 |
All lower priority threads will also sleep for the duration, |
|
6485 |
interrupts (and therefore, higher prio processes) are |
|
6486 |
still handled. |
|
6487 |
Better use a Delay, to only delay the calling thread. |
|
6488 |
(however, a delay cannot be used in the event handler or scheduler)" |
|
6489 |
||
6490 |
|now then delta| |
|
6491 |
||
831 | 6492 |
%{ /* NOCONTEXT */ |
6493 |
#ifdef WIN32 |
|
6494 |
int t = __intVal(millis); |
|
6495 |
||
6496 |
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
|
6497 |
Sleep(t); |
831 | 6498 |
} |
6499 |
RETURN (self); |
|
6500 |
#endif |
|
6501 |
%}. |
|
6502 |
||
616 | 6503 |
now := OperatingSystem getMillisecondTime. |
6504 |
then := OperatingSystem millisecondTimeAdd:now and:millis. |
|
6505 |
||
6506 |
[OperatingSystem millisecondTime:then isAfter:now] whileTrue:[ |
|
6507 |
delta := OperatingSystem millisecondTimeDeltaBetween:then and:now. |
|
6508 |
self selectOnAnyReadable:nil writable:nil exception:nil withTimeOut:delta. |
|
6509 |
now := OperatingSystem getMillisecondTime. |
|
6510 |
] |
|
6511 |
||
6512 |
" |
|
6513 |
OperatingSystem millisecondDelay:2000 |
|
6514 |
" |
|
6515 |
! |
|
6516 |
||
6517 |
millisecondTime:msTime1 isAfter:msTime2 |
|
6518 |
"return true if msTime1 is after msTime2, false if not. |
|
6519 |
The two arguments are supposed to be millisecond times |
|
6520 |
(such as returned getMillisecondTime) which wrap at 16r1FFFFFFF. |
|
6521 |
||
6522 |
This should really be moved to some RelativeTime class." |
|
6523 |
||
6524 |
(msTime1 > msTime2) ifTrue:[ |
|
6525 |
((msTime1 - msTime2) >= 16r10000000) ifTrue:[ |
|
6526 |
^ false |
|
6527 |
]. |
|
6528 |
^ true |
|
6529 |
]. |
|
6530 |
((msTime2 - msTime1) > 16r10000000) ifTrue:[ |
|
6531 |
^ true |
|
6532 |
]. |
|
6533 |
^ false |
|
6534 |
! |
|
6535 |
||
6536 |
millisecondTimeAdd:msTime1 and:msTime2 |
|
6537 |
"Add two millisecond times (such as returned getMillisecondTime). |
|
6538 |
The returned value is msTime1 + msTime2 where a wrap occurs at:16r1FFFFFFF. |
|
6539 |
||
6540 |
This should really be moved to some RelativeTime class." |
|
6541 |
||
6542 |
|sum| |
|
6543 |
||
6544 |
sum := msTime1 + msTime2. |
|
6545 |
(sum > 16r1FFFFFFF) ifTrue:[^ sum - 16r20000000]. |
|
6546 |
(sum < 0) ifTrue:[^ sum + 16r20000000]. |
|
6547 |
^ sum |
|
6548 |
! |
|
6549 |
||
1 | 6550 |
millisecondTimeDeltaBetween:msTime1 and:msTime2 |
95 | 6551 |
"subtract two millisecond times (such as returned getMillisecondTime) |
185 | 6552 |
and return the difference. Since milli-times wrap (at 16r01FFFFFFF), |
95 | 6553 |
some special handling is built-in here. |
185 | 6554 |
The returned value is msTime1 - msTime2. The returned value is invalid |
6555 |
if the delta is >= 0x10000000. |
|
63 | 6556 |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6557 |
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
|
6558 |
better yet: create a subclass of Integer named LimitedRangeInteger." |
1 | 6559 |
|
6560 |
(msTime1 > msTime2) ifTrue:[ |
|
185 | 6561 |
^ msTime1 - msTime2 |
1 | 6562 |
]. |
6563 |
^ msTime1 + 16r10000000 - msTime2 |
|
95 | 6564 |
|
6565 |
" |
|
6566 |
OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:1 |
|
6567 |
OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:(16 / 3) |
|
6568 |
OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:1000 |
|
6569 |
||
6570 |
OperatingSystem millisecondTimeDeltaBetween:0 and:16r0FFFFFFF |
|
6571 |
OperatingSystem millisecondTimeDeltaBetween:(13/3) and:16r0FFFFFFF |
|
6572 |
OperatingSystem millisecondTimeDeltaBetween:999 and:16r0FFFFFFF |
|
6573 |
||
6574 |
OperatingSystem millisecondTime:0 isAfter:16r0FFFFFFF |
|
6575 |
OperatingSystem millisecondTime:(13/3) isAfter:16r0FFFFFFF |
|
6576 |
OperatingSystem millisecondTime:999 isAfter:16r0FFFFFFF |
|
6577 |
||
6578 |
OperatingSystem millisecondTime:0 isAfter:0 |
|
6579 |
OperatingSystem millisecondTime:(13/3) isAfter:0 |
|
6580 |
OperatingSystem millisecondTime:999 isAfter:0 |
|
6581 |
||
6582 |
OperatingSystem millisecondTime:1 isAfter:0 |
|
6583 |
OperatingSystem millisecondTime:(13/3) isAfter:2 |
|
6584 |
OperatingSystem millisecondTime:999 isAfter:900 |
|
6585 |
||
6586 |
|t1 t2| |
|
6587 |
||
6588 |
t1 := Time millisecondClockValue. |
|
6589 |
(Delay forMilliseconds:1) wait. |
|
6590 |
t2 := Time millisecondClockValue. |
|
6591 |
OperatingSystem millisecondTimeDeltaBetween:t2 and:t1 |
|
6592 |
" |
|
1 | 6593 |
! |
6594 |
||
6595 |
sleep:numberOfSeconds |
|
308 | 6596 |
"cease ANY action for some time. This suspends the whole smalltalk |
6597 |
(unix-) process for some time. |
|
1 | 6598 |
Not really useful since not even low-prio processes and interrupt |
95 | 6599 |
handling will run during the sleep. |
6600 |
Use either OperatingSystem>>millisecondDelay: (which makes all |
|
6601 |
threads sleep, but handles interrupts) or use a Delay (which makes |
|
6602 |
only the calling thread sleep)." |
|
1 | 6603 |
|
6604 |
%{ /* NOCONTEXT */ |
|
6605 |
||
252 | 6606 |
if (__isSmallInteger(numberOfSeconds)) { |
1135 | 6607 |
sleep(__intVal(numberOfSeconds)); |
185 | 6608 |
RETURN ( self ); |
1 | 6609 |
} |
68 | 6610 |
%}. |
6611 |
" |
|
6612 |
argument not integer |
|
6613 |
" |
|
792 | 6614 |
^ self primitiveFailed |
95 | 6615 |
|
6616 |
" |
|
6617 |
OperatingSystem sleep:2 |
|
6618 |
" |
|
10 | 6619 |
! ! |
6620 |
||
616 | 6621 |
!OperatingSystem class methodsFor:'users & groups'! |
6622 |
||
6623 |
getEffectiveGroupID |
|
6624 |
"return the current users (thats you) effective numeric group id. |
|
6625 |
This is only different from getGroupID, if you have ST/X running |
|
6626 |
as a setuid program (of which you should think about twice)." |
|
6627 |
||
6628 |
%{ /* NOCONTEXT */ |
|
6629 |
||
6630 |
#ifdef UNIX_LIKE |
|
6631 |
int uid; |
|
6632 |
||
6633 |
uid = getegid(); |
|
6634 |
RETURN ( __MKSMALLINT(uid) ); |
|
6635 |
#endif |
|
6636 |
/* --- return same as getGroupID --- */ |
|
6637 |
%}. |
|
6638 |
^ self getGroupID |
|
6639 |
||
6640 |
" |
|
6641 |
OperatingSystem getEffectiveGroupID |
|
6642 |
" |
|
6643 |
! |
|
6644 |
||
6645 |
getEffectiveUserID |
|
6646 |
"return the current users (thats you) effective numeric user id. |
|
6647 |
This is only different from getUserID, if you have ST/X running |
|
6648 |
as a setuid program (of which you should think about twice)." |
|
10 | 6649 |
|
6650 |
%{ /* NOCONTEXT */ |
|
6651 |
||
616 | 6652 |
#ifdef UNIX_LIKE |
6653 |
int uid; |
|
6654 |
||
6655 |
uid = geteuid(); |
|
6656 |
RETURN ( __MKSMALLINT(uid) ); |
|
6657 |
#endif |
|
6658 |
/* --- return same as getUserID --- */ |
|
6659 |
%}. |
|
6660 |
^ self getUserID |
|
6661 |
||
6662 |
" |
|
6663 |
OperatingSystem getEffectiveUserID |
|
6664 |
" |
|
6665 |
! |
|
6666 |
||
6667 |
getGroupID |
|
6668 |
"return the current users (thats you) numeric group id" |
|
6669 |
||
6670 |
%{ /* NOCONTEXT */ |
|
6671 |
||
6672 |
#ifdef UNIX_LIKE |
|
6673 |
int uid; |
|
6674 |
||
6675 |
uid = getgid(); |
|
6676 |
RETURN ( __MKSMALLINT(uid) ); |
|
6677 |
#else |
|
6678 |
# ifdef SYSTEM_HAS_GROUPS |
|
6679 |
/* ... */ |
|
10 | 6680 |
# endif |
6681 |
#endif |
|
68 | 6682 |
%}. |
616 | 6683 |
^ 1 "just a dummy for systems which do not have userIDs" |
6684 |
||
68 | 6685 |
" |
616 | 6686 |
OperatingSystem getGroupID |
6687 |
" |
|
6688 |
! |
|
6689 |
||
6690 |
getGroupNameFromID:aNumber |
|
6691 |
"return the group-name-string for a given numeric group-id" |
|
6692 |
||
6693 |
%{ /* NOCONTEXT */ |
|
6694 |
||
6695 |
#ifdef UNIX_LIKE |
|
6696 |
struct group *g; |
|
6697 |
||
6698 |
if (__isSmallInteger(aNumber)) { |
|
1135 | 6699 |
g = getgrgid(__intVal(aNumber)); |
616 | 6700 |
if (g) { |
830 | 6701 |
RETURN ( __MKSTRING(g->gr_name COMMA_CON) ); |
616 | 6702 |
} |
6703 |
} |
|
6704 |
#endif |
|
6705 |
%}. |
|
6706 |
^ '???' |
|
6707 |
||
6708 |
" |
|
6709 |
OperatingSystem getGroupNameFromID:0 |
|
6710 |
OperatingSystem getGroupNameFromID:10 |
|
6711 |
" |
|
6712 |
! |
|
6713 |
||
6714 |
getHomeDirectory |
|
6715 |
"return the name of the users home directory" |
|
6716 |
||
6717 |
^ OperatingSystem getEnvironment:'HOME' |
|
6718 |
||
6719 |
" |
|
6720 |
OperatingSystem getHomeDirectory |
|
6721 |
" |
|
6722 |
! |
|
6723 |
||
6724 |
getLoginName |
|
6725 |
"return a string with the users name" |
|
6726 |
||
6727 |
%{ /* NOCONTEXT */ |
|
6728 |
static char cachedName[64]; |
|
6729 |
static firstCall = 1; |
|
6730 |
||
831 | 6731 |
char *name = (char *)0; |
616 | 6732 |
#ifdef UNIX_LIKE |
6733 |
if (firstCall) { |
|
6734 |
name = (char *)getlogin(); |
|
6735 |
if (! name || (name[0] == 0)) { |
|
6736 |
name = (char *)getenv("LOGNAME"); |
|
6737 |
} |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
6738 |
if (name && (strlen(name) < sizeof(cachedName))) { |
616 | 6739 |
strcpy(cachedName, name); |
6740 |
firstCall = 0; |
|
6741 |
} |
|
6742 |
} else { |
|
6743 |
name = cachedName; |
|
6744 |
} |
|
831 | 6745 |
#else |
6746 |
# ifdef MSDOS_LIKE |
|
6747 |
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
|
6748 |
int nameSize = sizeof(cachedName); |
831 | 6749 |
|
6750 |
if (GetUserName(cachedName, &nameSize) == TRUE) { |
|
6751 |
name = cachedName; |
|
6752 |
firstCall = 0; |
|
6753 |
} |
|
6754 |
} else { |
|
6755 |
name = cachedName; |
|
6756 |
} |
|
6757 |
# endif |
|
6758 |
#endif |
|
6759 |
if (! name || (name[0] == 0) ) { |
|
6760 |
name = (char *)getenv("LOGNAME"); |
|
6761 |
} |
|
6762 |
if (! name || (name[0] == 0) ) { |
|
6763 |
name = "you"; |
|
6764 |
} |
|
6765 |
||
830 | 6766 |
RETURN ( __MKSTRING(name COMMA_CON) ); |
831 | 6767 |
%}. |
616 | 6768 |
" |
6769 |
OperatingSystem getLoginName |
|
6770 |
" |
|
6771 |
! |
|
6772 |
||
6773 |
getUserID |
|
6774 |
"return the current users (thats you) numeric user id" |
|
6775 |
||
6776 |
%{ /* NOCONTEXT */ |
|
6777 |
||
6778 |
#ifdef UNIX_LIKE |
|
6779 |
int uid; |
|
6780 |
||
6781 |
uid = getuid(); |
|
6782 |
RETURN ( __MKSMALLINT(uid) ); |
|
6783 |
#else |
|
6784 |
# ifdef SYSTEM_HAS_USERS |
|
6785 |
/* ... */ |
|
6786 |
# endif |
|
6787 |
#endif |
|
6788 |
%}. |
|
6789 |
^ 1 "just a dummy for systems which do not have userIDs" |
|
6790 |
||
6791 |
" |
|
6792 |
OperatingSystem getUserID |
|
68 | 6793 |
" |
616 | 6794 |
! |
6795 |
||
6796 |
getUserNameFromID:aNumber |
|
6797 |
"return the user-name-string for a given numeric user-id" |
|
6798 |
||
6799 |
%{ /* NOCONTEXT */ |
|
6800 |
||
6801 |
#ifdef UNIX_LIKE |
|
6802 |
struct passwd *p; |
|
6803 |
||
6804 |
if (__isSmallInteger(aNumber)) { |
|
1135 | 6805 |
p = getpwuid(__intVal(aNumber)); |
616 | 6806 |
if (p) { |
830 | 6807 |
RETURN ( __MKSTRING(p->pw_name COMMA_CON) ); |
616 | 6808 |
} |
6809 |
} |
|
6810 |
#endif |
|
6811 |
%}. |
|
6812 |
^ '? (' , aNumber printString , ')' |
|
6813 |
||
6814 |
" |
|
6815 |
OperatingSystem getUserNameFromID:0 |
|
6816 |
OperatingSystem getUserNameFromID:100 |
|
6817 |
OperatingSystem getUserNameFromID:9991 |
|
6818 |
" |
|
1 | 6819 |
! |
6820 |
||
616 | 6821 |
userInfoOf:aNameOrID |
6822 |
"return a dictionary filled with userinfo. The argument can be either |
|
6823 |
a string with the users name or its numeric id. |
|
6824 |
Notice, that not all systems provide (all of) this info; |
|
6825 |
DOS systems return nothing; |
|
6826 |
non-SYSV4 systems have no age/comment. |
|
6827 |
Portable applications may want to check the systemType and NOT depend |
|
6828 |
on all keys to be present in the returned dictionary. |
|
6829 |
Another notice: on some systems (SYSV4), the gecos field includes multiple |
|
6830 |
entries (i.e. not just the name), separated by commas. You may want to |
|
6831 |
extract any substring, up to the first comma to get the real life name." |
|
6832 |
||
6833 |
|info name passw uid gid age comment |
|
6834 |
gecos dir shell| |
|
6835 |
||
6836 |
%{ |
|
6837 |
#ifdef UNIX_LIKE |
|
6838 |
struct passwd *buf; |
|
6839 |
int ret; |
|
6840 |
||
6841 |
if (__isString(aNameOrID)) { |
|
6842 |
buf = getpwnam(__stringVal(aNameOrID)); |
|
6843 |
} else if (__isSmallInteger(aNameOrID)) { |
|
6844 |
buf = getpwuid(__intVal(aNameOrID)); |
|
6845 |
} else { |
|
6846 |
buf = (struct passwd *)0; |
|
6847 |
} |
|
6848 |
if (buf) { |
|
830 | 6849 |
name = __MKSTRING(buf->pw_name COMMA_CON); |
6850 |
passw = __MKSTRING(buf->pw_passwd COMMA_CON); |
|
616 | 6851 |
# ifdef SYSV4 |
830 | 6852 |
age = __MKSTRING(buf->pw_age COMMA_CON); |
6853 |
comment = __MKSTRING(buf->pw_comment COMMA_CON); |
|
616 | 6854 |
# endif |
830 | 6855 |
dir = __MKSTRING(buf->pw_dir COMMA_CON); |
6856 |
gecos = __MKSTRING(buf->pw_gecos COMMA_CON); |
|
6857 |
shell = __MKSTRING(buf->pw_shell COMMA_CON); |
|
616 | 6858 |
|
1135 | 6859 |
uid = __MKSMALLINT(buf->pw_uid); |
6860 |
gid = __MKSMALLINT(buf->pw_gid); |
|
616 | 6861 |
} |
6862 |
#endif |
|
6863 |
%}. |
|
6864 |
info := IdentityDictionary new. |
|
6865 |
name notNil ifTrue:[ |
|
6866 |
info at:#name put:name. |
|
6867 |
] ifFalse:[ |
|
6868 |
info at:#name put:'unknown' |
|
6869 |
]. |
|
6870 |
passw notNil ifTrue:[info at:#passwd put:passw]. |
|
6871 |
age notNil ifTrue:[info at:#age put:age]. |
|
6872 |
comment notNil ifTrue:[info at:#comment put:comment]. |
|
6873 |
gecos notNil ifTrue:[info at:#gecos put:gecos]. |
|
6874 |
shell notNil ifTrue:[info at:#shell put:shell]. |
|
6875 |
dir notNil ifTrue:[info at:#dir put:dir]. |
|
6876 |
uid notNil ifTrue:[info at:#uid put:uid]. |
|
6877 |
gid notNil ifTrue:[info at:#gid put:gid]. |
|
6878 |
^ info |
|
6879 |
||
6880 |
" |
|
6881 |
OperatingSystem userInfoOf:'root' |
|
6882 |
OperatingSystem userInfoOf:1 |
|
6883 |
OperatingSystem userInfoOf:'claus' |
|
6884 |
OperatingSystem userInfoOf:'fooBar' |
|
6885 |
OperatingSystem userInfoOf:(OperatingSystem getUserID) |
|
6886 |
" |
|
6887 |
! ! |
|
6888 |
||
6889 |
!OperatingSystem class methodsFor:'waiting for events'! |
|
6890 |
||
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6891 |
blockingChildProcessWait |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6892 |
"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
|
6893 |
%{ /*NOCONTEXT*/ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6894 |
#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
|
6895 |
RETURN(false); |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6896 |
#else |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6897 |
RETURN(true); |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6898 |
#endif |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6899 |
%} |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6900 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6901 |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6902 |
childProcessWait:blocking |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6903 |
"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
|
6904 |
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
|
6905 |
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
|
6906 |
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
|
6907 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6908 |
|pid status code core| |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6909 |
%{ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6910 |
int p; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6911 |
#if defined(HAS_WAITPID) |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6912 |
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
|
6913 |
# 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
|
6914 |
#else |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6915 |
# if defined(HAS_WAIT3) |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6916 |
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
|
6917 |
#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
|
6918 |
# else /*!HAS_WAIT3*/ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6919 |
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
|
6920 |
# define __WAIT wait(&s) |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6921 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6922 |
# if !defined(WIFEXITED) |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6923 |
# 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
|
6924 |
# 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
|
6925 |
# 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
|
6926 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6927 |
# 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
|
6928 |
# 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
|
6929 |
# define WSTOPSIG(stat) ((int)(((stat)>>8)&0377)) |
843 | 6930 |
# endif /*!WIFEXITED*/ |
6931 |
# 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
|
6932 |
# define WCOREDUMP(stat) ((int)(((stat)>>8)&0200)) |
843 | 6933 |
# 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
|
6934 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6935 |
if (blocking != true) { |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6936 |
/* |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6937 |
* We do not support nonBlocking waits, so signal an error |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6938 |
* Sorry about the goto, but with all these ifdefs ... |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6939 |
*/ |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6940 |
goto done; |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6941 |
} |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6942 |
# endif /*!HAS_WAIT3*/ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6943 |
#endif /*!HAS_WAITPID*/ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6944 |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6945 |
do { |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6946 |
p = __WAIT; |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6947 |
} 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
|
6948 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6949 |
#undef __WAIT |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6950 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6951 |
if (p == 0) |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6952 |
RETURN(nil) |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6953 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6954 |
if (p == -1) { |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6955 |
if (errno == ECHILD) |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6956 |
RETURN(nil); |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6957 |
} else { |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6958 |
pid = __MKSMALLINT(p); |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6959 |
if (WIFEXITED(s)) { |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6960 |
status = @symbol(exit); |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6961 |
code = __MKSMALLINT(WEXITSTATUS(s)); |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6962 |
core = WCOREDUMP(s) ? true : false; |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6963 |
} else if (WIFSIGNALED(s)) { |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6964 |
status = @symbol(signal); |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6965 |
code = __MKSMALLINT(WTERMSIG(s)); |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6966 |
} else if (WIFSTOPPED(s)) { |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6967 |
status = @symbol(stop); |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6968 |
code = __MKSMALLINT(WSTOPSIG(s)); |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6969 |
} |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6970 |
#if defined(WIFCONTINUED) |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6971 |
else if (WIFCONTINUED(s)) { |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6972 |
status = @symbol(continue); |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6973 |
} |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6974 |
#endif |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
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 |
done: ; |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6977 |
%}. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6978 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6979 |
pid isNil ifTrue:[ |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6980 |
^ self primitiveFailed |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6981 |
]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6982 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6983 |
^ 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
|
6984 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6985 |
" |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6986 |
OperatingSystem childProcessWait:false |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6987 |
" |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6988 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6989 |
"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
|
6990 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6991 |
|
10 | 6992 |
readCheck:fd |
95 | 6993 |
"return true, if data is available on a filedescriptor (i.e. read |
6994 |
is possible without blocking)" |
|
10 | 6995 |
|
6996 |
(self selectOnAnyReadable:(Array with:fd) |
|
185 | 6997 |
writable:nil |
6998 |
exception:nil |
|
6999 |
withTimeOut:0) == fd |
|
7000 |
ifTrue:[^ true]. |
|
10 | 7001 |
^ false |
7002 |
! |
|
7003 |
||
616 | 7004 |
selectOn:fd1 and:fd2 withTimeOut:millis |
7005 |
"wait for any fd to become ready; timeout after t milliseconds. |
|
7006 |
A zero timeout-time will immediately return (i.e. poll). |
|
7007 |
Return fd if i/o ok, nil if timed-out or interrupted. |
|
7008 |
Obsolete: |
|
7009 |
This is a leftover method and will vanish." |
|
7010 |
||
7011 |
^ self selectOnAnyReadable:(Array with:fd1 with:fd2) |
|
7012 |
writable:(Array with:fd1 with:fd2) |
|
7013 |
exception:nil |
|
7014 |
withTimeOut:millis |
|
10 | 7015 |
! |
7016 |
||
7017 |
selectOn:fd withTimeOut:millis |
|
7018 |
"wait for aFileDesriptor to become ready; timeout after t milliseconds. |
|
1 | 7019 |
Return true, if i/o ok, false if timed-out or interrupted. |
7020 |
With 0 as timeout argument, this can be used to check for availability |
|
7021 |
of read-data. |
|
7022 |
Experimental." |
|
7023 |
||
3 | 7024 |
^ self selectOnAnyReadable:(Array with:fd) |
185 | 7025 |
writable:(Array with:fd) |
7026 |
exception:nil |
|
7027 |
withTimeOut:millis |
|
1 | 7028 |
! |
7029 |
||
616 | 7030 |
selectOnAny:fdArray withTimeOut:millis |
7031 |
"wait for any fd in fdArray (an Array of integers) to become ready; |
|
7032 |
timeout after t milliseconds. An empty set will always wait. |
|
7033 |
Return first ready fd if i/o ok, nil if timed-out or interrupted. |
|
7034 |
Experimental." |
|
7035 |
||
7036 |
^ self selectOnAnyReadable:fdArray |
|
7037 |
writable:fdArray |
|
185 | 7038 |
exception:nil |
7039 |
withTimeOut:millis |
|
1 | 7040 |
! |
7041 |
||
10 | 7042 |
selectOnAnyReadable:fdArray withTimeOut:millis |
95 | 7043 |
"wait for any fd in fdArray (an Array of integers) to become ready for |
7044 |
reading. Timeout after t milliseconds. An empty set will always wait. |
|
7045 |
A zero timeout-time will immediately return (i.e. poll). |
|
3 | 7046 |
Return first ready fd if i/o ok, nil if timed-out or interrupted. |
7047 |
Experimental." |
|
7048 |
||
7049 |
^ self selectOnAnyReadable:fdArray |
|
185 | 7050 |
writable:nil |
7051 |
exception:nil |
|
7052 |
withTimeOut:millis |
|
3 | 7053 |
! |
7054 |
||
95 | 7055 |
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray withTimeOut:millis |
7056 |
"wait for any fd in readFdArray (an Array of integers) to become ready for |
|
7057 |
reading, writeFdArray to become ready for writing, or exceptFdArray to |
|
7058 |
arrive exceptional data (i.e. out-of-band data). |
|
7059 |
Timeout after t milliseconds or, if the timeout time is 0, immediately.. |
|
7060 |
Empty fd-sets will always wait. Zero time can be used to poll file- |
|
7061 |
descriptors (i.e. to check if I/O possible without blocking). |
|
7062 |
Return first ready fd if I/O ok, nil if timed-out or interrupted." |
|
3 | 7063 |
|
1 | 7064 |
%{ |
831 | 7065 |
#ifdef MSDOS_LIKE |
7066 |
/* |
|
7067 |
* support a delay-wait only |
|
7068 |
* (i.e. fail if any filedescriptor is selected upon) |
|
7069 |
*/ |
|
7070 |
int count; |
|
7071 |
int i; |
|
7072 |
int t; |
|
7073 |
OBJ fd; |
|
7074 |
||
7075 |
if (! __isSmallInteger(millis)) { |
|
7076 |
goto fail; |
|
7077 |
} |
|
7078 |
||
7079 |
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
|
7080 |
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
|
7081 |
goto fail; |
831 | 7082 |
} |
7083 |
count = __arraySize(readFdArray); |
|
7084 |
for (i=0; i<count;i++) { |
|
1135 | 7085 |
fd = __ArrayInstPtr(readFdArray)->a_element[i]; |
831 | 7086 |
if (fd != nil) { |
7087 |
goto fail; |
|
7088 |
} |
|
7089 |
} |
|
7090 |
} |
|
7091 |
if (writeFdArray != nil) { |
|
7092 |
if (! __isArray(writeFdArray)) { |
|
7093 |
goto fail; |
|
7094 |
} |
|
7095 |
count = __arraySize(writeFdArray); |
|
7096 |
for (i=0; i<count;i++) { |
|
1135 | 7097 |
fd = __ArrayInstPtr(writeFdArray)->a_element[i]; |
831 | 7098 |
if (fd != nil) { |
7099 |
goto fail; |
|
7100 |
} |
|
7101 |
} |
|
7102 |
} |
|
7103 |
if (exceptFdArray != nil) { |
|
7104 |
if (! __isArray(exceptFdArray)) { |
|
7105 |
goto fail; |
|
7106 |
} |
|
7107 |
count = __arraySize(exceptFdArray); |
|
7108 |
for (i=0; i<count;i++) { |
|
1135 | 7109 |
fd = __ArrayInstPtr(exceptFdArray)->a_element[i]; |
831 | 7110 |
if (fd != nil) { |
7111 |
goto fail; |
|
7112 |
} |
|
7113 |
} |
|
7114 |
} |
|
1135 | 7115 |
t = __intVal(millis); |
831 | 7116 |
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
|
7117 |
/* |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
7118 |
* delay only |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
7119 |
*/ |
831 | 7120 |
Sleep(t); |
7121 |
} |
|
7122 |
RETURN (nil); |
|
7123 |
||
7124 |
#else /* not MSDOS_LIKE */ |
|
1 | 7125 |
fd_set rset, wset, eset; |
831 | 7126 |
struct timeval wt, et; |
1 | 7127 |
int t, f, maxF, i, lX, bX; |
7128 |
OBJ fd, retFd; |
|
95 | 7129 |
int ret; |
300 | 7130 |
int count; |
1 | 7131 |
|
252 | 7132 |
if (__isSmallInteger(millis)) { |
185 | 7133 |
FD_ZERO(&rset); |
7134 |
FD_ZERO(&wset); |
|
7135 |
FD_ZERO(&eset); |
|
7136 |
||
7137 |
maxF = -1; |
|
308 | 7138 |
if (readFdArray != nil) { |
300 | 7139 |
if (! __isArray(readFdArray)) { |
7140 |
goto fail; |
|
7141 |
} |
|
7142 |
count = __arraySize(readFdArray); |
|
308 | 7143 |
|
7144 |
for (i=0; i<count;i++) { |
|
1135 | 7145 |
fd = __ArrayInstPtr(readFdArray)->a_element[i]; |
308 | 7146 |
if (fd != nil) { |
1135 | 7147 |
f = __intVal(fd); |
308 | 7148 |
if ((f >= 0) && (f < FD_SETSIZE)) { |
7149 |
FD_SET(f, &rset); |
|
7150 |
if (f > maxF) maxF = f; |
|
7151 |
} |
|
185 | 7152 |
} |
7153 |
} |
|
7154 |
} |
|
300 | 7155 |
|
308 | 7156 |
if (writeFdArray != nil) { |
300 | 7157 |
if (! __isArray(writeFdArray)) { |
7158 |
goto fail; |
|
7159 |
} |
|
7160 |
count = __arraySize(writeFdArray); |
|
308 | 7161 |
for (i=0; i<count;i++) { |
1135 | 7162 |
fd = __ArrayInstPtr(writeFdArray)->a_element[i]; |
308 | 7163 |
if (fd != nil) { |
1135 | 7164 |
f = __intVal(fd); |
308 | 7165 |
if ((f >= 0) && (f < FD_SETSIZE)) { |
7166 |
FD_SET(f, &wset); |
|
7167 |
if (f > maxF) maxF = f; |
|
7168 |
} |
|
185 | 7169 |
} |
7170 |
} |
|
7171 |
} |
|
300 | 7172 |
|
308 | 7173 |
if (exceptFdArray != nil) { |
300 | 7174 |
if (! __isArray(exceptFdArray)) { |
7175 |
goto fail; |
|
7176 |
} |
|
7177 |
count = __arraySize(exceptFdArray); |
|
308 | 7178 |
for (i=0; i<count;i++) { |
1135 | 7179 |
fd = __ArrayInstPtr(exceptFdArray)->a_element[i]; |
308 | 7180 |
if (fd != nil) { |
1135 | 7181 |
f = __intVal(fd); |
308 | 7182 |
if ((f >= 0) && (f < FD_SETSIZE)) { |
7183 |
FD_SET(f, &eset); |
|
7184 |
if (f > maxF) maxF = f; |
|
7185 |
} |
|
185 | 7186 |
} |
7187 |
} |
|
7188 |
} |
|
308 | 7189 |
|
1135 | 7190 |
t = __intVal(millis); |
774
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7191 |
if (t) { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7192 |
wt.tv_sec = t / 1000; |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7193 |
wt.tv_usec = (t % 1000) * 1000; |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7194 |
} else { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7195 |
wt.tv_sec = wt.tv_usec = 0; |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7196 |
} |
185 | 7197 |
|
7198 |
/* |
|
7199 |
* make certain, that interrupt gets us out of the select |
|
7200 |
*/ |
|
362 | 7201 |
__BEGIN_INTERRUPTABLE__ |
185 | 7202 |
errno = 0; |
774
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7203 |
|
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7204 |
if (t == 0) { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7205 |
/* |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7206 |
* 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
|
7207 |
* interruptable. |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7208 |
*/ |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7209 |
do { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7210 |
ret = select(maxF+1, &rset, &wset, &eset, &wt); |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7211 |
} while ((ret < 0) && (errno == EINTR)); |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7212 |
} else { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7213 |
do { |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7214 |
ret = select(maxF+1, &rset, &wset, &eset, &wt); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7215 |
/* |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7216 |
* 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
|
7217 |
* could otherwise stay in this loop forever ... |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7218 |
* 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
|
7219 |
* 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
|
7220 |
*/ |
774
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7221 |
} while (0 /* (ret < 0) && (errno == EINTR) */ ); |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7222 |
} |
362 | 7223 |
__END_INTERRUPTABLE__ |
95 | 7224 |
|
185 | 7225 |
if (ret > 0) { |
7226 |
for (i=0; i <= maxF; i++) { |
|
7227 |
if (FD_ISSET(i, &rset) |
|
7228 |
|| FD_ISSET(i, &wset) |
|
7229 |
|| FD_ISSET(i, &eset)) { |
|
1135 | 7230 |
RETURN ( __MKSMALLINT(i) ); |
185 | 7231 |
} |
7232 |
} |
|
855
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
7233 |
} else { |
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
7234 |
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
|
7235 |
if (errno != EINTR) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
7236 |
fprintf(stderr, "OS: select errno = %d\n", errno); |
1135 | 7237 |
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
|
7238 |
} |
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
7239 |
} |
185 | 7240 |
} |
308 | 7241 |
|
185 | 7242 |
/* |
7243 |
* return nil (means time expired) |
|
7244 |
*/ |
|
7245 |
RETURN ( nil ); |
|
1 | 7246 |
} |
831 | 7247 |
#endif /* not MSDOS_LIKE */ |
7248 |
||
300 | 7249 |
fail: ; |
68 | 7250 |
%}. |
7251 |
" |
|
300 | 7252 |
timeout argument not integer, |
7253 |
or any fd-array nonNil and not an array |
|
792 | 7254 |
or not supported by OS |
68 | 7255 |
" |
792 | 7256 |
^ self primitiveFailed |
1 | 7257 |
! |
7258 |
||
616 | 7259 |
setBlocking:aBoolean on:fd |
7260 |
"set/clear the blocking attribute - if set (which is the default) |
|
7261 |
a read on the fileDescriptor will block until data is available. |
|
7262 |
If cleared, a read operation will immediately return with a value of |
|
7263 |
nil." |
|
10 | 7264 |
|
7265 |
%{ /* NOCONTEXT */ |
|
7266 |
||
616 | 7267 |
int ret, flags; |
7268 |
int savInt; |
|
7269 |
||
7270 |
#if defined(F_GETFL) && defined(F_SETFL) |
|
7271 |
# if defined(FNDELAY) |
|
7272 |
if (__isSmallInteger(fd)) { |
|
1135 | 7273 |
int f = __intVal(fd); |
7274 |
||
7275 |
flags = fcntl(f, F_GETFL, 0); |
|
616 | 7276 |
if (aBoolean == true) { |
1135 | 7277 |
ret = fcntl(f, F_SETFL, flags & ~FNDELAY); |
616 | 7278 |
} else { |
1135 | 7279 |
ret = fcntl(f, F_SETFL, flags | FNDELAY); |
185 | 7280 |
} |
616 | 7281 |
if (ret >= 0) ret = flags; |
1135 | 7282 |
RETURN ( __MKSMALLINT(ret) ); |
77 | 7283 |
} |
616 | 7284 |
# endif |
77 | 7285 |
#endif |
308 | 7286 |
%}. |
77 | 7287 |
" |
616 | 7288 |
fd argument not integer |
185 | 7289 |
" |
792 | 7290 |
^ self primitiveFailed |
1 | 7291 |
! |
7292 |
||
616 | 7293 |
writeCheck:fd |
7294 |
"return true, if filedescriptor can be written without blocking" |
|
7295 |
||
7296 |
(self selectOnAnyReadable:nil |
|
7297 |
writable:(Array with:fd) |
|
7298 |
exception:nil |
|
7299 |
withTimeOut:0) == fd |
|
7300 |
ifTrue:[^ true]. |
|
7301 |
^ false |
|
1 | 7302 |
! ! |
434 | 7303 |
|
630 | 7304 |
!OperatingSystem class methodsFor:'documentation'! |
7305 |
||
7306 |
version |
|
1153
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
7307 |
^ '$Header: /cvs/stx/stx/libbasic/Attic/Unix.st,v 1.136 1996-04-12 08:36:31 stefan Exp $' |
630 | 7308 |
! ! |
616 | 7309 |
OperatingSystem initialize! |