author | Claus Gittinger <cg@exept.de> |
Sat, 27 Jul 1996 14:12:21 +0200 | |
changeset 1615 | 0dc932c45c67 |
parent 1600 | e54d4908baa2 |
child 1616 | fa734ea238f8 |
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 |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
73 |
#ifdef solaris |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
74 |
# define WANT_SYSTEM |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
75 |
#endif |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
76 |
|
805 | 77 |
#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
|
78 |
# 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
|
79 |
#endif |
9620f7dc79d2
interruptable system() on unixware - should now move WANT_SYSTEM into xxxIntern files
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
80 |
|
831 | 81 |
/* |
82 |
* notice: although many systems' include files |
|
83 |
* already block against multiple inclusion, some |
|
84 |
* do not. Therefore, this is done here again. |
|
85 |
* (it does not hurt) |
|
86 |
*/ |
|
87 |
||
439 | 88 |
#ifdef WANT_REALPATH |
831 | 89 |
|
439 | 90 |
# include <sys/param.h> |
91 |
# define _SYS_PARAM_H_INCLUDED_ |
|
92 |
||
93 |
# include <errno.h> |
|
94 |
# define _ERRNO_H_INCLUDED_ |
|
95 |
||
96 |
# include <sys/stat.h> |
|
97 |
# define _SYS_STAT_H_INCLUDED_ |
|
443 | 98 |
|
439 | 99 |
#endif /* WANT_REALPATH */ |
100 |
||
831 | 101 |
|
102 |
||
434 | 103 |
#ifdef WANT_SHM |
443 | 104 |
extern int shmctl(), shmget(), shmdt(); |
105 |
extern char * shmat(); |
|
106 |
||
434 | 107 |
# include <sys/types.h> |
437 | 108 |
# define _SYS_TYPES_H_INCLUDED_ |
439 | 109 |
|
434 | 110 |
# include <sys/ipc.h> |
437 | 111 |
# define _SYS_IPC_H_INCLUDED_ |
439 | 112 |
|
434 | 113 |
# include <sys/shm.h> |
437 | 114 |
# define _SYS_SHM_H_INCLUDED_ |
831 | 115 |
|
439 | 116 |
#endif /* WANT_SHM */ |
434 | 117 |
|
831 | 118 |
|
434 | 119 |
#ifdef IRIX5 |
120 |
# include <sys/syssgi.h> |
|
121 |
#endif |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
122 |
|
831 | 123 |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
124 |
#ifdef transputer |
831 | 125 |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
126 |
# define unlink(f) ((remove(f) == 0) ? 0 : -1) |
831 | 127 |
|
128 |
#else /* not transputer */ |
|
129 |
||
130 |
# ifndef _SIGNAL_H_INCLUDED_ |
|
131 |
# include <signal.h> |
|
132 |
# define _SIGNAL_H_INCLUDED_ |
|
133 |
# endif |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
134 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
135 |
# ifdef SYSV |
831 | 136 |
# ifndef _SYS_TYPES_H_INCLUDED_ |
137 |
# include <sys/types.h> |
|
138 |
# define _SYS_TYPES_H_INCLUDED_ |
|
139 |
# endif |
|
140 |
# ifndef _SYS_PARAM_H_INCLUDED_ |
|
141 |
# include <sys/param.h> |
|
142 |
# define _SYS_PARAM_H_INCLUDED_ |
|
143 |
# endif |
|
144 |
# ifndef _SYS_TIMES_H_INCLUDED_ |
|
145 |
# include <sys/times.h> |
|
146 |
# define _SYS_TIMES_H_INCLUDED_ |
|
147 |
# endif |
|
148 |
# ifndef _SYS_FILE_H_INCLUDED_ |
|
149 |
# include <sys/file.h> |
|
150 |
# define _SYS_FILE_H_INCLUDED_ |
|
151 |
# endif |
|
152 |
||
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
153 |
# if ! defined(sco3_2) |
831 | 154 |
# ifndef _UNISTD_H_INCLUDED_ |
155 |
# include <unistd.h> |
|
156 |
# define _UNISTD_H_INCLUDED_ |
|
157 |
# endif |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
158 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
159 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
160 |
# if defined(isc3_2) || defined(sco3_2) |
831 | 161 |
# ifndef _SYS_TIME_H_INCLUDED_ |
162 |
# include <sys/time.h> |
|
163 |
# define _SYS_TIME_H_INCLUDED_ |
|
164 |
# endif |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
165 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
166 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
167 |
# if !defined(isc3_2) |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
168 |
# if defined(PCS) && defined(mips) |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
169 |
# include "/usr/include/bsd/sys/time.h" |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
170 |
# include "/usr/include/sys/time.h" |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
171 |
# else |
831 | 172 |
# ifndef _TIME_H_INCLUDED_ |
173 |
# include <time.h> |
|
174 |
# define _TIME_H_INCLUDED_ |
|
175 |
# endif |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
176 |
# endif |
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 |
# if defined(isc3_2) |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
180 |
# include <sys/bsdtypes.h> |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
181 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
182 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
183 |
# else /* not SYSV */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
184 |
|
802 | 185 |
# ifdef MSDOS_LIKE |
831 | 186 |
|
187 |
# ifndef _SYS_TYPES_H_INCLUDED_ |
|
1600 | 188 |
# include <h/sys/TYPES.h> |
831 | 189 |
# define _SYS_TYPES_H_INCLUDED_ |
190 |
# endif |
|
191 |
# ifndef _TIME_H_INCLUDED_ |
|
1600 | 192 |
# include <h/time.h> |
831 | 193 |
# define _TIME_H_INCLUDED_ |
194 |
# endif |
|
195 |
# ifndef _SYS_TIMEB_H_INCLUDED_ |
|
1600 | 196 |
# include <h/sys/timeb.h> |
831 | 197 |
# define _SYS_TIMEB_H_INCLUDED_ |
198 |
# endif |
|
199 |
||
200 |
# else /* not MSDOS_like */ |
|
201 |
||
202 |
# ifndef _SYS_TIME_H_INCLUDED_ |
|
203 |
# include <sys/time.h> |
|
204 |
# define _SYS_TIME_H_INCLUDED_ |
|
205 |
# endif |
|
206 |
# ifndef _SYS_TYPES_H_INCLUDED_ |
|
207 |
# include <sys/types.h> |
|
208 |
# define _SYS_TYPES_H_INCLUDED_ |
|
209 |
# endif |
|
210 |
||
211 |
# endif /* not MSDOS */ |
|
792 | 212 |
# endif /* not SYSV */ |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
213 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
214 |
# ifdef aix |
831 | 215 |
|
216 |
# ifndef _TIME_H_INCLUDED_ |
|
217 |
# include <time.h> |
|
914
d00401a9450e
Fix syntax error (#defined -> #define).
Stefan Vogel <sv@exept.de>
parents:
855
diff
changeset
|
218 |
# define _TIME_H_INCLUDED_ |
831 | 219 |
# endif |
220 |
# ifndef _SYS_SELECT_H_INCLUDED_ |
|
221 |
# include <sys/select.h> |
|
222 |
# define _SYS_SELECT_H_INCLUDED_ |
|
223 |
# endif |
|
224 |
||
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
225 |
# ifndef LOCK_EX |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
226 |
# ifndef _SYS_FILE_H_INCLUDED_ |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
227 |
# include <sys/file.h> |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
228 |
# define _SYS_FILE_H_INCLUDED_ |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
229 |
# endif |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
230 |
# endif |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
231 |
|
792 | 232 |
# endif /* aix */ |
233 |
||
234 |
# ifndef MSDOS_LIKE |
|
235 |
# include <pwd.h> |
|
236 |
# include <grp.h> |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
237 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
238 |
|
831 | 239 |
# ifndef _SYS_STAT_H_INCLUDED_ |
240 |
# include <sys/stat.h> |
|
241 |
# endif |
|
242 |
||
243 |
# ifndef _ERRNO_H_INCLUDED_ |
|
244 |
# include <errno.h> |
|
245 |
# define _ERRNO_H_INCLUDED_ |
|
246 |
# endif |
|
247 |
||
248 |
# ifndef _STDIO_H_INCLUDED_ |
|
249 |
# include <stdio.h> |
|
250 |
# define _STDIO_H_INCLUDED_ |
|
251 |
# endif |
|
252 |
||
253 |
# ifndef _FCNTL_H_INCLUDED_ |
|
254 |
# include <fcntl.h> |
|
255 |
# define _FCNTL_H_INCLUDED_ |
|
256 |
# endif |
|
257 |
||
258 |
# ifdef WIN32 |
|
259 |
# undef INT |
|
260 |
# undef Array |
|
261 |
# undef Number |
|
262 |
# undef Method |
|
263 |
# undef Point |
|
1487 | 264 |
# undef Rectangle |
831 | 265 |
|
266 |
/* # include <windows.h> /* */ |
|
1600 | 267 |
# include <h/stdarg.h> /* */ |
268 |
# include <h/windef.h> /* */ |
|
269 |
# include <h/winbase.h> /* */ |
|
270 |
# include <h/wingdi.h> /* */ |
|
271 |
# include <h/winuser.h> /* */ |
|
831 | 272 |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
273 |
# 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
|
274 |
# define Array __DEF_Array |
831 | 275 |
# endif |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
276 |
# 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
|
277 |
# define Number __DEF_Number |
831 | 278 |
# endif |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
279 |
# 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
|
280 |
# define Method __DEF_Method |
831 | 281 |
# endif |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
282 |
# 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
|
283 |
# define Point __DEF_Point |
831 | 284 |
# endif |
1487 | 285 |
|
286 |
# define stat _stat |
|
287 |
||
831 | 288 |
# endif |
289 |
||
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
290 |
|
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
291 |
# if defined(LINUX) |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
292 |
# define HAS_LOCALECONV |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
293 |
# endif |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
294 |
|
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
295 |
# if defined (HAS_LOCALECONV) |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
296 |
# ifndef _LOCALE_H_INCLUDED_ |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
297 |
# include <locale.h> |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
298 |
# define _LOCALE_H_INCLUDED_ |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
299 |
# endif |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
300 |
# endif |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
301 |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
302 |
/* |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
303 |
* posix systems should define these ... |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
304 |
* but on some (older) systems, they are not. |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
305 |
*/ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
306 |
# ifndef S_IXUSR |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
307 |
# ifdef S_IEXEC |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
308 |
# define S_IXUSR S_IEXEC |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
309 |
# define S_IXGRP (S_IEXEC>>3) |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
310 |
# define S_IXOTH (S_IEXEC>>6) |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
311 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
312 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
313 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
314 |
# ifndef S_IXUSR |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
315 |
# define S_IXUSR 0100 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
316 |
# define S_IXGRP 0010 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
317 |
# define S_IXOTH 0001 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
318 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
319 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
320 |
# ifndef S_IRUSR |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
321 |
# define S_IRUSR 0400 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
322 |
# define S_IRGRP 0040 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
323 |
# define S_IROTH 0004 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
324 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
325 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
326 |
# ifndef S_IWUSR |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
327 |
# define S_IWUSR 0200 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
328 |
# define S_IWGRP 0020 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
329 |
# define S_IWOTH 0002 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
330 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
331 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
332 |
# ifndef MAXPATHLEN |
792 | 333 |
# ifndef MSDOS_LIKE |
334 |
# include <sys/param.h> |
|
335 |
# endif |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
336 |
# ifndef MAXPATHLEN |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
337 |
# ifdef FILENAME_MAX /* i.e. MSDOS_LIKE */ |
792 | 338 |
# define MAXPATHLEN FILENAME_MAX |
339 |
# else |
|
340 |
# define MAXPATHLEN 1024 |
|
341 |
# endif |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
342 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
343 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
344 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
345 |
# if defined(HAS_UNAME) |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
346 |
# include <sys/utsname.h> |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
347 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
348 |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
349 |
# if defined(SYSV4) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
350 |
# include <stropts.h> |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
351 |
# endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
352 |
|
763
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
353 |
/* |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
354 |
* 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
|
355 |
*/ |
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
356 |
# ifndef SA_RESTART |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
357 |
# 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
|
358 |
# endif |
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
359 |
# ifndef SA_SIGINFO |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
360 |
# 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
|
361 |
# endif |
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
362 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
363 |
# 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
|
364 |
# include <sys/wait.h> |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
365 |
# endif |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
366 |
|
1433 | 367 |
# if defined(HAS_SYSINFO) |
368 |
# include <sys/systeminfo.h> |
|
369 |
# endif |
|
370 |
||
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
371 |
#endif /* not transputer */ |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
372 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
373 |
/* |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
374 |
* 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
|
375 |
*/ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
376 |
#ifndef errno |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
377 |
extern errno; |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
378 |
#endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
379 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
380 |
/* |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
381 |
* some (old ?) systems do not define this ... |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
382 |
*/ |
675 | 383 |
#if !defined(R_OK) && !defined(_AIX) |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
384 |
# define R_OK 4 /* Test for Read permission */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
385 |
# define W_OK 2 /* Test for Write permission */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
386 |
# define X_OK 1 /* Test for eXecute permission */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
387 |
# define F_OK 0 /* Test for existence of File */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
388 |
#endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
389 |
|
832 | 390 |
#ifdef WIN32 |
391 |
# define SIGHANDLER_ARG int |
|
392 |
#else |
|
393 |
# define SIGHANDLER_ARG |
|
394 |
#endif |
|
395 |
||
1441 | 396 |
#ifdef sunos |
397 |
# define NO_WAITPID |
|
398 |
#endif |
|
399 |
||
437 | 400 |
%} |
401 |
! ! |
|
402 |
||
403 |
!OperatingSystem primitiveFunctions! |
|
404 |
%{ |
|
405 |
||
406 |
/* |
|
407 |
* some systems' system() is broken in that it does not correctly |
|
408 |
* handle EINTR and returns failure even though it actually succeeded. |
|
409 |
* (LINUX is one of them) |
|
410 |
* Here is a fixed version. If you encounter EINTR returns from |
|
411 |
* OperatingSystem>>executeCommand, you ought to define WANT_SYSTEM |
|
412 |
* in the xxxIntern.h file to get this fixed version. |
|
413 |
* |
|
414 |
* As an added BONUS, this system() enables interrupts while waiting |
|
415 |
* 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
|
416 |
* (i.e. it is RT safe) |
437 | 417 |
*/ |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
418 |
|
433 | 419 |
#if defined(WANT_SYSTEM) |
420 |
||
434 | 421 |
/* # define DPRINTF(x) printf x */ |
422 |
# define DPRINTF(x) /* nothing */ |
|
433 | 423 |
|
437 | 424 |
# ifndef _STDDEF_H_INCLUDED_ |
425 |
# include <stddef.h> |
|
426 |
# define _STDDEF_H_INCLUDED_ |
|
427 |
# endif |
|
428 |
||
429 |
# ifndef _STDLIB_H_INCLUDED_ |
|
430 |
# include <stdlib.h> |
|
431 |
# define _STDLIB_H_INCLUDED_ |
|
432 |
# endif |
|
433 |
||
434 |
# ifndef _UNISTD_H_INCLUDED_ |
|
435 |
# include <unistd.h> |
|
436 |
# define _UNISTD_H_INCLUDED_ |
|
437 |
# endif |
|
438 |
||
439 |
# ifndef _SYS_WAIT_H_INCLUDED |
|
440 |
# include <sys/wait.h> |
|
441 |
# define _SYS_WAIT_H_INCLUDED |
|
442 |
# endif |
|
443 |
||
444 |
# ifndef _SIGNAL_H_INCLUDED_ |
|
445 |
# include <signal.h> |
|
446 |
# define _SIGNAL_H_INCLUDED_ |
|
447 |
# endif |
|
448 |
||
449 |
# ifndef _SYS_TYPES_H_INCLUDED_ |
|
450 |
# include <sys/types.h> |
|
451 |
# define _SYS_TYPES_H_INCLUDED_ |
|
452 |
# endif |
|
433 | 453 |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
454 |
# if (!defined(HAVE_GNU_LD) && !defined (__ELF__)) || !defined(LINUX) |
433 | 455 |
# define __environ environ |
512 | 456 |
# if !defined(LINUX) |
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
457 |
# define __sigemptyset sigemptyset |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
458 |
# define __sigaction sigaction |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
459 |
# define __sigaddset sigaddset |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
460 |
# define __sigprocmask sigprocmask |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
461 |
# define __execve execve |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
462 |
# define __wait wait |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
463 |
# define __waitpid waitpid |
674 | 464 |
# if defined(HAS_VFORK) |
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
465 |
# define FORK vfork |
514
81fa80a953e2
system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents:
513
diff
changeset
|
466 |
# else |
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
467 |
# define FORK fork |
514
81fa80a953e2
system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents:
513
diff
changeset
|
468 |
# endif |
512 | 469 |
# endif /* ! LINUX */ |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
470 |
extern char **environ; |
433 | 471 |
# endif |
472 |
||
473 |
# define SHELL_PATH "/bin/sh" /* Path of the shell. */ |
|
474 |
# define SHELL_NAME "sh" /* Name to give it. */ |
|
475 |
||
476 |
# ifndef FORK |
|
477 |
# define FORK __fork |
|
478 |
# endif |
|
479 |
||
480 |
# ifndef CONST |
|
481 |
# ifdef __GNUC__ |
|
482 |
# define CONST const |
|
483 |
# else |
|
484 |
# define CONST /* nothing */ |
|
485 |
# endif |
|
486 |
# endif |
|
487 |
||
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
488 |
static int |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
489 |
mySystem(line) |
433 | 490 |
register CONST char *line; |
491 |
{ |
|
492 |
int status, save; |
|
493 |
pid_t pid; |
|
494 |
struct sigaction sa, intr, quit; |
|
495 |
sigset_t block, omask; |
|
496 |
||
497 |
if (line == NULL) |
|
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
498 |
return -1; |
433 | 499 |
|
500 |
sa.sa_handler = SIG_IGN; |
|
501 |
sa.sa_flags = 0; |
|
502 |
__sigemptyset (&sa.sa_mask); |
|
503 |
||
504 |
if (__sigaction (SIGINT, &sa, &intr) < 0) { |
|
505 |
DPRINTF(("1: errno=%d\n", errno)); |
|
506 |
return -1; |
|
507 |
} |
|
508 |
if (__sigaction (SIGQUIT, &sa, &quit) < 0) { |
|
509 |
save = errno; |
|
510 |
(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL); |
|
511 |
errno = save; |
|
512 |
DPRINTF(("2: errno=%d\n", errno)); |
|
513 |
return -1; |
|
514 |
} |
|
515 |
||
516 |
__sigemptyset (&block); |
|
517 |
__sigaddset (&block, SIGCHLD); |
|
518 |
save = errno; |
|
519 |
if (__sigprocmask(SIG_BLOCK, &block, &omask) < 0) { |
|
520 |
if (errno == ENOSYS) |
|
521 |
errno = save; |
|
522 |
else { |
|
523 |
save = errno; |
|
524 |
(void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL); |
|
525 |
(void) __sigaction(SIGQUIT, &quit, (struct sigaction *) NULL); |
|
526 |
errno = save; |
|
527 |
DPRINTF(("3: errno=%d\n", errno)); |
|
528 |
return -1; |
|
529 |
} |
|
530 |
} |
|
531 |
||
532 |
pid = FORK (); |
|
533 |
if (pid == (pid_t) 0) { |
|
534 |
/* Child side. */ |
|
535 |
CONST char *new_argv[4]; |
|
536 |
new_argv[0] = SHELL_NAME; |
|
537 |
new_argv[1] = "-c"; |
|
538 |
new_argv[2] = line; |
|
539 |
new_argv[3] = NULL; |
|
540 |
||
541 |
/* Restore the signals. */ |
|
542 |
(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL); |
|
543 |
(void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL); |
|
544 |
(void) __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL); |
|
545 |
||
546 |
/* Exec the shell. */ |
|
547 |
(void) __execve (SHELL_PATH, (char *CONST *) new_argv, __environ); |
|
548 |
_exit (127); |
|
549 |
} else { |
|
550 |
if (pid < (pid_t) 0) { |
|
551 |
/* The fork failed. */ |
|
552 |
DPRINTF(("4: errno=%d\n", errno)); |
|
553 |
status = -1; |
|
554 |
} else { |
|
555 |
/* Parent side. */ |
|
556 |
#ifdef NO_WAITPID |
|
557 |
pid_t child; |
|
558 |
||
559 |
do { |
|
805 | 560 |
__BEGIN_INTERRUPTABLE__ |
433 | 561 |
child = __wait (&status); |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
562 |
__END_INTERRUPTABLE__ |
805 | 563 |
if (child < 0 && errno != EINTR) { |
433 | 564 |
DPRINTF(("5: errno=%d\n", errno)); |
565 |
status = -1; |
|
566 |
break; |
|
567 |
} |
|
568 |
} while (child != pid); |
|
569 |
#else |
|
570 |
pid_t child; |
|
571 |
||
572 |
/* claus: the original did not care for EINTR here ... */ |
|
573 |
do { |
|
805 | 574 |
__BEGIN_INTERRUPTABLE__ |
433 | 575 |
child = __waitpid (pid, &status, 0); |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
576 |
__END_INTERRUPTABLE__ |
433 | 577 |
} while ((child != pid) && (errno == EINTR)); |
578 |
if (child != pid) { |
|
579 |
DPRINTF(("6: errno=%d\n", errno)); |
|
580 |
status = -1; |
|
581 |
} |
|
582 |
#endif /* NO_WAITPID */ |
|
583 |
} |
|
584 |
} |
|
585 |
save = errno; |
|
586 |
if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL) |
|
587 |
| __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL) |
|
588 |
| __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)) != 0) { |
|
589 |
if (errno == ENOSYS) { |
|
590 |
errno = save; |
|
591 |
} else { |
|
592 |
status = -1; |
|
593 |
DPRINTF(("7: errno=%d\n", errno)); |
|
594 |
} |
|
595 |
} |
|
596 |
||
597 |
return status; |
|
598 |
} |
|
1441 | 599 |
#else |
1487 | 600 |
# define __wait wait |
433 | 601 |
#endif /* WANT_SYSTEM */ |
602 |
||
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
603 |
|
433 | 604 |
/* |
605 |
* some systems do not have realpath(); |
|
606 |
* the alternative of reading from a 'pwp'-pipe |
|
607 |
* is way too slow. Here is a realpath for the rest of us. |
|
440 | 608 |
* define WANT_REALPATH in the xxxIntern-file to get it. |
433 | 609 |
*/ |
443 | 610 |
|
440 | 611 |
#if defined(HAS_REALPATH) |
612 |
# undef WANT_REALPATH |
|
613 |
#endif |
|
614 |
#if !defined(HAS_GETWD) && !defined(HAS_GETCWD) |
|
615 |
# undef WANT_REALPATH |
|
616 |
#endif |
|
617 |
||
618 |
#if defined(WANT_REALPATH) |
|
406 | 619 |
|
620 |
# ifndef NULL |
|
621 |
# define NULL (char *)0 |
|
622 |
# endif |
|
623 |
||
439 | 624 |
# define MAX_READLINKS 32 |
625 |
||
626 |
# ifndef MAXPATHLEN |
|
627 |
# define MAXPATHLEN 1024 |
|
628 |
# endif |
|
406 | 629 |
|
630 |
static |
|
631 |
char *realpath(path, resolved_path) |
|
632 |
char *path; |
|
633 |
char resolved_path []; |
|
634 |
{ |
|
635 |
char copy_path[MAXPATHLEN]; |
|
636 |
char link_path[MAXPATHLEN]; |
|
637 |
char *new_path = resolved_path; |
|
638 |
char *max_path; |
|
639 |
int readlinks = 0; |
|
640 |
int n; |
|
641 |
||
642 |
/* Make a copy of the source path since we may need to modify it. */ |
|
643 |
strcpy(copy_path, path); |
|
644 |
path = copy_path; |
|
645 |
max_path = copy_path + MAXPATHLEN - 2; |
|
646 |
/* If it's a relative pathname use getwd for starters. */ |
|
647 |
if (*path != '/') { |
|
648 |
#ifdef HAS_GETCWD |
|
649 |
getcwd(new_path, MAXPATHLEN - 1); |
|
650 |
#else |
|
651 |
getwd(new_path); |
|
652 |
#endif |
|
653 |
new_path += strlen(new_path); |
|
654 |
if (new_path[-1] != '/') |
|
655 |
*new_path++ = '/'; |
|
656 |
} |
|
657 |
else { |
|
658 |
*new_path++ = '/'; |
|
659 |
path++; |
|
660 |
} |
|
661 |
/* Expand each slash-separated pathname component. */ |
|
662 |
while (*path != '\0') { |
|
663 |
/* Ignore stray "/". */ |
|
664 |
if (*path == '/') { |
|
665 |
path++; |
|
666 |
continue; |
|
667 |
} |
|
668 |
if (*path == '.') { |
|
669 |
/* Ignore ".". */ |
|
670 |
if (path[1] == '\0' || path[1] == '/') { |
|
671 |
path++; |
|
672 |
continue; |
|
673 |
} |
|
674 |
if (path[1] == '.') { |
|
675 |
if (path[2] == '\0' || path[2] == '/') { |
|
676 |
path += 2; |
|
677 |
/* Ignore ".." at root. */ |
|
678 |
if (new_path == resolved_path + 1) |
|
679 |
continue; |
|
680 |
/* Handle ".." by backing up. */ |
|
681 |
while ((--new_path)[-1] != '/') |
|
682 |
; |
|
683 |
continue; |
|
684 |
} |
|
685 |
} |
|
686 |
} |
|
687 |
/* Safely copy the next pathname component. */ |
|
688 |
while (*path != '\0' && *path != '/') { |
|
689 |
if (path > max_path) { |
|
690 |
errno = ENAMETOOLONG; |
|
691 |
return NULL; |
|
692 |
} |
|
693 |
*new_path++ = *path++; |
|
694 |
} |
|
695 |
#ifdef S_IFLNK |
|
696 |
/* Protect against infinite loops. */ |
|
697 |
if (readlinks++ > MAX_READLINKS) { |
|
698 |
errno = ELOOP; |
|
699 |
return NULL; |
|
700 |
} |
|
701 |
/* See if latest pathname component is a symlink. */ |
|
702 |
*new_path = '\0'; |
|
703 |
n = readlink(resolved_path, link_path, MAXPATHLEN - 1); |
|
704 |
if (n < 0) { |
|
705 |
/* EINVAL means the file exists but isn't a symlink. */ |
|
706 |
if (errno != EINVAL) |
|
707 |
return NULL; |
|
708 |
} |
|
709 |
else { |
|
710 |
/* Note: readlink doesn't add the null byte. */ |
|
711 |
link_path[n] = '\0'; |
|
712 |
if (*link_path == '/') |
|
713 |
/* Start over for an absolute symlink. */ |
|
714 |
new_path = resolved_path; |
|
715 |
else |
|
716 |
/* Otherwise back up over this component. */ |
|
717 |
while (*(--new_path) != '/') |
|
718 |
; |
|
719 |
/* Safe sex check. */ |
|
720 |
if (strlen(path) + n >= MAXPATHLEN) { |
|
721 |
errno = ENAMETOOLONG; |
|
722 |
return NULL; |
|
723 |
} |
|
724 |
/* Insert symlink contents into path. */ |
|
725 |
strcat(link_path, path); |
|
726 |
strcpy(copy_path, link_path); |
|
727 |
path = copy_path; |
|
728 |
} |
|
729 |
#endif /* S_IFLNK */ |
|
730 |
*new_path++ = '/'; |
|
731 |
} |
|
732 |
/* Delete trailing slash but don't whomp a lone slash. */ |
|
733 |
if (new_path != resolved_path + 1 && new_path[-1] == '/') |
|
734 |
new_path--; |
|
735 |
/* Make sure it's null terminated. */ |
|
736 |
*new_path = '\0'; |
|
737 |
return resolved_path; |
|
738 |
} |
|
739 |
# define HAS_REALPATH |
|
740 |
#endif /* WANT_REALPATH && not HAS_REALPATH */ |
|
741 |
%} |
|
742 |
! ! |
|
743 |
||
1497 | 744 |
!OperatingSystem class methodsFor:'documentation'! |
2 | 745 |
|
88 | 746 |
copyright |
747 |
" |
|
748 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
185 | 749 |
All Rights Reserved |
88 | 750 |
|
751 |
This software is furnished under a license and may be used |
|
752 |
only in accordance with the terms of that license and with the |
|
753 |
inclusion of the above copyright notice. This software may not |
|
754 |
be provided or otherwise made available to, or used by, any |
|
755 |
other person. No title to or ownership of the software is |
|
756 |
hereby transferred. |
|
757 |
" |
|
758 |
! |
|
759 |
||
2 | 760 |
documentation |
761 |
" |
|
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
762 |
this class realizes access to most (all ?) required operating system services; |
68 | 763 |
some of it is very specific for unix, so do not depend on |
764 |
things available here in your applications - some may not |
|
370 | 765 |
be found in other OS's or be slightly different ... |
68 | 766 |
|
767 |
(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
|
768 |
from you - in some situations it MAY be interesting to be |
792 | 769 |
able to get down to a select or fork system call easily (at least on Unix systems). |
68 | 770 |
You decide - portability vs. functionality) |
771 |
||
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
772 |
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
|
773 |
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
|
774 |
global variable OperatingSystem. |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
775 |
|
1286 | 776 |
[Class variables:] |
777 |
||
1487 | 778 |
HostName <String> remembered hostname |
779 |
||
780 |
DomainName <String> remembered domainname |
|
781 |
||
782 |
LastErrorNumber <Integer> the last value of errno |
|
783 |
||
784 |
LastExecStatus <Integer> the returned exec status after |
|
785 |
the last call of system |
|
786 |
||
787 |
OSSignals <Array> Array of signals to be raised for corresponding |
|
788 |
OperatingSystem signals. |
|
789 |
||
790 |
ForkFailed <Boolean> set if a fork (or popen) has failed; |
|
791 |
ST/X will avoid doing more forks/popens |
|
792 |
if this flag is set, for a slightly |
|
793 |
smoother operation. |
|
794 |
||
795 |
SlowFork <Boolean> if set, fork and popen are avoided; |
|
796 |
(more or less obsolete now) |
|
797 |
||
798 |
||
799 |
ErrorSignal <Signal> Parentsignal of all OS error signals. |
|
800 |
not directly raised. |
|
801 |
||
802 |
AccessDeniedErrorSignal |
|
803 |
||
804 |
FileNotFoundErrorSignal |
|
805 |
||
806 |
LocaleInfo <Dictionary> if non nil, that is taken instead of the operating |
|
807 |
systems locale definitions (allows for overwriting |
|
808 |
these, or provide a compatible info on systems which do |
|
809 |
not support locales) |
|
1286 | 810 |
|
811 |
[author:] |
|
1487 | 812 |
Claus Gittinger |
1286 | 813 |
|
814 |
[see also:] |
|
1487 | 815 |
OSProcessStatus |
816 |
Filename Date Time |
|
817 |
ExternalStream FileStream PipeStream Socket |
|
2 | 818 |
" |
819 |
! ! |
|
820 |
||
1497 | 821 |
!OperatingSystem class methodsFor:'initialization'! |
95 | 822 |
|
823 |
initialize |
|
185 | 824 |
"initialize the class" |
825 |
||
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
826 |
ObjectMemory addDependent:self. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
827 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
828 |
ErrorSignal isNil ifTrue:[ |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
829 |
ErrorSignal := Object errorSignal newSignalMayProceed:true.. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
830 |
ErrorSignal nameClass:self message:#errorSignal. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
831 |
ErrorSignal notifierString:'OS error encountered'. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
832 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
833 |
AccessDeniedErrorSignal := ErrorSignal newSignalMayProceed:true. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
834 |
AccessDeniedErrorSignal nameClass:self message:#accessDeniedError. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
835 |
AccessDeniedErrorSignal notifierString:'OS access denied'. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
836 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
837 |
FileNotFoundErrorSignal := ErrorSignal newSignalMayProceed:true. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
838 |
FileNotFoundErrorSignal nameClass:self message:#fileNotFoundErrorSignal. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
839 |
FileNotFoundErrorSignal notifierString:'OS file not found'. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
840 |
] |
95 | 841 |
! |
842 |
||
1470 | 843 |
update:something with:aParameter from:changedObject |
1247 | 844 |
"catch image restart and flush some cached data" |
845 |
||
95 | 846 |
something == #earlyRestart ifTrue:[ |
1487 | 847 |
" |
848 |
flush cached data |
|
849 |
" |
|
850 |
HostName := nil. |
|
851 |
DomainName := nil. |
|
852 |
LastErrorNumber := nil. |
|
853 |
LastExecStatus := nil |
|
95 | 854 |
] |
1247 | 855 |
|
856 |
"Modified: 22.4.1996 / 13:10:43 / cg" |
|
1470 | 857 |
"Created: 15.6.1996 / 15:22:37 / cg" |
95 | 858 |
! ! |
859 |
||
1497 | 860 |
!OperatingSystem class methodsFor:'OS signal constants'! |
616 | 861 |
|
862 |
sigABRT |
|
863 |
"return the signal number for SIGABRT - 0 if not supported by OS |
|
864 |
(the numeric value is not the same across unix-systems)" |
|
865 |
||
866 |
%{ /* NOCONTEXT */ |
|
867 |
#ifdef SIGABRT |
|
1135 | 868 |
RETURN ( __MKSMALLINT(SIGABRT) ); |
616 | 869 |
#else |
1135 | 870 |
RETURN ( __MKSMALLINT(0) ); |
616 | 871 |
#endif |
872 |
%} |
|
873 |
! |
|
874 |
||
875 |
sigALRM |
|
876 |
"return the signal number for SIGALRM - 0 if not supported |
|
877 |
(the numeric value is not the same across unix-systems)" |
|
878 |
||
879 |
%{ /* NOCONTEXT */ |
|
880 |
#ifdef SIGALRM |
|
1135 | 881 |
RETURN ( __MKSMALLINT(SIGALRM) ); |
616 | 882 |
#else |
1135 | 883 |
RETURN ( __MKSMALLINT(0) ); |
616 | 884 |
#endif |
885 |
%} |
|
886 |
! |
|
887 |
||
831 | 888 |
sigBREAK |
889 |
"return the signal number for SIGBREAK - 0 if not supported. |
|
890 |
This is an MSDOS specific signal" |
|
891 |
||
892 |
%{ /* NOCONTEXT */ |
|
893 |
#ifdef SIGBREAK |
|
1135 | 894 |
RETURN ( __MKSMALLINT(SIGBREAK) ); |
831 | 895 |
#else |
1135 | 896 |
RETURN ( __MKSMALLINT(0) ); |
831 | 897 |
#endif |
898 |
%} |
|
899 |
! |
|
900 |
||
616 | 901 |
sigBUS |
902 |
"return the signal number for SIGBUS - 0 if not supported |
|
903 |
(the numeric value is not the same across unix-systems)" |
|
904 |
||
905 |
%{ /* NOCONTEXT */ |
|
906 |
#ifdef SIGBUS |
|
1135 | 907 |
RETURN ( __MKSMALLINT(SIGBUS) ); |
616 | 908 |
#else |
1135 | 909 |
RETURN ( __MKSMALLINT(0) ); |
616 | 910 |
#endif |
911 |
%} |
|
912 |
! |
|
913 |
||
914 |
sigCHLD |
|
915 |
"return the signal number for SIGCHLD - 0 if not supported |
|
916 |
(the numeric value is not the same across unix-systems)" |
|
917 |
||
918 |
%{ /* NOCONTEXT */ |
|
919 |
#if defined(SIGCHLD) |
|
1135 | 920 |
RETURN ( __MKSMALLINT(SIGCHLD) ); |
616 | 921 |
#else |
922 |
# if defined(SIGCLD) |
|
1135 | 923 |
RETURN ( __MKSMALLINT(SIGCLD) ); |
616 | 924 |
# else |
1135 | 925 |
RETURN ( __MKSMALLINT(0) ); |
616 | 926 |
# endif |
927 |
#endif |
|
928 |
%} |
|
929 |
! |
|
930 |
||
931 |
sigCONT |
|
932 |
"return the signal number for SIGCONT - 0 if not supported |
|
933 |
(the numeric value is not the same across unix-systems)" |
|
934 |
||
935 |
%{ /* NOCONTEXT */ |
|
936 |
#if defined(SIGCONT) |
|
1135 | 937 |
RETURN ( __MKSMALLINT(SIGCONT) ); |
616 | 938 |
#else |
1135 | 939 |
RETURN ( __MKSMALLINT(0) ); |
616 | 940 |
#endif |
941 |
%} |
|
942 |
! |
|
943 |
||
944 |
sigDANGER |
|
945 |
"return the signal number for SIGDANGER - 0 if not supported |
|
946 |
(seems to be an AIX special)" |
|
947 |
||
948 |
%{ /* NOCONTEXT */ |
|
710 | 949 |
#if defined(SIGDANGER) |
1135 | 950 |
RETURN ( __MKSMALLINT(SIGDANGER) ); |
616 | 951 |
#else |
1135 | 952 |
RETURN ( __MKSMALLINT(0) ); |
616 | 953 |
#endif |
954 |
%} |
|
955 |
! |
|
956 |
||
957 |
sigEMT |
|
958 |
"return the signal number for SIGEMT - 0 if not supported by OS |
|
959 |
(the numeric value is not the same across unix-systems)" |
|
960 |
||
961 |
%{ /* NOCONTEXT */ |
|
962 |
#ifdef SIGEMT |
|
1135 | 963 |
RETURN ( __MKSMALLINT(SIGEMT) ); |
616 | 964 |
#else |
1135 | 965 |
RETURN ( __MKSMALLINT(0) ); |
616 | 966 |
#endif |
967 |
%} |
|
968 |
! |
|
969 |
||
970 |
sigFP |
|
971 |
"return the signal number for SIGFP - 0 if not supported by OS |
|
972 |
(the numeric value is not the same across unix-systems)" |
|
973 |
||
974 |
%{ /* NOCONTEXT */ |
|
975 |
#ifdef SIGFPE |
|
1135 | 976 |
RETURN ( __MKSMALLINT(SIGFPE) ); |
616 | 977 |
#else |
1135 | 978 |
RETURN ( __MKSMALLINT(0) ); |
616 | 979 |
#endif |
980 |
%} |
|
981 |
! |
|
982 |
||
983 |
sigGRANT |
|
984 |
"return the signal number for SIGGRANT - 0 if not supported |
|
985 |
(seems to be an AIX special)" |
|
986 |
||
987 |
%{ /* NOCONTEXT */ |
|
988 |
#if defined(SIGGRANT) |
|
1135 | 989 |
RETURN ( __MKSMALLINT(SIGGRANT) ); |
616 | 990 |
#else |
1135 | 991 |
RETURN ( __MKSMALLINT(0) ); |
616 | 992 |
#endif |
993 |
%} |
|
994 |
! |
|
995 |
||
996 |
sigHUP |
|
997 |
"return the signal number for SIGHUP |
|
998 |
(the numeric value is not the same across unix-systems)" |
|
999 |
||
1000 |
%{ /* NOCONTEXT */ |
|
1001 |
#ifdef SIGHUP |
|
1135 | 1002 |
RETURN ( __MKSMALLINT(SIGHUP) ); |
616 | 1003 |
#else |
1135 | 1004 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1005 |
#endif |
1006 |
%} |
|
1007 |
! |
|
1008 |
||
1009 |
sigILL |
|
1010 |
"return the signal number for SIGILL - 0 if not supported by OS |
|
1011 |
(the numeric value is not the same across unix-systems)" |
|
1012 |
||
1013 |
%{ /* NOCONTEXT */ |
|
1014 |
#ifdef SIGILL |
|
1135 | 1015 |
RETURN ( __MKSMALLINT(SIGILL) ); |
616 | 1016 |
#else |
1135 | 1017 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1018 |
#endif |
1019 |
%} |
|
1020 |
! |
|
1021 |
||
1022 |
sigINT |
|
1023 |
"return the signal number for SIGINT |
|
1024 |
(the numeric value is not the same across unix-systems)" |
|
1025 |
||
1026 |
%{ /* NOCONTEXT */ |
|
1027 |
#ifdef SIGINT |
|
1135 | 1028 |
RETURN ( __MKSMALLINT(SIGINT) ); |
616 | 1029 |
#else |
1135 | 1030 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1031 |
#endif |
1032 |
%} |
|
1033 |
! |
|
1034 |
||
1035 |
sigIO |
|
1036 |
"return the signal number for SIGIO - 0 if not supported |
|
1037 |
(the numeric value is not the same across unix-systems)" |
|
1038 |
||
1039 |
%{ /* NOCONTEXT */ |
|
1040 |
#if defined(SIGIO) |
|
1135 | 1041 |
RETURN ( __MKSMALLINT(SIGIO) ); |
616 | 1042 |
#else |
1135 | 1043 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1044 |
#endif |
1045 |
%} |
|
1046 |
! |
|
1047 |
||
1048 |
sigIOT |
|
1049 |
"return the signal number for SIGIOT - 0 if not supported by OS |
|
1050 |
(the numeric value is not the same across unix-systems)" |
|
1051 |
||
1052 |
%{ /* NOCONTEXT */ |
|
1053 |
#ifdef SIGIOT |
|
1135 | 1054 |
RETURN ( __MKSMALLINT(SIGIOT) ); |
616 | 1055 |
#else |
1135 | 1056 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1057 |
#endif |
1058 |
%} |
|
1059 |
! |
|
1060 |
||
1061 |
sigKILL |
|
1062 |
"return the signal number for SIGKILL |
|
1063 |
(the numeric value is not the same across unix-systems)" |
|
1064 |
||
1065 |
%{ /* NOCONTEXT */ |
|
1066 |
#ifdef SIGKILL |
|
1135 | 1067 |
RETURN ( __MKSMALLINT(SIGKILL) ); |
616 | 1068 |
#else |
1135 | 1069 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1070 |
#endif |
1071 |
%} |
|
1072 |
! |
|
1073 |
||
1074 |
sigLOST |
|
1075 |
"return the signal number for SIGLOST - 0 if not supported |
|
1076 |
(the numeric value is not the same across unix-systems)" |
|
1077 |
||
1078 |
%{ /* NOCONTEXT */ |
|
1079 |
#if defined(SIGLOST) |
|
1135 | 1080 |
RETURN ( __MKSMALLINT(SIGLOST) ); |
616 | 1081 |
#else |
1135 | 1082 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1083 |
#endif |
1084 |
%} |
|
1085 |
! |
|
1086 |
||
1087 |
sigMIGRATE |
|
1088 |
"return the signal number for SIGMIGRATE - 0 if not supported |
|
1089 |
(seems to be an AIX special)" |
|
1090 |
||
1091 |
%{ /* NOCONTEXT */ |
|
1092 |
#if defined(SIGMIGRATE) |
|
1135 | 1093 |
RETURN ( __MKSMALLINT(SIGMIGRATE) ); |
616 | 1094 |
#else |
1135 | 1095 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1096 |
#endif |
1097 |
%} |
|
1098 |
! |
|
1099 |
||
1100 |
sigMSG |
|
1101 |
"return the signal number for SIGMSG - 0 if not supported |
|
1102 |
(seems to be an AIX special)" |
|
1103 |
||
1104 |
%{ /* NOCONTEXT */ |
|
1105 |
#if defined(SIGMSG) |
|
1135 | 1106 |
RETURN ( __MKSMALLINT(SIGMSG) ); |
616 | 1107 |
#else |
1135 | 1108 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1109 |
#endif |
1110 |
%} |
|
1111 |
! |
|
1112 |
||
1113 |
sigPIPE |
|
1114 |
"return the signal number for SIGPIPE - 0 if not supported |
|
1115 |
(the numeric value is not the same across unix-systems)" |
|
1116 |
||
1117 |
%{ /* NOCONTEXT */ |
|
1118 |
#ifdef SIGPIPE |
|
1135 | 1119 |
RETURN ( __MKSMALLINT(SIGPIPE) ); |
616 | 1120 |
#else |
1135 | 1121 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1122 |
#endif |
1123 |
%} |
|
1124 |
! |
|
1125 |
||
1126 |
sigPOLL |
|
1127 |
"return the signal number for SIGPOLL - 0 if not supported |
|
1128 |
(the numeric value is not the same across unix-systems)" |
|
1129 |
||
1130 |
%{ /* NOCONTEXT */ |
|
1131 |
#if defined(SIGPOLL) |
|
1135 | 1132 |
RETURN ( __MKSMALLINT(SIGPOLL) ); |
616 | 1133 |
#else |
1135 | 1134 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1135 |
#endif |
1136 |
%} |
|
1137 |
! |
|
1138 |
||
1139 |
sigPRE |
|
1140 |
"return the signal number for SIGPRE - 0 if not supported |
|
1141 |
(seems to be an AIX special)" |
|
1142 |
||
1143 |
%{ /* NOCONTEXT */ |
|
1144 |
#if defined(SIGPRE) |
|
1135 | 1145 |
RETURN ( __MKSMALLINT(SIGPRE) ); |
616 | 1146 |
#else |
1135 | 1147 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1148 |
#endif |
1149 |
%} |
|
1150 |
! |
|
1151 |
||
1152 |
sigPROF |
|
1153 |
"return the signal number for SIGPROF - 0 if not supported |
|
1154 |
(the numeric value is not the same across unix-systems)" |
|
1155 |
||
1156 |
%{ /* NOCONTEXT */ |
|
1157 |
#if defined(SIGPROF) |
|
1135 | 1158 |
RETURN ( __MKSMALLINT(SIGPROF) ); |
616 | 1159 |
#else |
1135 | 1160 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1161 |
#endif |
1162 |
%} |
|
1163 |
! |
|
1164 |
||
1165 |
sigPWR |
|
1166 |
"return the signal number for SIGPWR - 0 if not supported |
|
1167 |
(not available on all systems)" |
|
1168 |
||
1169 |
%{ /* NOCONTEXT */ |
|
1170 |
#if defined(SIGPWR) |
|
1135 | 1171 |
RETURN ( __MKSMALLINT(SIGPWR) ); |
616 | 1172 |
#else |
1135 | 1173 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1174 |
#endif |
1175 |
%} |
|
1176 |
! |
|
1177 |
||
1178 |
sigQUIT |
|
1179 |
"return the signal number for SIGQUIT |
|
1180 |
(the numeric value is not the same across unix-systems)" |
|
1181 |
||
1182 |
%{ /* NOCONTEXT */ |
|
1183 |
#ifdef SIGQUIT |
|
1135 | 1184 |
RETURN ( __MKSMALLINT(SIGQUIT) ); |
616 | 1185 |
#else |
1135 | 1186 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1187 |
#endif |
1188 |
%} |
|
1189 |
! |
|
1190 |
||
1191 |
sigRETRACT |
|
1192 |
"return the signal number for SIGRETRACT - 0 if not supported |
|
1193 |
(seems to be an AIX special)" |
|
1194 |
||
1195 |
%{ /* NOCONTEXT */ |
|
1196 |
#if defined(SIGRETRACT) |
|
1135 | 1197 |
RETURN ( __MKSMALLINT(SIGRETRACT) ); |
616 | 1198 |
#else |
1135 | 1199 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1200 |
#endif |
1201 |
%} |
|
1202 |
! |
|
1203 |
||
1204 |
sigSAK |
|
1205 |
"return the signal number for SIGSAK - 0 if not supported |
|
1206 |
(seems to be an AIX special)" |
|
1207 |
||
1208 |
%{ /* NOCONTEXT */ |
|
1209 |
#if defined(SIGSAK) |
|
1135 | 1210 |
RETURN ( __MKSMALLINT(SIGSAK) ); |
616 | 1211 |
#else |
1135 | 1212 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1213 |
#endif |
1214 |
%} |
|
1215 |
! |
|
1216 |
||
1217 |
sigSEGV |
|
1218 |
"return the signal number for SIGSEGV - 0 if not supported |
|
1219 |
(the numeric value is not the same across unix-systems)" |
|
1220 |
||
1221 |
%{ /* NOCONTEXT */ |
|
1222 |
#ifdef SIGSEGV |
|
1135 | 1223 |
RETURN ( __MKSMALLINT(SIGSEGV) ); |
616 | 1224 |
#else |
1135 | 1225 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1226 |
#endif |
1227 |
%} |
|
1228 |
! |
|
1229 |
||
1230 |
sigSOUND |
|
1231 |
"return the signal number for SIGSOUND - 0 if not supported |
|
1232 |
(seems to be an AIX special)" |
|
1233 |
||
1234 |
%{ /* NOCONTEXT */ |
|
1235 |
#if defined(SIGSOUND) |
|
1135 | 1236 |
RETURN ( __MKSMALLINT(SIGSOUND) ); |
616 | 1237 |
#else |
1135 | 1238 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1239 |
#endif |
1240 |
%} |
|
1241 |
! |
|
1242 |
||
1243 |
sigSTOP |
|
1244 |
"return the signal number for SIGSTOP - 0 if not supported |
|
1245 |
(the numeric value is not the same across unix-systems)" |
|
1246 |
||
1247 |
%{ /* NOCONTEXT */ |
|
1248 |
#if defined(SIGSTOP) |
|
1135 | 1249 |
RETURN ( __MKSMALLINT(SIGSTOP) ); |
616 | 1250 |
#else |
1135 | 1251 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1252 |
#endif |
1253 |
%} |
|
1254 |
! |
|
1255 |
||
1256 |
sigSYS |
|
1257 |
"return the signal number for SIGSYS - 0 if not supported |
|
1258 |
(the numeric value is not the same across unix-systems)" |
|
1259 |
||
1260 |
%{ /* NOCONTEXT */ |
|
1261 |
#ifdef SIGSYS |
|
1135 | 1262 |
RETURN ( __MKSMALLINT(SIGSYS) ); |
616 | 1263 |
#else |
1135 | 1264 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1265 |
#endif |
1266 |
%} |
|
1267 |
! |
|
1268 |
||
1269 |
sigTERM |
|
1270 |
"return the signal number for SIGTERM - 0 if not supported |
|
1271 |
(the numeric value is not the same across unix-systems)" |
|
1272 |
||
1273 |
%{ /* NOCONTEXT */ |
|
1274 |
#ifdef SIGTERM |
|
1135 | 1275 |
RETURN ( __MKSMALLINT(SIGTERM) ); |
616 | 1276 |
#else |
1135 | 1277 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1278 |
#endif |
1279 |
%} |
|
1280 |
! |
|
1281 |
||
1282 |
sigTRAP |
|
1283 |
"return the signal number for SIGTRAP - 0 if not supported by OS |
|
1284 |
(the numeric value is not the same across unix-systems)" |
|
1285 |
||
1286 |
%{ /* NOCONTEXT */ |
|
1287 |
#ifdef SIGTRAP |
|
1135 | 1288 |
RETURN ( __MKSMALLINT(SIGTRAP) ); |
616 | 1289 |
#else |
1135 | 1290 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1291 |
#endif |
1292 |
%} |
|
1293 |
! |
|
1294 |
||
1295 |
sigTSTP |
|
1296 |
"return the signal number for SIGTSTP - 0 if not supported |
|
1297 |
(the numeric value is not the same across unix-systems)" |
|
1298 |
||
1299 |
%{ /* NOCONTEXT */ |
|
1300 |
#if defined(SIGTSTP) |
|
1135 | 1301 |
RETURN ( __MKSMALLINT(SIGTSTP) ); |
616 | 1302 |
#else |
1135 | 1303 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1304 |
#endif |
1305 |
%} |
|
1306 |
! |
|
1307 |
||
1308 |
sigTTIN |
|
1309 |
"return the signal number for SIGTTIN - 0 if not supported |
|
1310 |
(the numeric value is not the same across unix-systems)" |
|
1311 |
||
1312 |
%{ /* NOCONTEXT */ |
|
1313 |
#if defined(SIGTTIN) |
|
1135 | 1314 |
RETURN ( __MKSMALLINT(SIGTTIN) ); |
616 | 1315 |
#else |
1135 | 1316 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1317 |
#endif |
1318 |
%} |
|
1319 |
! |
|
1320 |
||
1321 |
sigTTOU |
|
1322 |
"return the signal number for SIGTTOU - 0 if not supported |
|
1323 |
(the numeric value is not the same across unix-systems)" |
|
1324 |
||
1325 |
%{ /* NOCONTEXT */ |
|
1326 |
#if defined(SIGTTOU) |
|
1135 | 1327 |
RETURN ( __MKSMALLINT(SIGTTOU) ); |
616 | 1328 |
#else |
1135 | 1329 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1330 |
#endif |
1331 |
%} |
|
1332 |
! |
|
1333 |
||
1334 |
sigURG |
|
1335 |
"return the signal number for SIGURG - 0 if not supported |
|
1336 |
(the numeric value is not the same across unix-systems)" |
|
1337 |
||
1338 |
%{ /* NOCONTEXT */ |
|
1339 |
#if defined(SIGURG) |
|
1135 | 1340 |
RETURN ( __MKSMALLINT(SIGURG) ); |
616 | 1341 |
#else |
1135 | 1342 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1343 |
#endif |
1344 |
%} |
|
1345 |
! |
|
1346 |
||
1347 |
sigUSR1 |
|
1348 |
"return the signal number for SIGUSR1 - 0 if not supported |
|
1349 |
(the numeric value is not the same across unix-systems)" |
|
1350 |
||
1351 |
%{ /* NOCONTEXT */ |
|
1352 |
#if defined(SIGUSR1) |
|
1135 | 1353 |
RETURN ( __MKSMALLINT(SIGUSR1) ); |
616 | 1354 |
#else |
1135 | 1355 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1356 |
#endif |
1357 |
%} |
|
1358 |
! |
|
1359 |
||
1360 |
sigUSR2 |
|
1361 |
"return the signal number for SIGUSR2 - 0 if not supported |
|
1362 |
(the numeric value is not the same across unix-systems)" |
|
1363 |
||
1364 |
%{ /* NOCONTEXT */ |
|
1365 |
#if defined(SIGUSR2) |
|
1135 | 1366 |
RETURN ( __MKSMALLINT(SIGUSR2) ); |
616 | 1367 |
#else |
1135 | 1368 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1369 |
#endif |
1370 |
%} |
|
1371 |
! |
|
1372 |
||
1373 |
sigVTALRM |
|
1374 |
"return the signal number for SIGVTALRM - 0 if not supported |
|
1375 |
(the numeric value is not the same across unix-systems)" |
|
1376 |
||
1377 |
%{ /* NOCONTEXT */ |
|
1378 |
#if defined(SIGVTALRM) |
|
1135 | 1379 |
RETURN ( __MKSMALLINT(SIGVTALRM) ); |
616 | 1380 |
#else |
1135 | 1381 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1382 |
#endif |
1383 |
%} |
|
1384 |
! |
|
1385 |
||
1386 |
sigWINCH |
|
1387 |
"return the signal number for SIGWINCH - 0 if not supported |
|
1388 |
(the numeric value is not the same across unix-systems)" |
|
1389 |
||
1390 |
%{ /* NOCONTEXT */ |
|
1391 |
#if defined(SIGWINCH) |
|
1135 | 1392 |
RETURN ( __MKSMALLINT(SIGWINCH) ); |
616 | 1393 |
#else |
1135 | 1394 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1395 |
#endif |
1396 |
%} |
|
1397 |
! |
|
1398 |
||
1399 |
sigXCPU |
|
1400 |
"return the signal number for SIGXCPU - 0 if not supported |
|
1401 |
(the numeric value is not the same across unix-systems)" |
|
1402 |
||
1403 |
%{ /* NOCONTEXT */ |
|
1404 |
#if defined(SIGXCPU) |
|
1135 | 1405 |
RETURN ( __MKSMALLINT(SIGXCPU) ); |
616 | 1406 |
#else |
1135 | 1407 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1408 |
#endif |
1409 |
%} |
|
1410 |
! |
|
1411 |
||
1412 |
sigXFSZ |
|
1413 |
"return the signal number for SIGXFSZ - 0 if not supported |
|
1414 |
(the numeric value is not the same across unix-systems)" |
|
1415 |
||
1416 |
%{ /* NOCONTEXT */ |
|
1417 |
#if defined(SIGXFSZ) |
|
1135 | 1418 |
RETURN ( __MKSMALLINT(SIGXFSZ) ); |
616 | 1419 |
#else |
1135 | 1420 |
RETURN ( __MKSMALLINT(0) ); |
616 | 1421 |
#endif |
1422 |
%} |
|
1423 |
! ! |
|
1424 |
||
1497 | 1425 |
!OperatingSystem class methodsFor:'Signal constants'! |
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1426 |
|
616 | 1427 |
accessDeniedErrorSignal |
1428 |
"return the signal raised when a (file-) access is denied." |
|
1429 |
||
1430 |
^ AccessDeniedErrorSignal |
|
1431 |
! |
|
1432 |
||
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1433 |
errorSignal |
1247 | 1434 |
"return the parent signal of all OS signals." |
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1435 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1436 |
^ ErrorSignal |
1247 | 1437 |
|
1438 |
"Modified: 22.4.1996 / 13:11:31 / cg" |
|
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1439 |
! |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1440 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1441 |
fileNotFoundErrorSignal |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1442 |
"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
|
1443 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1444 |
^ FileNotFoundErrorSignal |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1445 |
! ! |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1446 |
|
1497 | 1447 |
!OperatingSystem class methodsFor:'error messages'! |
1 | 1448 |
|
1153
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1449 |
clearLastErrorNumber |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1450 |
"return the last errors number. |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1451 |
See also: #lastErrorSymbol and #lastErrorString. |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1452 |
Notice: having a single error number is a bad idea in a multithreaded |
1487 | 1453 |
environment - this interface will change." |
1153
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1454 |
|
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1455 |
LastErrorNumber := nil. |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1456 |
|
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1457 |
" |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1458 |
OperatingSystem clearLastErrorNumber |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1459 |
" |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1460 |
|
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1461 |
"Created: 12.4.1996 / 09:28:58 / stefan" |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1462 |
"Modified: 12.4.1996 / 09:38:51 / stefan" |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1463 |
! |
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
1464 |
|
85 | 1465 |
currentErrorNumber |
68 | 1466 |
"returns the OS's last error nr (i.e. the value of errno). |
1467 |
Notice, that the value of this flag is only valid immediately |
|
1468 |
after the error occurred - it gets updated with every other |
|
85 | 1469 |
request to the OS. |
1470 |
Use lastErrorNumber - currentErrorNumber is invalidated by |
|
1471 |
many, many internal calls." |
|
68 | 1472 |
|
1473 |
%{ /* NOCONTEXT */ |
|
1474 |
||
1135 | 1475 |
RETURN ( __MKSMALLINT(errno) ); |
68 | 1476 |
%} |
1477 |
" |
|
85 | 1478 |
OperatingSystem currentErrorNumber |
1479 |
" |
|
1480 |
! |
|
1481 |
||
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1482 |
errorNumberFor:aSymbol |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1483 |
"given a symbolic error, return the numeric; |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1484 |
(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
|
1485 |
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
|
1486 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1487 |
%{ /* NOCONTEXT */ |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1488 |
OBJ sym = aSymbol; |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1489 |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1490 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1491 |
* POSIX errnos - these should be defined |
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 |
#ifdef EPERM |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1494 |
if (sym == @symbol(EPERM)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1495 |
RETURN ( __MKSMALLINT(EPERM) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1496 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1497 |
#endif |
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 |
#ifdef ENOENT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1500 |
if (sym == @symbol(ENOENT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1501 |
RETURN ( __MKSMALLINT(ENOENT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1502 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1503 |
#endif |
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 |
#ifdef ESRCH |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1506 |
if (sym == @symbol(ESRCH)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1507 |
RETURN ( __MKSMALLINT(ESRCH) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1508 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1509 |
#endif |
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 |
#ifdef EINTR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1512 |
if (sym == @symbol(EINTR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1513 |
RETURN ( __MKSMALLINT(EINTR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1514 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1515 |
#endif |
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 |
#ifdef EIO |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1518 |
if (sym == @symbol(EIO)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1519 |
RETURN ( __MKSMALLINT(EIO) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1520 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1521 |
#endif |
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 |
#ifdef ENXIO |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1524 |
if (sym == @symbol(ENXIO)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1525 |
RETURN ( __MKSMALLINT(ENXIO) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1526 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1527 |
#endif |
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 |
#ifdef E2BIG |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1530 |
if (sym == @symbol(E2BIG)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1531 |
RETURN ( __MKSMALLINT(E2BIG) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1532 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1533 |
#endif |
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 |
#ifdef ENOEXEC |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1536 |
if (sym == @symbol(ENOEXEC)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1537 |
RETURN ( __MKSMALLINT(ENOEXEC) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1538 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1539 |
#endif |
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 |
#ifdef EBADF |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1542 |
if (sym == @symbol(EBADF)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1543 |
RETURN ( __MKSMALLINT(EBADF) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1544 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1545 |
#endif |
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 |
#ifdef ECHILD |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1548 |
if (sym == @symbol(ECHILD)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1549 |
RETURN ( __MKSMALLINT(ECHILD) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1550 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1551 |
#endif |
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 |
#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
|
1554 |
if (sym == @symbol(EAGAIN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1555 |
RETURN ( __MKSMALLINT(EAGAIN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1556 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1557 |
#endif |
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 |
#ifdef ENOMEM |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1560 |
if (sym == @symbol(ENOMEM)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1561 |
RETURN ( __MKSMALLINT(ENOMEM) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1562 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1563 |
#endif |
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 |
#ifdef EACCES |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1566 |
if (sym == @symbol(EACCES)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1567 |
RETURN ( __MKSMALLINT(EACCES) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1568 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1569 |
#endif |
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 |
#ifdef EFAULT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1572 |
if (sym == @symbol(EFAULT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1573 |
RETURN ( __MKSMALLINT(EFAULT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1574 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1575 |
#endif |
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 |
#ifdef EBUSY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1578 |
if (sym == @symbol(EBUSY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1579 |
RETURN ( __MKSMALLINT(EBUSY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1580 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1581 |
#endif |
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 |
#ifdef EXDEV |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1584 |
if (sym == @symbol(EXDEV)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1585 |
RETURN ( __MKSMALLINT(EXDEV) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1586 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1587 |
#endif |
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 |
#ifdef ENODEV |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1590 |
if (sym == @symbol(ENODEV)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1591 |
RETURN ( __MKSMALLINT(ENODEV) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1592 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1593 |
#endif |
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 |
#ifdef ENOTDIR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1596 |
if (sym == @symbol(ENOTDIR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1597 |
RETURN ( __MKSMALLINT(ENOTDIR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1598 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1599 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1600 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1601 |
#ifdef EISDIR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1602 |
if (sym == @symbol(EISDIR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1603 |
RETURN ( __MKSMALLINT(EISDIR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1604 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1605 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1606 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1607 |
#ifdef EINVAL |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1608 |
if (sym == @symbol(EINVAL)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1609 |
RETURN ( __MKSMALLINT(EINVAL) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1610 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1611 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1612 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1613 |
#ifdef ENFILE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1614 |
if (sym == @symbol(ENFILE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1615 |
RETURN ( __MKSMALLINT(ENFILE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1616 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1617 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1618 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1619 |
#ifdef EMFILE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1620 |
if (sym == @symbol(EMFILE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1621 |
RETURN ( __MKSMALLINT(EMFILE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1622 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1623 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1624 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1625 |
#ifdef ENOTTY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1626 |
if (sym == @symbol(ENOTTY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1627 |
RETURN ( __MKSMALLINT(ENOTTY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1628 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1629 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1630 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1631 |
#ifdef EFBIG |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1632 |
if (sym == @symbol(EFBIG)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1633 |
RETURN ( __MKSMALLINT(EFBIG) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1634 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1635 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1636 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1637 |
#ifdef ENOSPC |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1638 |
if (sym == @symbol(ENOSPC)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1639 |
RETURN ( __MKSMALLINT(ENOSPC) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1640 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1641 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1642 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1643 |
#ifdef ESPIPE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1644 |
if (sym == @symbol(ESPIPE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1645 |
RETURN ( __MKSMALLINT(ESPIPE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1646 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1647 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1648 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1649 |
#ifdef EROFS |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1650 |
if (sym == @symbol(EROFS)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1651 |
RETURN ( __MKSMALLINT(EROFS) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1652 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1653 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1654 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1655 |
#ifdef EMLINK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1656 |
if (sym == @symbol(EMLINK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1657 |
RETURN ( __MKSMALLINT(EMLINK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1658 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1659 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1660 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1661 |
#ifdef EPIPE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1662 |
if (sym == @symbol(EPIPE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1663 |
RETURN ( __MKSMALLINT(EPIPE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1664 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1665 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1666 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1667 |
#ifdef EDOM |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1668 |
if (sym == @symbol(EDOM)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1669 |
RETURN ( __MKSMALLINT(EDOM) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1670 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1671 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1672 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1673 |
#ifdef ERANGE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1674 |
if (sym == @symbol(ERANGE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1675 |
RETURN ( __MKSMALLINT(ERANGE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1676 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1677 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1678 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1679 |
#ifdef EDEADLK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1680 |
if (sym == @symbol(EDEADLK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1681 |
RETURN ( __MKSMALLINT(EDEADLK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1682 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1683 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1684 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1685 |
#ifdef ENAMETOOLONG |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1686 |
if (sym == @symbol(ENAMETOOLONG)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1687 |
RETURN ( __MKSMALLINT(ENAMETOOLONG) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1688 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1689 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1690 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1691 |
#ifdef ENOLCK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1692 |
if (sym == @symbol(ENOLCK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1693 |
RETURN ( __MKSMALLINT(ENOLCK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1694 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1695 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1696 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1697 |
#ifdef ENOSYS |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1698 |
if (sym == @symbol(ENOSYS)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1699 |
RETURN ( __MKSMALLINT(ENOSYS) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1700 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1701 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1702 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1703 |
#ifdef ENOTEMPTY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1704 |
if (sym == @symbol(ENOTEMPTY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1705 |
RETURN ( __MKSMALLINT(ENOTEMPTY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1706 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1707 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1708 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1709 |
#ifdef EEXIST |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1710 |
if (sym == @symbol(EEXIST)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1711 |
RETURN ( __MKSMALLINT(EEXIST) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1712 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1713 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1714 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1715 |
#ifdef EILSEQ |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1716 |
if (sym == @symbol(EILSEQ)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1717 |
RETURN ( __MKSMALLINT(EILSEQ) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1718 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1719 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1720 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1721 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1722 |
* XPG3 errnos - defined on most systems |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1723 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1724 |
#ifdef ENOTBLK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1725 |
if (sym == @symbol(ENOTBLK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1726 |
RETURN ( __MKSMALLINT(ENOTBLK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1727 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1728 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1729 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1730 |
#ifdef ETXTBSY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1731 |
if (sym == @symbol(ETXTBSY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1732 |
RETURN ( __MKSMALLINT(ETXTBSY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1733 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1734 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1735 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1736 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1737 |
* some others |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1738 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1739 |
#ifdef EWOULDBLOCK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1740 |
if (sym == @symbol(EWOULDBLOCK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1741 |
RETURN ( __MKSMALLINT(EWOULDBLOCK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1742 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1743 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1744 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1745 |
#ifdef ENOMSG |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1746 |
if (sym == @symbol(ENOMSG)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1747 |
RETURN ( __MKSMALLINT(ENOMSG) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1748 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1749 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1750 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1751 |
#ifdef ELOOP |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1752 |
if (sym == @symbol(ELOOP)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1753 |
RETURN ( __MKSMALLINT(ELOOP) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1754 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1755 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1756 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1757 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1758 |
* some stream errors |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1759 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1760 |
#ifdef ETIME |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1761 |
if (sym == @symbol(ETIME)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1762 |
RETURN ( __MKSMALLINT(ETIME) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1763 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1764 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1765 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1766 |
#ifdef ENOSR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1767 |
if (sym == @symbol(ENOSR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1768 |
RETURN ( __MKSMALLINT(ENOSR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1769 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1770 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1771 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1772 |
#ifdef ENOSTR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1773 |
if (sym == @symbol(ENOSTR)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1774 |
RETURN ( __MKSMALLINT(ENOSTR) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1775 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1776 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1777 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1778 |
#ifdef ECOMM |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1779 |
if (sym == @symbol(ECOMM)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1780 |
RETURN ( __MKSMALLINT(ECOMM) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1781 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1782 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1783 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1784 |
#ifdef EPROTO |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1785 |
if (sym == @symbol(EPROTO)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1786 |
RETURN ( __MKSMALLINT(EPROTO) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1787 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1788 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1789 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1790 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1791 |
* nfs errors |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1792 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1793 |
#ifdef ESTALE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1794 |
if (sym == @symbol(ESTALE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1795 |
RETURN ( __MKSMALLINT(ESTALE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1796 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1797 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1798 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1799 |
#ifdef EREMOTE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1800 |
if (sym == @symbol(EREMOTE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1801 |
RETURN ( __MKSMALLINT(EREMOTE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1802 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1803 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1804 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1805 |
/* |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1806 |
* some networking errors |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1807 |
*/ |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1808 |
#ifdef EINPROGRESS |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1809 |
if (sym == @symbol(EINPROGRESS)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1810 |
RETURN ( __MKSMALLINT(EINPROGRESS) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1811 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1812 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1813 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1814 |
#ifdef EALREADY |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1815 |
if (sym == @symbol(EALREADY)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1816 |
RETURN ( __MKSMALLINT(EALREADY) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1817 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1818 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1819 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1820 |
#ifdef ENOTSOCK |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1821 |
if (sym == @symbol(ENOTSOCK)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1822 |
RETURN ( __MKSMALLINT(ENOTSOCK) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1823 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1824 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1825 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1826 |
#ifdef EDESTADDRREQ |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1827 |
if (sym == @symbol(EDESTADDRREQ)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1828 |
RETURN ( __MKSMALLINT(EDESTADDRREQ) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1829 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1830 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1831 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1832 |
#ifdef EMSGSIZE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1833 |
if (sym == @symbol(EMSGSIZE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1834 |
RETURN ( __MKSMALLINT(EMSGSIZE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1835 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1836 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1837 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1838 |
#ifdef EPROTOTYPE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1839 |
if (sym == @symbol(EPROTOTYPE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1840 |
RETURN ( __MKSMALLINT(EPROTOTYPE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1841 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1842 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1843 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1844 |
#ifdef ENOPROTOOPT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1845 |
if (sym == @symbol(ENOPROTOOPT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1846 |
RETURN ( __MKSMALLINT(ENOPROTOOPT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1847 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1848 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1849 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1850 |
#ifdef EPROTONOSUPPORT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1851 |
if (sym == @symbol(EPROTONOSUPPORT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1852 |
RETURN ( __MKSMALLINT(EPROTONOSUPPORT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1853 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1854 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1855 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1856 |
#ifdef ESOCKTNOSUPPORT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1857 |
if (sym == @symbol(ESOCKTNOSUPPORT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1858 |
RETURN ( __MKSMALLINT(ESOCKTNOSUPPORT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1859 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1860 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1861 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1862 |
#ifdef EOPNOTSUPP |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1863 |
if (sym == @symbol(EOPNOTSUPP)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1864 |
RETURN ( __MKSMALLINT(EOPNOTSUPP) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1865 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1866 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1867 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1868 |
#ifdef EPFNOSUPPORT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1869 |
if (sym == @symbol(EPFNOSUPPORT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1870 |
RETURN ( __MKSMALLINT(EPFNOSUPPORT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1871 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1872 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1873 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1874 |
#ifdef EAFNOSUPPORT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1875 |
if (sym == @symbol(EAFNOSUPPORT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1876 |
RETURN ( __MKSMALLINT(EAFNOSUPPORT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1877 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1878 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1879 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1880 |
#ifdef EADDRINUSE |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1881 |
if (sym == @symbol(EADDRINUSE)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1882 |
RETURN ( __MKSMALLINT(EADDRINUSE) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1883 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1884 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1885 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1886 |
#ifdef EADDRNOTAVAIL |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1887 |
if (sym == @symbol(EADDRNOTAVAIL)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1888 |
RETURN ( __MKSMALLINT(EADDRNOTAVAIL) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1889 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1890 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1891 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1892 |
#ifdef ETIMEDOUT |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1893 |
if (sym == @symbol(ETIMEDOUT)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1894 |
RETURN ( __MKSMALLINT(ETIMEDOUT) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1895 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1896 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1897 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1898 |
#ifdef ECONNREFUSED |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1899 |
if (sym == @symbol(ECONNREFUSED)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1900 |
RETURN ( __MKSMALLINT(ECONNREFUSED) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1901 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1902 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1903 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1904 |
#ifdef ENETDOWN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1905 |
if (sym == @symbol(ENETDOWN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1906 |
RETURN ( __MKSMALLINT(ENETDOWN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1907 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1908 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1909 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1910 |
#ifdef ENETUNREACH |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1911 |
if (sym == @symbol(ENETUNREACH)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1912 |
RETURN ( __MKSMALLINT(ENETUNREACH) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1913 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1914 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1915 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1916 |
#ifdef ENETRESET |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1917 |
if (sym == @symbol(ENETRESET)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1918 |
RETURN ( __MKSMALLINT(ENETRESET) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1919 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1920 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1921 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1922 |
#ifdef ECONNABORTED |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1923 |
if (sym == @symbol(ECONNABORTED)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1924 |
RETURN ( __MKSMALLINT(ECONNABORTED) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1925 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1926 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1927 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1928 |
#ifdef ECONNRESET |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1929 |
if (sym == @symbol(ECONNRESET)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1930 |
RETURN ( __MKSMALLINT(ECONNRESET) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1931 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1932 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1933 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1934 |
#ifdef EISCONN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1935 |
if (sym == @symbol(EISCONN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1936 |
RETURN ( __MKSMALLINT(EISCONN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1937 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1938 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1939 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1940 |
#ifdef ENOTCONN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1941 |
if (sym == @symbol(ENOTCONN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1942 |
RETURN ( __MKSMALLINT(ENOTCONN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1943 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1944 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1945 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1946 |
#ifdef ESHUTDOWN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1947 |
if (sym == @symbol(ESHUTDOWN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1948 |
RETURN ( __MKSMALLINT(ESHUTDOWN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1949 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1950 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1951 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1952 |
#ifdef EHOSTDOWN |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1953 |
if (sym == @symbol(EHOSTDOWN)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1954 |
RETURN ( __MKSMALLINT(EHOSTDOWN) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1955 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1956 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1957 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1958 |
#ifdef EHOSTUNREACH |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1959 |
if (sym == @symbol(EHOSTUNREACH)) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1960 |
RETURN ( __MKSMALLINT(EHOSTUNREACH) ); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1961 |
} |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1962 |
#endif |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1963 |
%}. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1964 |
^ -1 |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1965 |
! |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1966 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1967 |
errorSymbolAndTextForNumber:errNr |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1968 |
"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
|
1969 |
(as returned by a system call). |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1970 |
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
|
1971 |
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
|
1972 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1973 |
|sym text| |
1 | 1974 |
|
77 | 1975 |
%{ |
1976 |
/* claus: |
|
1977 |
* I made this some primitive code, since errnos are not |
|
1978 |
* standard across unixes |
|
1979 |
*/ |
|
1980 |
char *msg = "unknown error"; |
|
1981 |
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
|
1982 |
OBJ eno = errNr; |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1983 |
|
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1104
diff
changeset
|
1984 |
if (__isSmallInteger(eno)) { |
1135 | 1985 |
switch (__intVal(eno)) { |
185 | 1986 |
/* |
1987 |
* POSIX errnos - these should be defined |
|
1988 |
*/ |
|
443 | 1989 |
#ifdef EPERM |
185 | 1990 |
case EPERM: |
1991 |
msg = "Operation not permitted"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1992 |
sym = @symbol(EPERM); |
185 | 1993 |
break; |
443 | 1994 |
#endif |
1995 |
#ifdef ENOENT |
|
185 | 1996 |
case ENOENT: |
1997 |
msg = "No such file or directory"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
1998 |
sym = @symbol(ENOENT); |
185 | 1999 |
break; |
443 | 2000 |
#endif |
2001 |
#ifdef ESRCH |
|
185 | 2002 |
case ESRCH: |
2003 |
msg = "No such process"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2004 |
sym = @symbol(ESRCH); |
185 | 2005 |
break; |
443 | 2006 |
#endif |
2007 |
#ifdef EINTR |
|
185 | 2008 |
case EINTR: |
2009 |
msg = "Interrupted system call"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2010 |
sym = @symbol(EINTR); |
185 | 2011 |
break; |
443 | 2012 |
#endif |
2013 |
#ifdef EIO |
|
185 | 2014 |
case EIO: |
2015 |
msg = "I/O error"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2016 |
sym = @symbol(EIO); |
185 | 2017 |
break; |
443 | 2018 |
#endif |
2019 |
#ifdef ENXIO |
|
185 | 2020 |
case ENXIO: |
2021 |
msg = "No such device or address"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2022 |
sym = @symbol(ENXIO); |
185 | 2023 |
break; |
443 | 2024 |
#endif |
2025 |
#ifdef E2BIG |
|
185 | 2026 |
case E2BIG: |
2027 |
msg = "Arg list too long"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2028 |
sym = @symbol(E2BIG); |
185 | 2029 |
break; |
443 | 2030 |
#endif |
2031 |
#ifdef ENOEXEC |
|
185 | 2032 |
case ENOEXEC: |
2033 |
msg = "Exec format error"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2034 |
sym = @symbol(ENOEXEC); |
185 | 2035 |
break; |
443 | 2036 |
#endif |
2037 |
#ifdef EBADF |
|
185 | 2038 |
case EBADF: |
2039 |
msg = "Bad file number"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2040 |
sym = @symbol(EBADF); |
185 | 2041 |
break; |
443 | 2042 |
#endif |
2043 |
#ifdef ECHILD |
|
185 | 2044 |
case ECHILD: |
2045 |
msg = "No child processes"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2046 |
sym = @symbol(ECHILD); |
185 | 2047 |
break; |
443 | 2048 |
#endif |
77 | 2049 |
#if !defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN) |
185 | 2050 |
case EAGAIN: |
2051 |
msg = "Try again"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2052 |
sym = @symbol(EAGAIN); |
185 | 2053 |
break; |
77 | 2054 |
#endif |
443 | 2055 |
#ifdef ENOMEM |
185 | 2056 |
case ENOMEM: |
2057 |
msg = "Out of memory"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2058 |
sym = @symbol(ENOMEM); |
185 | 2059 |
break; |
443 | 2060 |
#endif |
2061 |
#ifdef EACCES |
|
185 | 2062 |
case EACCES: |
2063 |
msg = "Permission denied"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2064 |
sym = @symbol(EACCES); |
185 | 2065 |
break; |
443 | 2066 |
#endif |
2067 |
#ifdef EFAULT |
|
185 | 2068 |
case EFAULT: |
2069 |
msg = "Bad address"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2070 |
sym = @symbol(EFAULT); |
185 | 2071 |
break; |
443 | 2072 |
#endif |
2073 |
#ifdef EBUSY |
|
185 | 2074 |
case EBUSY: |
2075 |
msg = "Device or resource busy"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2076 |
sym = @symbol(EBUSY); |
185 | 2077 |
break; |
443 | 2078 |
#endif |
2079 |
#ifdef EEXIST |
|
185 | 2080 |
case EEXIST: |
2081 |
msg = "File exists"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2082 |
sym = @symbol(EEXIST); |
185 | 2083 |
break; |
443 | 2084 |
#endif |
2085 |
#ifdef EXDEV |
|
185 | 2086 |
case EXDEV: |
2087 |
msg = "Cross-device link"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2088 |
sym = @symbol(EXDEV); |
185 | 2089 |
break; |
443 | 2090 |
#endif |
2091 |
#ifdef ENODEV |
|
185 | 2092 |
case ENODEV: |
2093 |
msg = "No such device"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2094 |
sym = @symbol(ENODEV); |
185 | 2095 |
break; |
443 | 2096 |
#endif |
2097 |
#ifdef ENOTDIR |
|
185 | 2098 |
case ENOTDIR: |
2099 |
msg = "Not a directory"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2100 |
sym = @symbol(ENOTDIR); |
185 | 2101 |
break; |
443 | 2102 |
#endif |
2103 |
#ifdef EISDIR |
|
185 | 2104 |
case EISDIR: |
2105 |
msg = "Is a directory"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2106 |
sym = @symbol(EISDIR); |
185 | 2107 |
break; |
443 | 2108 |
#endif |
2109 |
#ifdef EINVAL |
|
185 | 2110 |
case EINVAL: |
2111 |
msg = "Invalid argument"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2112 |
sym = @symbol(EINVAL); |
185 | 2113 |
break; |
443 | 2114 |
#endif |
2115 |
#ifdef ENFILE |
|
185 | 2116 |
case ENFILE: |
2117 |
msg = "File table overflow"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2118 |
sym = @symbol(ENFILE); |
185 | 2119 |
break; |
443 | 2120 |
#endif |
2121 |
#ifdef EMFILE |
|
185 | 2122 |
case EMFILE: |
2123 |
msg = "Too many open files"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2124 |
sym = @symbol(EMFILE); |
185 | 2125 |
break; |
443 | 2126 |
#endif |
2127 |
#ifdef ENOTTY |
|
185 | 2128 |
case ENOTTY: |
2129 |
msg = "Not a typewriter"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2130 |
sym = @symbol(ENOTTY); |
185 | 2131 |
break; |
443 | 2132 |
#endif |
2133 |
#ifdef EFBIG |
|
185 | 2134 |
case EFBIG: |
2135 |
msg = "File too large"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2136 |
sym = @symbol(EFBIG); |
185 | 2137 |
break; |
443 | 2138 |
#endif |
2139 |
#ifdef ENOSPC |
|
185 | 2140 |
case ENOSPC: |
2141 |
msg = "No space left on device"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2142 |
sym = @symbol(ENOSPC); |
185 | 2143 |
break; |
443 | 2144 |
#endif |
2145 |
#ifdef ESPIPE |
|
185 | 2146 |
case ESPIPE: |
2147 |
msg = "Illegal seek"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2148 |
sym = @symbol(ESPIPE); |
185 | 2149 |
break; |
443 | 2150 |
#endif |
2151 |
#ifdef EROFS |
|
185 | 2152 |
case EROFS: |
2153 |
msg = "Read-only file system"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2154 |
sym = @symbol(EROFS); |
185 | 2155 |
break; |
443 | 2156 |
#endif |
2157 |
#ifdef EMLINK |
|
185 | 2158 |
case EMLINK: |
2159 |
msg = "Too many links"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2160 |
sym = @symbol(EMLINK); |
185 | 2161 |
break; |
443 | 2162 |
#endif |
2163 |
#ifdef EPIPE |
|
185 | 2164 |
case EPIPE: |
2165 |
msg = "Broken pipe"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2166 |
sym = @symbol(EPIPE); |
185 | 2167 |
break; |
443 | 2168 |
#endif |
2169 |
#ifdef EDOM |
|
185 | 2170 |
case EDOM: |
2171 |
msg = "Math argument out of domain"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2172 |
sym = @symbol(EDOM); |
185 | 2173 |
break; |
443 | 2174 |
#endif |
2175 |
#ifdef ERANGE |
|
185 | 2176 |
case ERANGE: |
2177 |
msg = "Math result not representable"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2178 |
sym = @symbol(ERANGE); |
185 | 2179 |
break; |
443 | 2180 |
#endif |
77 | 2181 |
#ifdef EDEADLK |
308 | 2182 |
# if EDEADLK != EWOULDBLOCK |
185 | 2183 |
case EDEADLK: |
2184 |
msg = "Resource deadlock would occur"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2185 |
sym = @symbol(EDEADLK); |
185 | 2186 |
break; |
308 | 2187 |
# endif |
77 | 2188 |
#endif |
2189 |
#ifdef ENAMETOOLONG |
|
185 | 2190 |
case ENAMETOOLONG: |
2191 |
msg = "File name too long"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2192 |
sym = @symbol(ENAMETOOLONG); |
185 | 2193 |
break; |
77 | 2194 |
#endif |
2195 |
#ifdef ENOLCK |
|
185 | 2196 |
case ENOLCK: |
2197 |
msg = "No record locks available"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2198 |
sym = @symbol(ENOLCK); |
185 | 2199 |
break; |
77 | 2200 |
#endif |
2201 |
#ifdef ENOSYS |
|
185 | 2202 |
case ENOSYS: |
2203 |
msg = "Function not implemented"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2204 |
sym = @symbol(ENOSYS); |
185 | 2205 |
break; |
77 | 2206 |
#endif |
359 | 2207 |
#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST) |
185 | 2208 |
case ENOTEMPTY: |
2209 |
msg = "Directory not empty"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2210 |
sym = @symbol(ENOTEMPTY); |
185 | 2211 |
break; |
77 | 2212 |
#endif |
2213 |
#ifdef EILSEQ |
|
185 | 2214 |
case EILSEQ: |
2215 |
msg = "Illegal byte sequence"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2216 |
sym = @symbol(EILSEQ); |
185 | 2217 |
break; |
77 | 2218 |
#endif |
185 | 2219 |
/* |
2220 |
* XPG3 errnos - defined on most systems |
|
2221 |
*/ |
|
77 | 2222 |
#ifdef ENOTBLK |
185 | 2223 |
case ENOTBLK: |
2224 |
msg = "Block device required"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2225 |
sym = @symbol(ENOTBLK); |
185 | 2226 |
break; |
77 | 2227 |
#endif |
2228 |
#ifdef ETXTBSY |
|
185 | 2229 |
case ETXTBSY: |
2230 |
msg = "Text file busy"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2231 |
sym = @symbol(ETXTBSY); |
185 | 2232 |
break; |
77 | 2233 |
#endif |
185 | 2234 |
/* |
2235 |
* some others |
|
2236 |
*/ |
|
77 | 2237 |
#ifdef EWOULDBLOCK |
185 | 2238 |
case EWOULDBLOCK: |
2239 |
msg = "Operation would block"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2240 |
sym = @symbol(EWOULDBLOCK); |
185 | 2241 |
break; |
77 | 2242 |
#endif |
2243 |
#ifdef ENOMSG |
|
185 | 2244 |
case ENOMSG: |
2245 |
msg = "No message of desired type"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2246 |
sym = @symbol(ENOMSG); |
185 | 2247 |
break; |
77 | 2248 |
#endif |
2249 |
#ifdef ELOOP |
|
185 | 2250 |
case ELOOP: |
2251 |
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
|
2252 |
sym = @symbol(ELOOP); |
185 | 2253 |
break; |
77 | 2254 |
#endif |
2255 |
||
185 | 2256 |
/* |
2257 |
* some stream errors |
|
2258 |
*/ |
|
77 | 2259 |
#ifdef ETIME |
185 | 2260 |
case ETIME: |
2261 |
msg = "Timer expired"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2262 |
sym = @symbol(ETIME); |
185 | 2263 |
break; |
77 | 2264 |
#endif |
2265 |
#ifdef ENOSR |
|
185 | 2266 |
case ENOSR: |
2267 |
msg = "Out of streams resources"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2268 |
sym = @symbol(ENOSR); |
185 | 2269 |
break; |
77 | 2270 |
#endif |
2271 |
#ifdef ENOSTR |
|
185 | 2272 |
case ENOSTR: |
2273 |
msg = "Device not a stream"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2274 |
sym = @symbol(ENOSTR); |
185 | 2275 |
break; |
77 | 2276 |
#endif |
2277 |
#ifdef ECOMM |
|
185 | 2278 |
case ECOMM: |
2279 |
msg = "Communication error on send"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2280 |
sym = @symbol(ECOMM); |
185 | 2281 |
break; |
77 | 2282 |
#endif |
2283 |
#ifdef EPROTO |
|
185 | 2284 |
case EPROTO: |
2285 |
msg = "Protocol error"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2286 |
sym = @symbol(EPROTO); |
185 | 2287 |
break; |
77 | 2288 |
#endif |
185 | 2289 |
/* |
2290 |
* nfs errors |
|
2291 |
*/ |
|
77 | 2292 |
#ifdef ESTALE |
185 | 2293 |
case ESTALE: |
2294 |
msg = "Stale NFS file handle"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2295 |
sym = @symbol(ESTALE); |
185 | 2296 |
break; |
77 | 2297 |
#endif |
2298 |
#ifdef EREMOTE |
|
185 | 2299 |
case EREMOTE: |
2300 |
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
|
2301 |
sym = @symbol(EREMOTE); |
185 | 2302 |
break; |
77 | 2303 |
#endif |
185 | 2304 |
/* |
2305 |
* some networking errors |
|
2306 |
*/ |
|
77 | 2307 |
#ifdef EINPROGRESS |
185 | 2308 |
case EINPROGRESS: |
2309 |
msg = "Operation now in progress"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2310 |
sym = @symbol(EINPROGRESS); |
185 | 2311 |
break; |
77 | 2312 |
#endif |
2313 |
#ifdef EALREADY |
|
185 | 2314 |
case EALREADY: |
2315 |
msg = "Operation already in progress"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2316 |
sym = @symbol(EALREADY); |
185 | 2317 |
break; |
77 | 2318 |
#endif |
2319 |
#ifdef ENOTSOCK |
|
185 | 2320 |
case ENOTSOCK: |
2321 |
msg = "Socket operation on non-socket"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2322 |
sym = @symbol(ENOTSOCK); |
185 | 2323 |
break; |
77 | 2324 |
#endif |
2325 |
#ifdef EDESTADDRREQ |
|
185 | 2326 |
case EDESTADDRREQ: |
2327 |
msg = "Destination address required"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2328 |
sym = @symbol(EDESTADDRREQ); |
185 | 2329 |
break; |
77 | 2330 |
#endif |
2331 |
#ifdef EMSGSIZE |
|
185 | 2332 |
case EMSGSIZE: |
2333 |
msg = "Message too long"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2334 |
sym = @symbol(EMSGSIZE); |
185 | 2335 |
break; |
77 | 2336 |
#endif |
2337 |
#ifdef EPROTOTYPE |
|
185 | 2338 |
case EPROTOTYPE: |
2339 |
msg = "Protocol wrong type for socket"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2340 |
sym = @symbol(EPROTOTYPE); |
185 | 2341 |
break; |
77 | 2342 |
#endif |
2343 |
#ifdef ENOPROTOOPT |
|
185 | 2344 |
case ENOPROTOOPT: |
2345 |
msg = "Protocol not available"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2346 |
sym = @symbol(ENOPROTOOPT); |
185 | 2347 |
break; |
77 | 2348 |
#endif |
2349 |
#ifdef EPROTONOSUPPORT |
|
185 | 2350 |
case EPROTONOSUPPORT: |
2351 |
msg = "Protocol not supported"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2352 |
sym = @symbol(EPROTONOSUPPORT); |
185 | 2353 |
break; |
77 | 2354 |
#endif |
2355 |
#ifdef ESOCKTNOSUPPORT |
|
185 | 2356 |
case ESOCKTNOSUPPORT: |
2357 |
msg = "Socket type not supported"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2358 |
sym = @symbol(ESOCKTNOSUPPORT); |
185 | 2359 |
break; |
77 | 2360 |
#endif |
2361 |
#ifdef EOPNOTSUPP |
|
185 | 2362 |
case EOPNOTSUPP: |
2363 |
msg = "Operation not supported on socket"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2364 |
sym = @symbol(EOPNOTSUPP); |
185 | 2365 |
break; |
77 | 2366 |
#endif |
2367 |
#ifdef EPFNOSUPPORT |
|
185 | 2368 |
case EPFNOSUPPORT: |
2369 |
msg = "Protocol family not supported"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2370 |
sym = @symbol(EPFNOSUPPORT); |
185 | 2371 |
break; |
77 | 2372 |
#endif |
2373 |
#ifdef EAFNOSUPPORT |
|
185 | 2374 |
case EAFNOSUPPORT: |
2375 |
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
|
2376 |
sym = @symbol(EAFNOSUPPORT); |
185 | 2377 |
break; |
77 | 2378 |
#endif |
2379 |
#ifdef EADDRINUSE |
|
185 | 2380 |
case EADDRINUSE: |
2381 |
msg = "Address already in use"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2382 |
sym = @symbol(EADDRINUSE); |
185 | 2383 |
break; |
77 | 2384 |
#endif |
2385 |
#ifdef EADDRNOTAVAIL |
|
185 | 2386 |
case EADDRNOTAVAIL: |
2387 |
msg = "Can\'t assign requested address"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2388 |
sym = @symbol(EADDRNOTAVAIL); |
185 | 2389 |
break; |
77 | 2390 |
#endif |
2391 |
#ifdef ETIMEDOUT |
|
185 | 2392 |
case ETIMEDOUT: |
2393 |
msg = "Connection timed out"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2394 |
sym = @symbol(ETIMEDOUT); |
185 | 2395 |
break; |
77 | 2396 |
#endif |
2397 |
#ifdef ECONNREFUSED |
|
185 | 2398 |
case ECONNREFUSED: |
2399 |
msg = "Connection refused"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2400 |
sym = @symbol(ECONNREFUSED); |
185 | 2401 |
break; |
77 | 2402 |
#endif |
362 | 2403 |
#ifdef ENETDOWN |
2404 |
case ENETDOWN: |
|
2405 |
msg = "Network is down"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2406 |
sym = @symbol(ENETDOWN); |
362 | 2407 |
break; |
2408 |
#endif |
|
2409 |
#ifdef ENETUNREACH |
|
2410 |
case ENETUNREACH: |
|
2411 |
msg = "Network is unreachable"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2412 |
sym = @symbol(ENETUNREACH); |
362 | 2413 |
break; |
2414 |
#endif |
|
2415 |
#ifdef ENETRESET |
|
2416 |
case ENETRESET: |
|
2417 |
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
|
2418 |
sym = @symbol(ENETRESET); |
362 | 2419 |
break; |
2420 |
#endif |
|
2421 |
#ifdef ECONNABORTED |
|
2422 |
case ECONNABORTED: |
|
2423 |
msg = "Software caused connection abort"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2424 |
sym = @symbol(ECONNABORTED); |
362 | 2425 |
break; |
2426 |
#endif |
|
2427 |
#ifdef ECONNRESET |
|
2428 |
case ECONNRESET: |
|
2429 |
msg = "Connection reset by peer"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2430 |
sym = @symbol(ECONNRESET); |
362 | 2431 |
break; |
2432 |
#endif |
|
2433 |
#ifdef EISCONN |
|
2434 |
case EISCONN: |
|
2435 |
msg = "Socket is already connected"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2436 |
sym = @symbol(EISCONN); |
362 | 2437 |
break; |
2438 |
#endif |
|
2439 |
#ifdef ENOTCONN |
|
2440 |
case ENOTCONN: |
|
2441 |
msg = "Socket is not connected"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2442 |
sym = @symbol(ENOTCONN); |
362 | 2443 |
break; |
2444 |
#endif |
|
2445 |
#ifdef ESHUTDOWN |
|
2446 |
case ESHUTDOWN: |
|
2447 |
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
|
2448 |
sym = @symbol(ESHUTDOWN); |
362 | 2449 |
break; |
2450 |
#endif |
|
2451 |
#ifdef EHOSTDOWN |
|
2452 |
case EHOSTDOWN: |
|
2453 |
msg = "Host is down"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2454 |
sym = @symbol(EHOSTDOWN); |
362 | 2455 |
break; |
2456 |
#endif |
|
2457 |
#ifdef EHOSTUNREACH |
|
2458 |
case EHOSTUNREACH: |
|
2459 |
msg = "No route to host"; |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2460 |
sym = @symbol(EHOSTUNREACH); |
362 | 2461 |
break; |
2462 |
#endif |
|
2463 |
||
185 | 2464 |
default: |
368 | 2465 |
{ |
809
5eef87c2907b
e convenient macro for register saving (sparc only)
Claus Gittinger <cg@exept.de>
parents:
805
diff
changeset
|
2466 |
__BEGIN_PROTECT_REGISTERS__ |
1135 | 2467 |
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
|
2468 |
__END_PROTECT_REGISTERS__ |
368 | 2469 |
} |
185 | 2470 |
msg = buffer; |
2471 |
break; |
|
2472 |
} |
|
77 | 2473 |
} |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2474 |
text = __MKSTRING(msg); |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2475 |
%}. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2476 |
^ Array with:sym with:text |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2477 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2478 |
" |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2479 |
OperatingSystem errorSymbolAndTextForNumber:4 |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2480 |
" |
616 | 2481 |
! |
2482 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2483 |
errorSymbolForNumber:errNr |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2484 |
"return a symbol for a unix errorNumber |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2485 |
(as returned by a system call)." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2486 |
|
1153
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
2487 |
^ (self errorSymbolAndTextForNumber:errNr) at:1 |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2488 |
|
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 |
OperatingSystem errorTextForNumber:4 |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2491 |
" |
1153
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
2492 |
|
8119975c55ce
Fix errorSymbolForNumber, add clearLastErrorNumber.
Stefan Vogel <sv@exept.de>
parents:
1142
diff
changeset
|
2493 |
"Modified: 12.4.1996 / 09:16:29 / stefan" |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2494 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2495 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2496 |
errorTextForNumber:errNr |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2497 |
"return a message string from a unix errorNumber |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2498 |
(as returned by a system call). |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2499 |
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
|
2500 |
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
|
2501 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2502 |
^ (self errorSymbolAndTextForNumber:errNr) at:2 |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2503 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2504 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2505 |
OperatingSystem errorTextForNumber:4 |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2506 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2507 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2508 |
|
616 | 2509 |
lastErrorNumber |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2510 |
"return the last errors number. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2511 |
See also: #lastErrorSymbol and #lastErrorString. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2512 |
Notice: having a single error number is a bad idea in a multithreaded |
1487 | 2513 |
environment - this interface will change." |
616 | 2514 |
|
2515 |
^ LastErrorNumber |
|
2516 |
||
2517 |
" |
|
2518 |
OperatingSystem lastErrorNumber |
|
2519 |
" |
|
2520 |
! |
|
2521 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2522 |
lastErrorString |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2523 |
"return a message string describing the last error. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2524 |
See also: #lastErrorNumber and #lastErrorSymbol. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2525 |
Notice: having a single error number is a bad idea in a multithreaded |
1487 | 2526 |
environment - this interface will change." |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2527 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2528 |
^ self errorTextForNumber:LastErrorNumber |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2529 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2530 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2531 |
OperatingSystem lastErrorString |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2532 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2533 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
2534 |
|
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2535 |
lastErrorSymbol |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2536 |
"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
|
2537 |
See also: #lastErrorNumber and #lastErrorString. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2538 |
Notice: having a single error number is a bad idea in a multithreaded |
1487 | 2539 |
environment - this interface will change." |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2540 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2541 |
^ self errorSymbolForNumber:LastErrorNumber |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2542 |
|
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2543 |
" |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2544 |
OperatingSystem lastErrorSymbol |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2545 |
" |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2546 |
! |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2547 |
|
616 | 2548 |
lastExecStatus |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2549 |
"return the last execution status. |
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
2550 |
Notice: having a single error number is a bad idea in a multithreaded |
1487 | 2551 |
environment - this interface will change." |
616 | 2552 |
|
2553 |
^ LastExecStatus |
|
2554 |
||
2555 |
" |
|
2556 |
OperatingSystem lastExecStatus |
|
2557 |
" |
|
1 | 2558 |
! ! |
2559 |
||
1497 | 2560 |
!OperatingSystem class methodsFor:'executing OS commands'! |
616 | 2561 |
|
2562 |
canExecuteCommand:aCommandString |
|
2563 |
"return true, if the OS can execute aCommand." |
|
2564 |
||
2565 |
|cmd| |
|
2566 |
||
2567 |
cmd := aCommandString asCollectionOfWords first. |
|
2568 |
^ (self pathOfCommand:cmd) notNil |
|
2569 |
||
2570 |
" |
|
2571 |
OperatingSystem canExecuteCommand:'fooBar' |
|
2572 |
OperatingSystem canExecuteCommand:'ls' |
|
2573 |
OperatingSystem canExecuteCommand:'cvs' |
|
2574 |
" |
|
2575 |
||
2576 |
"Created: 4.11.1995 / 19:13:54 / cg" |
|
68 | 2577 |
! |
2578 |
||
616 | 2579 |
exec:aPath withArguments:argArray |
2580 |
"execute the unix command specified by the argument, aPath, with |
|
2581 |
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
|
2582 |
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
|
2583 |
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
|
2584 |
to another program." |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2585 |
|
792 | 2586 |
^ 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
|
2587 |
! |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2588 |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2589 |
exec:aPath withArguments:argArray fileDescriptors:fdArray closeDescriptors:closeFdArray fork:doFork newPgrp:newPgrp |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2590 |
"Internal combined fork & exec; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2591 |
If fork is false: |
1487 | 2592 |
execute the unix command specified by the argument, aPath, with |
2593 |
arguments in argArray (no arguments, if nil). |
|
2594 |
If successful, this method does not return and smalltalk is gone. |
|
2595 |
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
|
2596 |
if its true: |
1487 | 2597 |
for a child to do the above. |
2598 |
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
|
2599 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2600 |
fdArray contains the filedescriptors, to be used for the child (if fork is true). |
1487 | 2601 |
fdArray[1] = 15 -> use fd 15 as stdin. |
2602 |
If an element of the array is set to nil, the corresponding filedescriptor |
|
2603 |
will be closed for the child. |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2604 |
|
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
2605 |
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
|
2606 |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2607 |
If newPgrp is true, the subprocess will be established in a new process group. |
1487 | 2608 |
Ths processgroup will be equal to id. |
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2609 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2610 |
Notice: this used to be two separate ST-methods; however, in order to use |
1487 | 2611 |
vfork on some machines, it had to be merged into one, to avoid write |
2612 |
accesses to ST/X memory from the vforked-child. The code below only does |
|
2613 |
read accesses." |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2614 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2615 |
%{ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2616 |
#ifndef MSDOS_LIKE |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2617 |
char **argv; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2618 |
int nargs, i, id; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2619 |
OBJ arg; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2620 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2621 |
if (__isString(aPath) && |
1487 | 2622 |
((argArray == nil) || __isArray(argArray)) && |
2623 |
((fdArray == nil) || __isArray(fdArray)) && |
|
2624 |
((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
|
2625 |
) { |
1487 | 2626 |
nargs = argArray == nil ? 0 : _arraySize(argArray); |
2627 |
argv = (char **) malloc(sizeof(char *) * (nargs + 1)); |
|
2628 |
if (argv) { |
|
2629 |
for (i=0; i < nargs; i++) { |
|
2630 |
arg = __ArrayInstPtr(argArray)->a_element[i]; |
|
2631 |
if (__isString(arg)) { |
|
2632 |
argv[i] = (char *) __stringVal(arg); |
|
2633 |
} else { |
|
2634 |
argv[i] = ""; |
|
2635 |
} |
|
2636 |
} |
|
2637 |
argv[i] = NULL; |
|
2638 |
||
2639 |
if (doFork == true) { |
|
2640 |
int nfd, nclose; |
|
2641 |
||
2642 |
nfd = fdArray == nil ? 0 : _arraySize(fdArray); |
|
2643 |
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
|
2644 |
#ifdef HAS_VFORK |
1487 | 2645 |
id = vfork(); |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2646 |
#else |
1487 | 2647 |
id = fork(); |
2648 |
#endif |
|
2649 |
if (id == 0) { |
|
2650 |
/* |
|
2651 |
** In child. |
|
2652 |
** first: dup filedescriptors |
|
2653 |
*/ |
|
2654 |
for (i = 0; i < nfd; i++) { |
|
2655 |
if (__isSmallInteger(__ArrayInstPtr(fdArray)->a_element[i]) && |
|
2656 |
__intVal(__ArrayInstPtr(fdArray)->a_element[i]) != i |
|
2657 |
) { |
|
2658 |
dup2(__intVal(__ArrayInstPtr(fdArray)->a_element[i]), i); |
|
2659 |
} |
|
2660 |
} |
|
2661 |
/* |
|
2662 |
** second: close unused filedescriptors |
|
2663 |
*/ |
|
2664 |
for (i = 0; i < nfd; i++) { |
|
2665 |
if (__ArrayInstPtr(fdArray)->a_element[i] == nil) { |
|
2666 |
close(i); |
|
2667 |
} |
|
2668 |
} |
|
2669 |
/* |
|
2670 |
** third: close filedescriptors |
|
2671 |
*/ |
|
2672 |
for (i = 0; i < nclose; i++) { |
|
2673 |
if (__isSmallInteger(__ArrayInstPtr(closeFdArray)->a_element[i])) { |
|
2674 |
close(__intVal(__ArrayInstPtr(closeFdArray)->a_element[i])); |
|
2675 |
} |
|
2676 |
} |
|
2677 |
if (newPgrp == true) { |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2678 |
#if defined(_POSIX_JOB_CONTROL) |
1487 | 2679 |
(void) setpgid(0, 0); |
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2680 |
#else |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2681 |
#if defined(BSD) |
1487 | 2682 |
(void) setpgrp(0); |
2683 |
#endif |
|
2684 |
#endif |
|
2685 |
} |
|
2686 |
||
2687 |
execv(__stringVal(aPath), argv); |
|
2688 |
/* should not be reached */ |
|
2689 |
_exit(127); /* POSIX 2 compatible exit value */ |
|
2690 |
} |
|
2691 |
/* |
|
2692 |
** In parent: succes or failure |
|
2693 |
*/ |
|
2694 |
free(argv); |
|
2695 |
RETURN (__MKSMALLINT(id)); |
|
2696 |
} else { |
|
2697 |
execv(__stringVal(aPath), argv); |
|
2698 |
/* |
|
2699 |
* should not be reached |
|
2700 |
* (well, it is, if you pass a wrong command-path) |
|
2701 |
*/ |
|
2702 |
free(argv); |
|
2703 |
RETURN ( false ); |
|
2704 |
} |
|
2705 |
} |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2706 |
} |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2707 |
#endif |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2708 |
%}. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2709 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2710 |
path-argument not string |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2711 |
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
|
2712 |
or malloc failed |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2713 |
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
|
2714 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2715 |
^ self primitiveFailed |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2716 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2717 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2718 |
|id| |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2719 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2720 |
id := OperatingSystem fork. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2721 |
id == 0 ifTrue:[ |
1487 | 2722 |
"I am the child" |
2723 |
OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp'). |
|
2724 |
"not reached" |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2725 |
] |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2726 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2727 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2728 |
|id| |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2729 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2730 |
id := OperatingSystem fork. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2731 |
id == 0 ifTrue:[ |
1487 | 2732 |
"I am the child" |
2733 |
OperatingSystem exec:'/bin/sh' withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2'). |
|
2734 |
"not reached" |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2735 |
]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2736 |
id printNL. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2737 |
(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
|
2738 |
'killing ...' printNL. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2739 |
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
|
2740 |
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
|
2741 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2742 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2743 |
|
1076
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2744 |
exec:aPath withArguments:argArray fileDescriptors:fdArray fork:doFork |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2745 |
"Internal combined fork & exec; |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2746 |
If fork is false: |
1487 | 2747 |
execute the unix command specified by the argument, aPath, with |
2748 |
arguments in argArray (no arguments, if nil). |
|
2749 |
If successful, this method does not return and smalltalk is gone. |
|
2750 |
If not successful, false is returned. Normal use is with forkForCommand. |
|
1076
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2751 |
if its true: |
1487 | 2752 |
for a child to do the above. |
2753 |
The id of the child process is returned; -1 if fork failed. |
|
1076
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2754 |
|
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2755 |
fdArray contains the filedescriptors, to be used for the child (if fork is true). |
1487 | 2756 |
fdArray[1] = 15 -> use fd 15 as stdin. |
2757 |
If an element of the array is set to nil, the corresponding filedescriptor |
|
2758 |
will be closed for the child. |
|
1076
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2759 |
|
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2760 |
Notice: this used to be two separate ST-methods; however, in order to use |
1487 | 2761 |
vfork on some machines, it had to be merged into one, to avoid write |
2762 |
accesses to ST/X memory from the vforked-child. The code below only does |
|
2763 |
read accesses." |
|
1076
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2764 |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2765 |
^ self exec:aPath withArguments:argArray fileDescriptors:fdArray closeDescriptors:nil fork:doFork newPgrp:false |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2766 |
|
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
2767 |
"Modified: 23.4.1996 / 17:05:41 / stefan" |
1076
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2768 |
! |
0bfb3317718b
backward compatibility: #exec:withArguments:fileDescriptors:fork:
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
2769 |
|
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2770 |
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
|
2771 |
"Internal combined fork & exec; |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2772 |
If fork is false: |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2773 |
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
|
2774 |
arguments in argArray (no arguments, if nil). |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2775 |
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
|
2776 |
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
|
2777 |
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
|
2778 |
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
|
2779 |
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
|
2780 |
|
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2781 |
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
|
2782 |
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
|
2783 |
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
|
2784 |
read accesses." |
616 | 2785 |
|
2786 |
%{ |
|
792 | 2787 |
#ifndef MSDOS_LIKE |
616 | 2788 |
char **argv; |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2789 |
int nargs, i, id; |
616 | 2790 |
OBJ arg; |
2791 |
||
2792 |
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
|
2793 |
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
|
2794 |
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
|
2795 |
if (argv) { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2796 |
for (i=0; i < nargs; i++) { |
1135 | 2797 |
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
|
2798 |
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
|
2799 |
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
|
2800 |
} else { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2801 |
argv[i] = ""; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2802 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2803 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2804 |
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
|
2805 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2806 |
if (doFork == true) { |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2807 |
#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
|
2808 |
id = vfork(); |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2809 |
#else |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2810 |
id = fork(); |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2811 |
#endif |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2812 |
if (id == 0) { |
1135 | 2813 |
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
|
2814 |
/* 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
|
2815 |
_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
|
2816 |
} |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2817 |
free(argv); |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2818 |
RETURN (__MKSMALLINT(id)); |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2819 |
} else { |
1135 | 2820 |
execv(__stringVal(aPath), argv); |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2821 |
/* |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2822 |
* should not be reached |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2823 |
* (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
|
2824 |
*/ |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2825 |
free(argv); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2826 |
RETURN ( false ); |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2827 |
} |
616 | 2828 |
} |
2829 |
} |
|
792 | 2830 |
#endif |
616 | 2831 |
%}. |
2832 |
" |
|
792 | 2833 |
path-argument not string |
2834 |
or argArray not an array/nil |
|
2835 |
or malloc failed |
|
2836 |
or not supported by OS |
|
616 | 2837 |
" |
2838 |
^ self primitiveFailed |
|
2839 |
||
2840 |
" |
|
2841 |
|id| |
|
2842 |
||
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2843 |
id := OperatingSystem fork. |
616 | 2844 |
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
|
2845 |
"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
|
2846 |
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
|
2847 |
"not reached" |
616 | 2848 |
] |
2849 |
" |
|
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2850 |
" |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2851 |
|id| |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2852 |
|
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2853 |
id := OperatingSystem fork. |
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2854 |
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
|
2855 |
"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
|
2856 |
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
|
2857 |
"not reached" |
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2858 |
]. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2859 |
id printNL. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2860 |
(Delay forSeconds:3.5) wait. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2861 |
'killing ...' printNL. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2862 |
OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2863 |
OperatingSystem sendSignal:(OperatingSystem sigKILL) to:id |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2864 |
" |
616 | 2865 |
! |
2866 |
||
2867 |
executeCommand:aCommandString |
|
2868 |
"execute the unix command specified by the argument, aCommandString. |
|
676 | 2869 |
The commandString is passed to a shell for execution - see the description of |
2870 |
'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
|
2871 |
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
|
2872 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2873 |
" 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
|
2874 |
^ 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
|
2875 |
until then:" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2876 |
|
616 | 2877 |
%{ |
2878 |
int status; |
|
2879 |
||
2880 |
if (__isString(aCommandString)) { |
|
2881 |
/* |
|
2882 |
* ST/X provides a modified (fixed) implementation of the |
|
2883 |
* system() libc-function, which is interruptable ... |
|
2884 |
*/ |
|
2885 |
# ifdef WANT_SYSTEM |
|
1135 | 2886 |
status = mySystem((char *) __stringVal(aCommandString)); |
616 | 2887 |
# else |
1135 | 2888 |
status = system((char *) __stringVal(aCommandString)); |
616 | 2889 |
# endif |
1135 | 2890 |
OperatingSystem_LastExecStatus = __MKSMALLINT(status); |
616 | 2891 |
if (status == 0) { |
2892 |
RETURN ( true ); |
|
2893 |
} |
|
1135 | 2894 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 2895 |
RETURN ( false ); |
2896 |
} |
|
2897 |
%}. |
|
792 | 2898 |
"/ |
2899 |
"/ invalid argument (non-string) |
|
2900 |
"/ |
|
2901 |
^ self primitiveFailed |
|
616 | 2902 |
|
2903 |
" |
|
805 | 2904 |
OperatingSystem executeCommand:'sleep 30'. |
616 | 2905 |
OperatingSystem executeCommand:'pwd'. |
2906 |
OperatingSystem executeCommand:'ls -l'. |
|
2907 |
OperatingSystem executeCommand:'invalidCommand'. |
|
2908 |
OperatingSystem executeCommand:'rm /tmp/foofoofoofoo'. |
|
2909 |
" |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2910 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2911 |
"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
|
2912 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2913 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2914 |
executeCommand:aCommandString onError:aBlock |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2915 |
"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
|
2916 |
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
|
2917 |
'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
|
2918 |
Return true if successful. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2919 |
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
|
2920 |
as argument." |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2921 |
|
1034 | 2922 |
|pid exitStatus sema| |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2923 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2924 |
sema := Semaphore new. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2925 |
|
1034 | 2926 |
[ |
1487 | 2927 |
pid := self startProcess:aCommandString. |
2928 |
pid > 0 ifTrue:[ |
|
2929 |
Processor monitorPid:pid action:[:status | |
|
2930 |
status stillAlive ifFalse:[ |
|
2931 |
exitStatus := status. |
|
2932 |
sema signal |
|
2933 |
]. |
|
2934 |
]. |
|
2935 |
sema wait. |
|
2936 |
] ifFalse:[ |
|
2937 |
exitStatus := OSProcessStatus processCreationFailure. |
|
2938 |
]. |
|
1034 | 2939 |
] valueUninterruptably. |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2940 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2941 |
exitStatus success ifFalse:[ |
1487 | 2942 |
^ aBlock value:exitStatus |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2943 |
]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2944 |
^ true. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2945 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2946 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2947 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2948 |
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
|
2949 |
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
|
2950 |
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
|
2951 |
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
|
2952 |
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
|
2953 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2954 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2955 |
"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
|
2956 |
"Modified: 28.12.1995 / 15:25:48 / stefan" |
1034 | 2957 |
"Modified: 28.2.1996 / 21:41:23 / cg" |
616 | 2958 |
! |
2959 |
||
2960 |
fork |
|
2961 |
"fork a new (HEAVY-weight) unix process. |
|
2962 |
Dont confuse this with Block>>fork, which creates |
|
2963 |
lightweight smalltalk processes. This method will return |
|
676 | 2964 |
0 to the child process, and a non-zero number (which is the childs |
2965 |
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
|
2966 |
|
676 | 2967 |
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
|
2968 |
#startProcess: and #executCommand: for higher level interfaces." |
68 | 2969 |
|
2970 |
%{ /* NOCONTEXT */ |
|
792 | 2971 |
#ifndef MSDOS_LIKE |
616 | 2972 |
|
2973 |
int pid; |
|
2974 |
||
2975 |
pid = fork(); |
|
1135 | 2976 |
RETURN ( __MKSMALLINT(pid) ); |
792 | 2977 |
#endif |
2978 |
%}. |
|
2979 |
"/ |
|
2980 |
"/ not supported by OS |
|
2981 |
"/ |
|
2982 |
^ self primitiveFailed |
|
2983 |
||
616 | 2984 |
" |
2985 |
|id| |
|
2986 |
||
2987 |
id := OperatingSystem fork. |
|
2988 |
id == 0 ifTrue:[ |
|
2989 |
OperatingSystem exit |
|
2990 |
] |
|
2991 |
" |
|
68 | 2992 |
! |
2993 |
||
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2994 |
getStatusOfProcess:aProcessId |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2995 |
"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
|
2996 |
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
|
2997 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2998 |
%{ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2999 |
#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
|
3000 |
int status; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3001 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3002 |
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
|
3003 |
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
|
3004 |
{ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3005 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3006 |
# 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
|
3007 |
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
|
3008 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3009 |
do { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3010 |
__BEGIN_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3011 |
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
|
3012 |
__END_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3013 |
if (child < 0 && errno != EINTR) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
3014 |
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
|
3015 |
status = -1; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3016 |
break; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3017 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3018 |
} 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
|
3019 |
# else |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3020 |
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
|
3021 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3022 |
/* 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
|
3023 |
do { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3024 |
__BEGIN_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3025 |
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
|
3026 |
__END_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3027 |
} 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
|
3028 |
if (child != pid) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
3029 |
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
|
3030 |
status = -1; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3031 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3032 |
# 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
|
3033 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3034 |
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
|
3035 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3036 |
#endif |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3037 |
%}. |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3038 |
self primitiveFailed |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3039 |
|
1034 | 3040 |
! |
3041 |
||
3042 |
pathOfCommand:aCommand |
|
3043 |
"find where aCommand's executable file is" |
|
3044 |
||
3045 |
|path f| |
|
3046 |
||
3047 |
path := self getEnvironment:'PATH'. |
|
3048 |
path notNil ifTrue:[ |
|
3049 |
(path asCollectionOfSubstringsSeparatedBy:$:) do:[:path | |
|
3050 |
(f := (path asFilename construct:aCommand)) isExecutable ifTrue:[ |
|
3051 |
^ f pathName |
|
3052 |
] |
|
3053 |
]. |
|
3054 |
]. |
|
3055 |
^ nil |
|
3056 |
||
3057 |
" |
|
3058 |
OperatingSystem pathOfCommand:'fooBar' |
|
3059 |
OperatingSystem pathOfCommand:'ls' |
|
3060 |
OperatingSystem pathOfCommand:'cvs' |
|
3061 |
" |
|
3062 |
! |
|
3063 |
||
3064 |
startProcess:aCommandString |
|
3065 |
"start executing the unix command as specified by the argument, aCommandString |
|
3066 |
as a separate process; do not wait for the command to finish. |
|
3067 |
The commandString is passed to a shell for execution - see the description of |
|
3068 |
'sh -c' in your UNIX manual. |
|
3069 |
Return the processId if successful, nil otherwise. |
|
3070 |
Use #waitForProcess: for synchronization and exec status return, |
|
3071 |
or #killProcess: to stop it." |
|
3072 |
||
3073 |
^ self |
|
3074 |
exec:'/bin/sh' |
|
3075 |
withArguments:(Array with:'sh' with:'-c' with:aCommandString) |
|
3076 |
fork:true. |
|
3077 |
||
3078 |
" |
|
3079 |
|pid| |
|
3080 |
||
3081 |
pid := OperatingSystem startProcess:'sleep 2; echo 1; sleep 2; echo 2'. |
|
3082 |
(Delay forSeconds:3) wait. |
|
3083 |
OperatingSystem killProcess:pid. |
|
3084 |
" |
|
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3085 |
! |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3086 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3087 |
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
|
3088 |
"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
|
3089 |
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
|
3090 |
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
|
3091 |
'sh -c' in your UNIX manual. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3092 |
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
|
3093 |
each may be nil. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3094 |
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
|
3095 |
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
|
3096 |
or #killProcess: to stop it." |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3097 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3098 |
|in out err| |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3099 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3100 |
anExternalInStream notNil ifTrue:[ |
1487 | 3101 |
in := anExternalInStream fileDescriptor. |
1046 | 3102 |
] ifFalse:[ |
1487 | 3103 |
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
|
3104 |
]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3105 |
anExternalOutStream notNil ifTrue:[ |
1487 | 3106 |
out := anExternalOutStream fileDescriptor. |
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3107 |
]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3108 |
anExternalErrStream notNil ifTrue:[ |
1487 | 3109 |
err := anExternalErrStream fileDescriptor. |
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3110 |
]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3111 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3112 |
^ self |
1487 | 3113 |
exec:'/bin/sh' |
3114 |
withArguments:(Array with:'sh' with:'-c' with:aCommandString) |
|
3115 |
fileDescriptors:(Array with:in with:out with:err) |
|
3116 |
fork:true. |
|
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3117 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3118 |
"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
|
3119 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3120 |
OperatingSystem executeCommand:'ls -l > out'. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3121 |
" |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3122 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3123 |
"non-blocking (lower prio threads continue): |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3124 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3125 |
|in out err pid sema| |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3126 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3127 |
in := 'out' asFilename readStream. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3128 |
out := 'out2' asFilename writeStream. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3129 |
err := 'err' asFilename writeStream. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3130 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3131 |
sema := Semaphore new. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3132 |
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
|
3133 |
pid notNil ifTrue:[ |
1487 | 3134 |
Processor monitorPid:pid action:[:OSstatus | sema signal ]. |
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3135 |
]. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3136 |
in close. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3137 |
out close. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3138 |
err close. |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3139 |
sema wait. |
1422 | 3140 |
Transcript showCR:'finished' |
1045
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3141 |
" |
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3142 |
|
c7a38395a1d4
added user-friendly interface: #startProcess:inputFrom:outputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
3143 |
"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
|
3144 |
"Modified: 29.2.1996 / 12:49:14 / cg" |
616 | 3145 |
! ! |
3146 |
||
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3147 |
!OperatingSystem class methodsFor:'file access'! |
616 | 3148 |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3149 |
closeFd:anInteger |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3150 |
"low level close of a filedescriptor" |
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 |
%{ |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3153 |
#if !defined(transputer) && !defined(MSDOS_LIKE) |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3154 |
if (__isSmallInteger(anInteger)) { |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3155 |
close(__intVal(anInteger)); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3156 |
RETURN(self); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3157 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3158 |
#endif |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3159 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3160 |
^ self primitiveFailed. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3161 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3162 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3163 |
createDirectory:newPathName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3164 |
"create a new directory with name 'newPathName'. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3165 |
Return true if successful, false if failed. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3166 |
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
|
3167 |
|
1497 | 3168 |
"/ if it already exists this is ok |
3169 |
||
3170 |
(self isDirectory:newPathName) ifTrue:[^ true]. |
|
3171 |
||
3172 |
"/ since createDirectory is not used too often, |
|
3173 |
"/ you'll forgive me using mkdir ... |
|
1084
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 |
^ self executeCommand:('mkdir 2>/dev/null ', newPathName) |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3176 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3177 |
" |
1497 | 3178 |
OperatingSystem createDirectory:'foo' |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3179 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3180 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3181 |
"Modified: 20.12.1995 / 11:24:13 / stefan" |
1497 | 3182 |
"Modified: 29.6.1996 / 14:06:54 / cg" |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3183 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3184 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3185 |
linkFile:oldPath to:newPath |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3186 |
"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
|
3187 |
Return true if successful, false if not." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3188 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3189 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3190 |
#ifndef MSDOS_LIKE |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3191 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3192 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3193 |
if (__isString(oldPath) && __isString(newPath)) { |
1487 | 3194 |
__BEGIN_INTERRUPTABLE__ |
3195 |
do { |
|
3196 |
ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath)); |
|
3197 |
} while (ret < 0 && errno == EINTR); |
|
3198 |
__END_INTERRUPTABLE__ |
|
3199 |
if (ret < 0) { |
|
3200 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3201 |
RETURN ( false ); |
|
3202 |
} |
|
3203 |
RETURN (true); |
|
1084
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 |
#endif |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3206 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3207 |
^ self primitiveFailed |
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 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3210 |
OperatingSystem linkFile:'foo' to:'bar' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3211 |
" |
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 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3214 |
makePipe |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3215 |
"make a pipe, return array with two filedescriptors on success, |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3216 |
nil on failure. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3217 |
This is a lowLevel entry, not for public use. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3218 |
See ExternalStream>>makePipe for a more user-friendly, public interface." |
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 |
|fd1 fd2| |
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 |
%{ |
1597 | 3223 |
#ifdef UNIX_LIKE |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3224 |
int fds[2]; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3225 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3226 |
if (pipe(fds) < 0) { |
1487 | 3227 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
3228 |
RETURN ( nil ); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3229 |
} |
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 |
fd1 = __MKSMALLINT(fds[0]); |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3232 |
fd2 = __MKSMALLINT(fds[1]); |
1597 | 3233 |
#endif |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3234 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3235 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3236 |
^ Array with:fd1 with:fd2. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3237 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3238 |
|
1132 | 3239 |
recursiveCopyDirectory:sourcePathName to:destination |
3240 |
"copy the directory named 'sourcePathName' and all contained files/directories to 'destination'. |
|
3241 |
Return true if successful." |
|
3242 |
||
3243 |
^ self executeCommand:('cp -rf ' , sourcePathName, ' ', destination) |
|
3244 |
||
3245 |
"Modified: 7.3.1996 / 15:26:30 / cg" |
|
3246 |
! |
|
3247 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3248 |
recursiveCreateDirectory:dirName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3249 |
"create a directory - with all parent dirs if needed. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3250 |
Return true if successful, false otherwise. If false |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3251 |
is returned, a partial created tree may be left, |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3252 |
which is not cleaned-up here." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3253 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3254 |
self createDirectory:dirName. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3255 |
(self isDirectory:dirName) ifFalse:[ |
1487 | 3256 |
(self recursiveCreateDirectory:(self directoryNameOf:dirName)) ifFalse:[^ false]. |
3257 |
^ self createDirectory:dirName |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3258 |
]. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3259 |
^ true |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3260 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3261 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3262 |
OperatingSystem recursiveCreateDirectory:'foo/bar/baz' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3263 |
OperatingSystem recursiveRemoveDirectory:'foo' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3264 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3265 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3266 |
"Modified: 7.3.1996 / 15:26:22 / cg" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3267 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3268 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3269 |
recursiveRemoveDirectory:fullPathName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3270 |
"remove the directory named 'fullPathName' and all contained files/directories. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3271 |
Return true if successful." |
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 executeCommand:('rm -rf ' , fullPathName) |
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 |
OperatingSystem recursiveCreateDirectory:'foo/bar/baz' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3277 |
OperatingSystem recursiveRemoveDirectory:'foo' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3278 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3279 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3280 |
"Modified: 7.3.1996 / 15:26:30 / cg" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3281 |
! |
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 |
removeDirectory:fullPathName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3284 |
"remove the directory named 'fullPathName'. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3285 |
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
|
3286 |
This is a lowLevel entry - use Filename protocol for compatibility." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3287 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3288 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3289 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3290 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3291 |
if (__isString(fullPathName)) { |
1487 | 3292 |
__BEGIN_INTERRUPTABLE__ |
3293 |
do { |
|
3294 |
ret = rmdir((char *) __stringVal(fullPathName)); |
|
3295 |
} while (ret < 0 && errno == EINTR); |
|
3296 |
__END_INTERRUPTABLE__ |
|
3297 |
if (ret < 0) { |
|
3298 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3299 |
RETURN ( false ); |
|
3300 |
} |
|
3301 |
RETURN (true); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3302 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3303 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3304 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3305 |
|
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 |
OperatingSystem createDirectory:'foo' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3308 |
OperatingSystem removeDirectory:'foo' |
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 |
|
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 |
removeFile:fullPathName |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3314 |
"remove the file named 'fullPathName'; return true if successful. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3315 |
This is a lowLevel entry - use Filename protocol for compatibility." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3316 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3317 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3318 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3319 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3320 |
if (__isString(fullPathName)) { |
1487 | 3321 |
__BEGIN_INTERRUPTABLE__ |
3322 |
do { |
|
3323 |
ret = unlink((char *) __stringVal(fullPathName)); |
|
3324 |
} while (ret < 0 && errno == EINTR); |
|
3325 |
__END_INTERRUPTABLE__ |
|
3326 |
if (ret < 0) { |
|
3327 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3328 |
RETURN ( false ); |
|
3329 |
} |
|
3330 |
RETURN (true); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3331 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3332 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3333 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3334 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3335 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3336 |
renameFile:oldPath to:newPath |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3337 |
"rename the file 'oldPath' to 'newPath'. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3338 |
Return true if successful, false if not" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3339 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3340 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3341 |
int ret, eno; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3342 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3343 |
if (__isString(oldPath) && __isString(newPath)) { |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3344 |
#if defined(HAS_RENAME) |
1487 | 3345 |
__BEGIN_INTERRUPTABLE__ |
3346 |
do { |
|
3347 |
ret = rename((char *) __stringVal(oldPath), (char *) __stringVal(newPath)); |
|
3348 |
} while (ret < 0 && errno == EINTR); |
|
3349 |
__END_INTERRUPTABLE__ |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3350 |
#else |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3351 |
# ifndef MSDOS_LIKE |
1487 | 3352 |
ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath)); |
3353 |
if (ret >= 0) { |
|
3354 |
ret = unlink((char *) __stringVal(oldPath)); |
|
3355 |
if (ret < 0) { |
|
3356 |
eno = errno; |
|
3357 |
unlink((char *) __stringVal(newPath)); |
|
3358 |
errno = eno; |
|
3359 |
} |
|
3360 |
} |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3361 |
# endif |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3362 |
#endif |
1487 | 3363 |
if (ret < 0) { |
3364 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3365 |
RETURN ( false ); |
|
3366 |
} |
|
3367 |
RETURN (true); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3368 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3369 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3370 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3371 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3372 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3373 |
OperatingSystem renameFile:'foo' to:'bar' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3374 |
" |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3375 |
! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3376 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3377 |
truncateFile:aPathName to:newSize |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3378 |
"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
|
3379 |
This may not be supported on all architectures. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3380 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3381 |
This is a low-level entry - use Filename protocol." |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3382 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3383 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3384 |
#ifdef HAS_FTRUNCATE |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3385 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3386 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3387 |
if (__isString(aPathName) |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3388 |
&& __isSmallInteger(newSize)) { |
1487 | 3389 |
__BEGIN_INTERRUPTABLE__ |
3390 |
do { |
|
3391 |
ret = truncate((char *) __stringVal(aPathName), __intVal(newSize)); |
|
3392 |
} while (ret < 0 && errno == EINTR); |
|
3393 |
__END_INTERRUPTABLE__ |
|
3394 |
if (ret < 0) { |
|
3395 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3396 |
RETURN ( false ); |
|
3397 |
} |
|
3398 |
RETURN (true); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3399 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3400 |
#endif |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3401 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3402 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3403 |
! ! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3404 |
|
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3405 |
!OperatingSystem class methodsFor:'file access rights'! |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3406 |
|
616 | 3407 |
accessMaskFor:aSymbol |
3408 |
"return the access bits mask for numbers as returned by |
|
3409 |
OperatingSystem>>accessModeOf: |
|
3410 |
and expected by OperatingSystem>>changeAccessModeOf:to:. |
|
3411 |
Since these numbers are OS dependent, always use the mask |
|
3412 |
(never hardcode 8rxxx into your code)." |
|
68 | 3413 |
|
3414 |
%{ /* NOCONTEXT */ |
|
616 | 3415 |
# ifndef S_IRUSR |
3416 |
/* posix systems should define these ... */ |
|
3417 |
# define S_IRUSR 0400 |
|
3418 |
# define S_IWUSR 0200 |
|
3419 |
# define S_IXUSR 0100 |
|
3420 |
# define S_IRGRP 0040 |
|
3421 |
# define S_IWGRP 0020 |
|
3422 |
# define S_IXGRP 0010 |
|
3423 |
# define S_IROTH 0004 |
|
3424 |
# define S_IWOTH 0002 |
|
3425 |
# define S_IXOTH 0001 |
|
3426 |
||
3427 |
# endif |
|
3428 |
||
3429 |
if (aSymbol == @symbol(readUser)) { |
|
1135 | 3430 |
RETURN ( __MKSMALLINT(S_IRUSR) ); |
616 | 3431 |
} |
3432 |
if (aSymbol == @symbol(writeUser)) { |
|
1135 | 3433 |
RETURN ( __MKSMALLINT(S_IWUSR) ); |
616 | 3434 |
} |
3435 |
if (aSymbol == @symbol(executeUser)) { |
|
1135 | 3436 |
RETURN ( __MKSMALLINT(S_IXUSR) ); |
616 | 3437 |
} |
3438 |
if (aSymbol == @symbol(readGroup)) { |
|
1135 | 3439 |
RETURN ( __MKSMALLINT(S_IRGRP) ); |
616 | 3440 |
} |
3441 |
if (aSymbol == @symbol(writeGroup)) { |
|
1135 | 3442 |
RETURN ( __MKSMALLINT(S_IWGRP) ); |
616 | 3443 |
} |
3444 |
if (aSymbol == @symbol(executeGroup)) { |
|
1135 | 3445 |
RETURN ( __MKSMALLINT(S_IXGRP) ); |
616 | 3446 |
} |
3447 |
if (aSymbol == @symbol(readOthers)) { |
|
1135 | 3448 |
RETURN ( __MKSMALLINT(S_IROTH) ); |
616 | 3449 |
} |
3450 |
if (aSymbol == @symbol(writeOthers)) { |
|
1135 | 3451 |
RETURN ( __MKSMALLINT(S_IWOTH) ); |
616 | 3452 |
} |
3453 |
if (aSymbol == @symbol(executeOthers)) { |
|
1135 | 3454 |
RETURN ( __MKSMALLINT(S_IXOTH) ); |
616 | 3455 |
} |
3456 |
%}. |
|
792 | 3457 |
^ self primitiveFailed |
616 | 3458 |
|
3459 |
" |
|
3460 |
OperatingSystem accessMaskFor:#readUser |
|
3461 |
" |
|
68 | 3462 |
! |
3463 |
||
616 | 3464 |
accessModeOf:aPathName |
3465 |
"return a number representing access rights rwxrwxrwx for owner, |
|
3466 |
group and others. Return nil if such a file does not exist. |
|
3467 |
Notice that the returned number is OS dependent - use the |
|
3468 |
modeMasks as returned by OperatingSystem>>accessMaskFor:" |
|
3469 |
||
3470 |
" |
|
3471 |
this could have been implemented as: |
|
1487 | 3472 |
(self infoOf:aPathName) at:#mode |
616 | 3473 |
but for huge directory searches the code below is faster |
3474 |
" |
|
345 | 3475 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3476 |
%{ |
616 | 3477 |
struct stat buf; |
3478 |
int ret; |
|
3479 |
||
3480 |
if (__isString(aPathName)) { |
|
1487 | 3481 |
__BEGIN_INTERRUPTABLE__ |
3482 |
do { |
|
3483 |
ret = stat((char *) __stringVal(aPathName), &buf); |
|
3484 |
} while ((ret < 0) && (errno == EINTR)); |
|
3485 |
__END_INTERRUPTABLE__ |
|
3486 |
||
3487 |
if (ret < 0) { |
|
3488 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3489 |
RETURN ( nil ); |
|
3490 |
} |
|
3491 |
RETURN ( __MKSMALLINT(buf.st_mode & 0777) ); |
|
616 | 3492 |
} |
3493 |
%}. |
|
792 | 3494 |
^ self primitiveFailed |
616 | 3495 |
|
3496 |
" |
|
3497 |
(OperatingSystem accessModeOf:'/') printStringRadix:8 |
|
3498 |
" |
|
345 | 3499 |
! |
3500 |
||
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3501 |
changeAccessModeOf:aPathName to:modeBits |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3502 |
"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
|
3503 |
You should construct this mask using accessMaskFor, to be OS |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3504 |
independent. Return true if changed, |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3505 |
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
|
3506 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3507 |
%{ |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3508 |
int ret; |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3509 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3510 |
if (__isString(aPathName) && __isSmallInteger(modeBits)) { |
1487 | 3511 |
__BEGIN_INTERRUPTABLE__ |
3512 |
do { |
|
3513 |
ret = chmod((char *)__stringVal(aPathName), __intVal(modeBits)); |
|
3514 |
} while (ret < 0 && errno == EINTR); |
|
3515 |
__END_INTERRUPTABLE__ |
|
3516 |
if (ret < 0) { |
|
3517 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3518 |
RETURN ( false ); |
|
3519 |
} |
|
3520 |
RETURN ( true ); |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3521 |
} |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3522 |
%}. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3523 |
^ self primitiveFailed |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3524 |
! ! |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3525 |
|
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3526 |
!OperatingSystem class methodsFor:'file locking'! |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3527 |
|
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3528 |
advisoryLockFD:aFileDescriptor blocking:blockIfLocked |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3529 |
"set an advisory lock on the file represented by aFileDescriptor. |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3530 |
(such as returned by ExternalStream>>fileDescriptor). |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3531 |
An advisory lock depends on other accessors to also perform |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3532 |
the locking operation - if they do not, they can still access the |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3533 |
file. |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3534 |
Returns true, if the lock was aquired, false otherwise. |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3535 |
Notice, that not all OS's support these locks; on some, this may |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3536 |
simply be a no-op. |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3537 |
Also notice, that some systems block the process, to wait for the lock. |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3538 |
This can (again: on some systems) be avoided by passing a false blockIfLocked |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3539 |
argument." |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3540 |
|
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3541 |
%{ |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3542 |
if (__isSmallInteger(aFileDescriptor)) { |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3543 |
int fd = __intVal(aFileDescriptor); |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3544 |
int lockArg; |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3545 |
|
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3546 |
#if defined(LOCK_EX) && defined(LOCK_UN) |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3547 |
/* BSD 4.3 advisory locks */ |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3548 |
lockArg = LOCK_EX; |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3549 |
# if defined(LOCK_NB) |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3550 |
if (blockIfLocked == false) { |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3551 |
lockArg |= LOCK_NB; |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3552 |
} |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3553 |
# endif |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3554 |
if (flock(fd, lockArg) != -1) { |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3555 |
RETURN (true); |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3556 |
} |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3557 |
#else |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3558 |
# if defined(F_LOCK) && defined(F_UNLOCK) |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3559 |
/* SYSV3 advisory locks */ |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3560 |
if (lockf(fd, F_LOCK, 0) != -1) { |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3561 |
RETURN (true); |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3562 |
} |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3563 |
# endif |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3564 |
#endif |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3565 |
} |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3566 |
%}. |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3567 |
^ false |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3568 |
! |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3569 |
|
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3570 |
advisoryUnlockFD:aFileDescriptor |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3571 |
"clear an advisory lock on the file represented by aFileDescriptor, |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3572 |
which was previously aquired by #advisoryLockFD:. |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3573 |
Return false, if the unlock failed (which only happens when a wrong |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3574 |
fd is passed). |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3575 |
Notice, that not all OS's support these locks; on some, this may |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3576 |
simply be a no-op." |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3577 |
|
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3578 |
%{ |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3579 |
if (__isSmallInteger(aFileDescriptor)) { |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3580 |
int fd = __intVal(aFileDescriptor); |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3581 |
|
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3582 |
#if defined(LOCK_EX) && defined(LOCK_UN) |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3583 |
/* BSD 4.3 advisory locks */ |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3584 |
if (flock(fd, LOCK_UN) != -1) { |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3585 |
RETURN (true); |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3586 |
} |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3587 |
#else |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3588 |
# if defined(F_LOCK) && defined(F_UNLOCK) |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3589 |
/* SYSV3 advisory locks */ |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3590 |
if (lockf(fd, F_UNLOCK, 0) != -1) { |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3591 |
RETURN (true); |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3592 |
} |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3593 |
# endif |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3594 |
#endif |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3595 |
} |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3596 |
%}. |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3597 |
^ false |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3598 |
! |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3599 |
|
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3600 |
supportAdvisoryLocks |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3601 |
"return true, if the OS supports advisory file locking" |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3602 |
|
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3603 |
%{ /* NOCONTEXT */ |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3604 |
#if defined(LOCK_EX) && defined(LOCK_UN) |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3605 |
RETURN (true); |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3606 |
#else |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3607 |
# if defined(F_LOCK) && defined(F_UNLOCK) |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3608 |
RETURN (true); |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3609 |
# endif |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3610 |
#endif |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3611 |
%}. |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3612 |
^ false |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3613 |
! ! |
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3614 |
|
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
3615 |
!OperatingSystem class methodsFor:'file queries'! |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3616 |
|
616 | 3617 |
baseNameOf:aPathString |
3618 |
"return the baseName of the argument, aPathString |
|
3619 |
- thats the file/directory name without leading parent-dirs |
|
3620 |
(i.e. OperatingSystem baseNameOf:'/usr/lib/st/file' -> 'file' |
|
3621 |
and OperatingSystem baseNameOf:'/usr/lib' -> lib). |
|
3622 |
This method does not check if the path is valid |
|
3623 |
(i.e. if these directories really exist & is readable)." |
|
3624 |
||
3625 |
|prev index sep| |
|
3626 |
||
3627 |
sep := self fileSeparator. |
|
3628 |
((aPathString size == 1) and:[(aPathString at:1) == sep]) ifTrue:[ |
|
3629 |
^ aPathString |
|
3630 |
]. |
|
3631 |
prev := 1. |
|
3632 |
[true] whileTrue:[ |
|
3633 |
index := aPathString indexOf:sep startingAt:prev. |
|
3634 |
index == 0 ifTrue:[ |
|
3635 |
^ aPathString copyFrom:prev |
|
3636 |
]. |
|
3637 |
prev := index + 1 |
|
3638 |
] |
|
3639 |
||
3640 |
" |
|
3641 |
OperatingSystem baseNameOf:'/fee/foo/bar' |
|
3642 |
OperatingSystem baseNameOf:'foo/bar' |
|
3643 |
OperatingSystem baseNameOf:'../../foo/bar' |
|
3644 |
OperatingSystem baseNameOf:'hello' |
|
3645 |
" |
|
3646 |
! |
|
3647 |
||
3648 |
caseSensitiveFilenames |
|
3649 |
"return true, if the OS has caseSensitive file naming. |
|
3650 |
On MSDOS, this will return false. Since this is for Unix, we |
|
3651 |
return true." |
|
3652 |
||
3653 |
^ true |
|
3654 |
! |
|
3655 |
||
3656 |
compressPath:pathName |
|
3657 |
"return the pathName compressed - that is, remove all ..-entries |
|
3658 |
and . entries. This does not always (in case of symbolic links) |
|
3659 |
return the true pathName and is therefore used as a fallback |
|
3660 |
if realPath and popen failed." |
|
3661 |
||
3662 |
|names| |
|
3663 |
||
3664 |
names := pathName |
|
3665 |
asCollectionOfSubstringsSeparatedBy:self fileSeparator. |
|
3666 |
names := names asOrderedCollection. |
|
3667 |
" |
|
3668 |
cut off initial double-slashes |
|
3669 |
" |
|
3670 |
[names startsWith:#('' '')] whileTrue:[ |
|
3671 |
names removeFirst. |
|
3672 |
]. |
|
3673 |
" |
|
3674 |
cut off double-slashes at end |
|
3675 |
" |
|
3676 |
[names endsWith:#('')] whileTrue:[ |
|
3677 |
names removeLast. |
|
3678 |
]. |
|
3679 |
" |
|
3680 |
cut off current-dir at beginning |
|
3681 |
" |
|
3682 |
[(names size >= 2) and:[names startsWith:#('.')]] whileTrue:[ |
|
3683 |
names removeFirst. |
|
3684 |
]. |
|
3685 |
||
3686 |
" |
|
3687 |
cut off parent-dirs at end |
|
3688 |
" |
|
3689 |
[(names size > 2) |
|
3690 |
and:[(names endsWith:#('..')) |
|
3691 |
and:[((names at:(names size - 1)) startsWith:'.') not ]]] whileTrue:[ |
|
3692 |
names removeLast; removeLast |
|
3693 |
]. |
|
3694 |
||
3695 |
^ names asStringWith:self fileSeparator |
|
3696 |
from:1 |
|
3697 |
to:names size |
|
3698 |
compressTabs:false final:nil |
|
3699 |
||
3700 |
" |
|
3701 |
OperatingSystem compressPath:'./..' |
|
3702 |
OperatingSystem compressPath:'/foo/bar/baz/..' |
|
3703 |
OperatingSystem compressPath:'foo/bar/baz/..' |
|
3704 |
OperatingSystem compressPath:'foo/bar/baz/../' |
|
3705 |
OperatingSystem compressPath:'foo/bar/baz/..///' |
|
3706 |
OperatingSystem compressPath:'///foo/bar/baz/..///' |
|
3707 |
" |
|
68 | 3708 |
! |
3709 |
||
616 | 3710 |
directoryNameOf:aPathString |
3711 |
"return the directoryName of the argument, aPath |
|
3712 |
- thats the name of the directory where aPath is |
|
3713 |
(i.e. OperatingSystem directoryNameOf:'/usr/lib/st/file' -> '/usr/lib/st' |
|
3714 |
and OperatingSystem directoryNameOf:'/usr/lib' -> /usr'). |
|
3715 |
This method does not check if the path is valid |
|
3716 |
(i.e. if these directories really exist & are readable)." |
|
3717 |
||
3718 |
|last index sep sepString| |
|
3719 |
||
3720 |
sep := self fileSeparator. |
|
3721 |
sepString := sep asString. |
|
3722 |
(aPathString = sepString) ifTrue:[ |
|
3723 |
" |
|
3724 |
the trivial '/' case |
|
3725 |
" |
|
3726 |
^ aPathString |
|
3727 |
]. |
|
3728 |
(aPathString startsWith:sepString) ifFalse:[ |
|
3729 |
(aPathString endsWith:sepString) ifTrue:[ |
|
3730 |
^ aPathString copyTo:(aPathString size - 1) |
|
3731 |
]. |
|
3732 |
]. |
|
3733 |
last := 1. |
|
3734 |
[true] whileTrue:[ |
|
3735 |
index := aPathString indexOf:sep startingAt:(last + 1). |
|
3736 |
index == 0 ifTrue:[ |
|
3737 |
(last == 1) ifTrue:[ |
|
3738 |
(aPathString startsWith:sepString) ifTrue:[ |
|
3739 |
^ sepString |
|
3740 |
]. |
|
3741 |
^ '.' |
|
3742 |
]. |
|
3743 |
" |
|
3744 |
(aPathString startsWith:sepString) ifFalse:[ |
|
3745 |
(aPathString startsWith:('..' , sepString)) ifFalse:[ |
|
3746 |
^ './' , (aPathString copyTo:(last - 1)) |
|
3747 |
] |
|
3748 |
]. |
|
3749 |
" |
|
3750 |
^ aPathString copyTo:(last - 1) |
|
3751 |
]. |
|
3752 |
last := index. |
|
3753 |
] |
|
3754 |
||
3755 |
" |
|
3756 |
OperatingSystem directoryNameOf:'/fee/foo/bar' |
|
3757 |
OperatingSystem directoryNameOf:'foo/bar' |
|
3758 |
OperatingSystem directoryNameOf:'../../foo/bar' |
|
3759 |
OperatingSystem directoryNameOf:'bar' |
|
3760 |
OperatingSystem directoryNameOf:'/bar' |
|
3761 |
" |
|
3762 |
! |
|
3763 |
||
3764 |
fileSeparator |
|
3765 |
"return the character used to separate names in a path. |
|
3766 |
This character differs for MSDOS and other systems, |
|
3767 |
(but those are currently not supported - so this is some |
|
3768 |
preparation for the future)" |
|
3769 |
||
3770 |
^ $/ |
|
3771 |
! |
|
3772 |
||
3773 |
idOf:aPathName |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3774 |
"return the fileNumber (i.e. inode number) of a file. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3775 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3776 |
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
|
3777 |
some dummy id will be returned. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3778 |
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
|
3779 |
physically identical, even if found in different directories |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3780 |
(i.e. if they are hardLinked)." |
616 | 3781 |
|
3782 |
" |
|
3783 |
this could have been implemented as: |
|
1487 | 3784 |
(self infoOf:aPathName) at:#id |
616 | 3785 |
but for huge directory searches the code below is faster |
3786 |
" |
|
68 | 3787 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3788 |
%{ |
616 | 3789 |
struct stat buf; |
3790 |
int ret; |
|
3791 |
||
3792 |
if (__isString(aPathName)) { |
|
1487 | 3793 |
__BEGIN_INTERRUPTABLE__ |
3794 |
do { |
|
3795 |
ret = stat((char *) __stringVal(aPathName), &buf); |
|
3796 |
} while (ret < 0 && errno == EINTR); |
|
3797 |
__END_INTERRUPTABLE__ |
|
3798 |
if (ret >= 0) { |
|
3799 |
RETURN (__MKSMALLINT(buf.st_ino)); |
|
3800 |
} |
|
3801 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3802 |
RETURN (nil); |
|
616 | 3803 |
} |
68 | 3804 |
%} |
616 | 3805 |
. |
792 | 3806 |
^ self primitiveFailed |
616 | 3807 |
|
3808 |
"OperatingSystem idOf:'/'" |
|
68 | 3809 |
! |
3810 |
||
616 | 3811 |
infoOf:aPathName |
3812 |
"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
|
3813 |
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
|
3814 |
Return nil if such a file does not exist. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3815 |
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
|
3816 |
use #linkInfoOf: to get info about the link itself. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3817 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3818 |
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
|
3819 |
future without affecting existing applications." |
616 | 3820 |
|
3821 |
|info type mode uid gid size id |
|
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
3822 |
atime mtime ctime| |
616 | 3823 |
|
3824 |
%{ |
|
3825 |
struct stat buf; |
|
3826 |
int ret; |
|
3827 |
||
3828 |
if (__isString(aPathName)) { |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3829 |
__BEGIN_INTERRUPTABLE__ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3830 |
do { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3831 |
ret = stat((char *) __stringVal(aPathName), &buf); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3832 |
} while ((ret < 0) && (errno == EINTR)); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3833 |
__END_INTERRUPTABLE__ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3834 |
|
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3835 |
if (ret < 0) { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3836 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3837 |
RETURN ( nil ); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3838 |
} |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3839 |
switch (buf.st_mode & S_IFMT) { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3840 |
case S_IFDIR: |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3841 |
type = @symbol(directory); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3842 |
break; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3843 |
case S_IFREG: |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3844 |
type = @symbol(regular); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3845 |
break; |
616 | 3846 |
#ifdef S_IFCHR |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3847 |
case S_IFCHR: |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3848 |
type = @symbol(characterSpecial); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3849 |
break; |
616 | 3850 |
#endif |
3851 |
#ifdef S_IFBLK |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3852 |
case S_IFBLK: |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3853 |
type = @symbol(blockSpecial); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3854 |
break; |
616 | 3855 |
#endif |
3856 |
#ifdef S_IFLNK |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3857 |
case S_IFLNK: |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3858 |
type = @symbol(symbolicLink); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3859 |
break; |
616 | 3860 |
#endif |
3861 |
#ifdef S_IFSOCK |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3862 |
case S_IFSOCK: |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3863 |
type = @symbol(socket); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3864 |
break; |
616 | 3865 |
#endif |
3866 |
#ifdef S_IFIFO |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3867 |
case S_IFIFO: |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3868 |
type = @symbol(fifo); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3869 |
break; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3870 |
#endif |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3871 |
default: |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3872 |
type = @symbol(unknown); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3873 |
break; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3874 |
} |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3875 |
mode = __MKSMALLINT(buf.st_mode & 0777); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3876 |
uid = __MKSMALLINT(buf.st_uid); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3877 |
gid = __MKSMALLINT(buf.st_gid); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3878 |
size = __MKSMALLINT(buf.st_size); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3879 |
id = __MKSMALLINT(buf.st_ino); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3880 |
atime = __MKUINT(buf.st_atime); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3881 |
mtime = __MKUINT(buf.st_mtime); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3882 |
ctime = __MKUINT(buf.st_ctime); |
616 | 3883 |
} |
3884 |
%}. |
|
3885 |
mode notNil ifTrue:[ |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3886 |
info := IdentityDictionary new. |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3887 |
info at:#type put:type. |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3888 |
info at:#mode put:mode. |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3889 |
info at:#uid put:uid. |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3890 |
info at:#gid put:gid. |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3891 |
info at:#size put:size. |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3892 |
info at:#id put:id. |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3893 |
info at:#accessed put:(AbsoluteTime fromOSTime:(atime * 1000)). |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3894 |
info at:#modified put:(AbsoluteTime fromOSTime:(mtime * 1000)). |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3895 |
info at:#statusChanged put:(AbsoluteTime fromOSTime:(ctime * 1000)). |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
3896 |
^ info |
616 | 3897 |
]. |
792 | 3898 |
^ self primitiveFailed |
616 | 3899 |
|
3900 |
" |
|
3901 |
OperatingSystem infoOf:'/' |
|
3902 |
(OperatingSystem infoOf:'/') at:#uid |
|
3903 |
(OperatingSystem infoOf:'/') at:#accessed |
|
3904 |
" |
|
68 | 3905 |
! |
3906 |
||
616 | 3907 |
isDirectory:aPathName |
3908 |
"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
|
3909 |
(i.e. exists and is a directory). |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3910 |
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
|
3911 |
if you need to check for this, use #linkInfo:." |
68 | 3912 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3913 |
%{ |
616 | 3914 |
struct stat buf; |
3915 |
int ret; |
|
3916 |
||
3917 |
if (__isString(aPathName)) { |
|
1487 | 3918 |
__BEGIN_INTERRUPTABLE__ |
3919 |
do { |
|
3920 |
ret = stat((char *) __stringVal(aPathName), &buf); |
|
3921 |
} while ((ret < 0) && (errno == EINTR)); |
|
3922 |
__END_INTERRUPTABLE__ |
|
3923 |
if (ret < 0) { |
|
3924 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3925 |
RETURN ( false ); |
|
3926 |
} |
|
3927 |
RETURN ( ((buf.st_mode & S_IFMT) == S_IFDIR) ? true : false); |
|
616 | 3928 |
} |
3929 |
%}. |
|
792 | 3930 |
^ self primitiveFailed |
616 | 3931 |
|
3932 |
"an alternative implementation would be: |
|
1487 | 3933 |
^ (self infoOf:aPathName) at:#type == #directory |
616 | 3934 |
" |
68 | 3935 |
! |
3936 |
||
616 | 3937 |
isExecutable:aPathName |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3938 |
"return true, if the given file is executable. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3939 |
For symbolic links, the pointed-to-file is checked." |
68 | 3940 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3941 |
%{ |
616 | 3942 |
int ret; |
3943 |
||
3944 |
if (__isString(aPathName)) { |
|
1487 | 3945 |
__BEGIN_INTERRUPTABLE__ |
3946 |
do { |
|
3947 |
ret = access(__stringVal(aPathName), X_OK); |
|
3948 |
} while ((ret < 0) && (errno == EINTR)); |
|
3949 |
__END_INTERRUPTABLE__ |
|
3950 |
if (ret < 0) { |
|
3951 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3952 |
} |
|
3953 |
RETURN ( ((ret == 0) ? true : false) ); |
|
616 | 3954 |
} |
3955 |
%}. |
|
792 | 3956 |
^ self primitiveFailed |
68 | 3957 |
! |
3958 |
||
616 | 3959 |
isReadable:aPathName |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3960 |
"return true, if the file/dir 'aPathName' is readable. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
3961 |
For symbolic links, the pointed-to-file is checked." |
68 | 3962 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3963 |
%{ |
616 | 3964 |
int ret; |
3965 |
||
3966 |
if (__isString(aPathName)) { |
|
1487 | 3967 |
__BEGIN_INTERRUPTABLE__ |
3968 |
do { |
|
3969 |
ret = access(__stringVal(aPathName), R_OK); |
|
3970 |
} while ((ret < 0) && (errno == EINTR)); |
|
3971 |
__END_INTERRUPTABLE__ |
|
3972 |
if (ret < 0) { |
|
3973 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
3974 |
} |
|
3975 |
RETURN ( ((ret == 0) ? true : false) ); |
|
616 | 3976 |
} |
3977 |
%}. |
|
792 | 3978 |
^ self primitiveFailed |
68 | 3979 |
! |
3980 |
||
616 | 3981 |
isSymbolicLink:aPathName |
3982 |
"return true, if the given file is a symbolic link" |
|
3983 |
||
3984 |
^ (self linkInfoOf:aPathName) notNil |
|
3985 |
||
3986 |
" |
|
3987 |
OperatingSystem isSymbolicLink:'Make.proto' |
|
3988 |
OperatingSystem isSymbolicLink:'Makefile' |
|
3989 |
" |
|
3990 |
! |
|
3991 |
||
3992 |
isValidPath:aPathName |
|
3993 |
"return true, if 'aPathName' is a valid path name |
|
3994 |
(i.e. the file or directory exists)" |
|
68 | 3995 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
3996 |
%{ |
616 | 3997 |
struct stat buf; |
3998 |
int ret; |
|
3999 |
||
4000 |
if (__isString(aPathName) || __isSymbol(aPathName) ) { |
|
4001 |
__BEGIN_INTERRUPTABLE__ |
|
4002 |
do { |
|
1135 | 4003 |
ret = stat((char *) __stringVal(aPathName), &buf); |
616 | 4004 |
} while ((ret < 0) && (errno == EINTR)); |
4005 |
__END_INTERRUPTABLE__ |
|
4006 |
if (ret < 0) { |
|
1135 | 4007 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 4008 |
RETURN (false); |
4009 |
} |
|
4010 |
RETURN ( ret ? false : true ); |
|
4011 |
} |
|
792 | 4012 |
%}. |
4013 |
^ self primitiveFailed |
|
68 | 4014 |
! |
4015 |
||
616 | 4016 |
isWritable:aPathName |
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4017 |
"return true, if the given file is writable. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4018 |
For symbolic links, the pointed-to-file is checked." |
68 | 4019 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4020 |
%{ |
616 | 4021 |
int ret; |
4022 |
||
4023 |
if (__isString(aPathName)) { |
|
1487 | 4024 |
__BEGIN_INTERRUPTABLE__ |
4025 |
do { |
|
4026 |
ret = access(__stringVal(aPathName), W_OK); |
|
4027 |
} while ((ret < 0) && (errno == EINTR)); |
|
4028 |
__END_INTERRUPTABLE__ |
|
4029 |
if (ret < 0) { |
|
4030 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
|
4031 |
} |
|
4032 |
RETURN ( ((ret == 0) ? true : false) ); |
|
616 | 4033 |
} |
4034 |
%}. |
|
792 | 4035 |
^ self primitiveFailed |
68 | 4036 |
! |
4037 |
||
616 | 4038 |
linkInfoOf:aPathName |
4039 |
"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
|
4040 |
IFF aPathName is a symbolic link. |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4041 |
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
|
4042 |
|
616 | 4043 |
The contents of the dictionary gives info about the link itself, |
4044 |
on contrast to #infoOf:, which returns the info of the pointed to file |
|
4045 |
in case of a symbolic link." |
|
4046 |
||
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4047 |
|info type mode uid gid size id atime mtime ctime path| |
616 | 4048 |
|
4049 |
%{ /* STACK: 1200 */ |
|
792 | 4050 |
#ifdef S_IFLNK |
616 | 4051 |
struct stat buf; |
4052 |
int ret; |
|
4053 |
char pathBuffer[1024]; |
|
4054 |
||
4055 |
if (__isString(aPathName)) { |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4056 |
__BEGIN_INTERRUPTABLE__ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4057 |
do { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4058 |
ret = lstat((char *) __stringVal(aPathName), &buf); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4059 |
} while ((ret < 0) && (errno == EINTR)); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4060 |
__END_INTERRUPTABLE__ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4061 |
|
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4062 |
if (ret < 0) { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4063 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4064 |
RETURN ( nil ); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4065 |
} |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4066 |
switch (buf.st_mode & S_IFMT) { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4067 |
default: |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4068 |
RETURN ( nil ); /* not a symbolic link */ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4069 |
|
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4070 |
case S_IFLNK: |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4071 |
type = @symbol(symbolicLink); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4072 |
break; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4073 |
} |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4074 |
|
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4075 |
mode = __MKSMALLINT(buf.st_mode & 0777); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4076 |
uid = __MKSMALLINT(buf.st_uid); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4077 |
gid = __MKSMALLINT(buf.st_gid); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4078 |
size = __MKSMALLINT(buf.st_size); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4079 |
id = __MKSMALLINT(buf.st_ino); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4080 |
atime = __MKUINT(buf.st_atime); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4081 |
mtime = __MKUINT(buf.st_mtime); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4082 |
ctime = __MKUINT(buf.st_ctime); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4083 |
if ((ret = readlink((char *) __stringVal(aPathName), pathBuffer, sizeof(pathBuffer))) < 0) { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4084 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4085 |
RETURN ( nil ); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4086 |
} |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4087 |
pathBuffer[ret] = '\0'; /* readlink does not 0-terminate */ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4088 |
path = __MKSTRING(pathBuffer COMMA_CON); |
616 | 4089 |
} |
792 | 4090 |
#else |
4091 |
RETURN ( nil ); |
|
4092 |
#endif |
|
616 | 4093 |
%}. |
4094 |
mode notNil ifTrue:[ |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4095 |
info := IdentityDictionary new. |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4096 |
info at:#type put:type. |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4097 |
info at:#mode put:mode. |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4098 |
info at:#uid put:uid. |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4099 |
info at:#gid put:gid. |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4100 |
info at:#size put:size. |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4101 |
info at:#id put:id. |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4102 |
info at:#path put:path. |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4103 |
info at:#accessed put:(AbsoluteTime fromOSTime:(atime * 1000)). |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4104 |
info at:#modified put:(AbsoluteTime fromOSTime:(mtime * 1000)). |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4105 |
info at:#statusChanged put:(AbsoluteTime fromOSTime:(ctime * 1000)). |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4106 |
^ info |
616 | 4107 |
]. |
792 | 4108 |
^ self primitiveFailed |
616 | 4109 |
|
4110 |
" |
|
1084
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4111 |
OperatingSystem infoOf:'Make.proto' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4112 |
OperatingSystem linkInfoOf:'Make.proto' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4113 |
|
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4114 |
OperatingSystem infoOf:'resources/motif.style' |
d6ffc9368fd5
set LastErrorNumber; category changes
Claus Gittinger <cg@exept.de>
parents:
1076
diff
changeset
|
4115 |
OperatingSystem linkInfoOf:'resources/motif.style' |
616 | 4116 |
" |
4117 |
! |
|
4118 |
||
4119 |
parentDirectoryName |
|
4120 |
"return the name used to refer to parent directories. |
|
4121 |
In MSDOS, Unix and other systems this is '..', but maybe different |
|
4122 |
for other systems. |
|
4123 |
(but those are currently not supported - so this is some |
|
4124 |
preparation for the future)" |
|
4125 |
||
4126 |
^ '..' |
|
68 | 4127 |
! |
4128 |
||
616 | 4129 |
pathNameOf:pathName |
4130 |
"return the pathName of the argument, aPathString, |
|
4131 |
- thats the full pathname of the directory, starting at '/'. |
|
4132 |
This method needs the path to be valid |
|
4133 |
(i.e. all directories must exist, be readable and executable). |
|
4134 |
Notice: if symbolic links are involved, the result may look different |
|
4135 |
from what you expect." |
|
4136 |
||
4137 |
|p path command| |
|
4138 |
||
4139 |
"some systems have a convenient function for this ..." |
|
4140 |
path := self primPathNameOf:pathName. |
|
4141 |
||
4142 |
path isNil ifTrue:[ |
|
4143 |
(self isValidPath:pathName) ifFalse:[^ pathName]. |
|
4144 |
||
4145 |
(SlowFork==true or:[ForkFailed]) ifFalse:[ |
|
4146 |
PipeStream openErrorSignal handle:[:ex | |
|
4147 |
ForkFailed := true. |
|
4148 |
'OS: cannot fork/popen' errorPrintNL. |
|
4149 |
ex return. |
|
4150 |
] do:[ |
|
4151 |
"have to fall back ..." |
|
4152 |
command := 'cd ' , pathName , '; pwd'. |
|
4153 |
p := PipeStream readingFrom:command. |
|
4154 |
]. |
|
4155 |
||
4156 |
(p isNil or:[p atEnd]) ifTrue:[ |
|
4157 |
('OS: PipeStream for <' , command , '> failed') errorPrintNL. |
|
4158 |
] ifFalse:[ |
|
4159 |
path := p nextLine. |
|
4160 |
p close. |
|
4161 |
]. |
|
4162 |
]. |
|
4163 |
path isNil ifTrue:[ |
|
4164 |
path := pathName |
|
4165 |
]. |
|
4166 |
(SlowFork==true or:[ForkFailed]) ifTrue:[ |
|
4167 |
path := self compressPath:path |
|
4168 |
] |
|
4169 |
]. |
|
4170 |
^ path. |
|
4171 |
||
4172 |
" |
|
4173 |
OperatingSystem pathNameOf:'.' |
|
4174 |
OperatingSystem pathNameOf:'../smalltalk/../smalltalk' |
|
4175 |
OperatingSystem pathNameOf:'../../..' |
|
4176 |
OperatingSystem pathNameOf:'..' |
|
4177 |
" |
|
359 | 4178 |
! |
4179 |
||
616 | 4180 |
primPathNameOf:pathName |
4181 |
"return the pathName of the argument, aPathString, |
|
4182 |
- thats the full pathname of the directory, starting at '/'. |
|
4183 |
This method here returns nil, if the OS does not provide a |
|
4184 |
realPath library function. |
|
4185 |
Notice: if symbolic links are involved, the result may look different |
|
4186 |
from what you expect." |
|
4187 |
||
4188 |
|path| |
|
4189 |
||
4190 |
"some systems have a convenient function for this ..." |
|
4191 |
%{ /* STACK: 16000 */ |
|
4192 |
#ifdef HAS_REALPATH |
|
4193 |
char nameBuffer[MAXPATHLEN + 1]; |
|
4194 |
||
4195 |
if (__isString(pathName)) { |
|
1135 | 4196 |
if (realpath(__stringVal(pathName), nameBuffer)) { |
830 | 4197 |
RETURN ( __MKSTRING(nameBuffer COMMA_CON) ); |
616 | 4198 |
} |
4199 |
} |
|
4200 |
#endif |
|
4201 |
%}. |
|
4202 |
^ nil |
|
359 | 4203 |
! |
4204 |
||
616 | 4205 |
timeOfLastAccess:aPathName |
4206 |
"return the time, when the file was last accessed. |
|
4207 |
For nonexistent files, nil is returned." |
|
4208 |
||
4209 |
"could be implemented as: |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4210 |
(self infoOf:aPathName) at:#accessed |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4211 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4212 |
|osSeconds| |
616 | 4213 |
%{ |
4214 |
struct stat buf; |
|
4215 |
time_t mtime; |
|
4216 |
int ret; |
|
4217 |
||
4218 |
if (__isString(aPathName)) { |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4219 |
__BEGIN_INTERRUPTABLE__ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4220 |
do { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4221 |
ret = stat((char *) __stringVal(aPathName), &buf); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4222 |
} while (ret < 0 && errno == EINTR); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4223 |
__END_INTERRUPTABLE__ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4224 |
if (ret < 0) { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4225 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4226 |
RETURN (nil); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4227 |
} |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4228 |
osSeconds = __MKUINT(buf.st_atime); |
616 | 4229 |
} |
792 | 4230 |
%}. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4231 |
osSeconds notNil ifTrue:[^ AbsoluteTime fromOSTime:(osSeconds * 1000)]. |
792 | 4232 |
^ self primitiveFailed |
616 | 4233 |
|
4234 |
" |
|
4235 |
OperatingSystem timeOfLastAccess:'/' |
|
4236 |
" |
|
359 | 4237 |
! |
4238 |
||
616 | 4239 |
timeOfLastChange:aPathName |
4240 |
"return the time, when the file was last changed. |
|
4241 |
For nonexistent files, nil is returned." |
|
4242 |
||
4243 |
"could be implemented as: |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4244 |
(self infoOf:aPathName) at:#modified |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4245 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4246 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4247 |
|osSeconds| |
616 | 4248 |
%{ |
4249 |
struct stat buf; |
|
4250 |
int ret; |
|
4251 |
time_t mtime; |
|
4252 |
||
4253 |
if (__isString(aPathName)) { |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4254 |
__BEGIN_INTERRUPTABLE__ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4255 |
do { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4256 |
ret = stat((char *) __stringVal(aPathName), &buf); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4257 |
} while (ret < 0 && errno == EINTR); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4258 |
__END_INTERRUPTABLE__ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4259 |
if (ret < 0) { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4260 |
@global(LastErrorNumber) = __MKSMALLINT(errno); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4261 |
RETURN ( nil ); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4262 |
} |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
4263 |
osSeconds = __MKUINT(buf.st_mtime); |
616 | 4264 |
} |
792 | 4265 |
%}. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
4266 |
osSeconds notNil ifTrue:[^ AbsoluteTime fromOSTime:(osSeconds * 1000)]. |
792 | 4267 |
^ self primitiveFailed |
616 | 4268 |
|
4269 |
" |
|
4270 |
OperatingSystem timeOfLastChange:'/' |
|
4271 |
" |
|
4272 |
! |
|
4273 |
||
4274 |
typeOf:aPathName |
|
4275 |
"return the type of a file as a symbol" |
|
4276 |
||
4277 |
" |
|
4278 |
this could have been implemented as: |
|
4279 |
(self infoOf:aPathName) at:#type |
|
4280 |
but for huge directory searches the code below is faster |
|
4281 |
" |
|
359 | 4282 |
|
1104
219a06128193
removed NOCONTEXT directives ...
Claus Gittinger <cg@exept.de>
parents:
1084
diff
changeset
|
4283 |
%{ |
616 | 4284 |
struct stat buf; |
4285 |
int ret; |
|
4286 |
||
4287 |
if (__isString(aPathName)) { |
|
4288 |
__BEGIN_INTERRUPTABLE__ |
|
4289 |
do { |
|
1135 | 4290 |
ret = stat((char *) __stringVal(aPathName), &buf); |
616 | 4291 |
} while (ret < 0 && errno == EINTR); |
4292 |
__END_INTERRUPTABLE__ |
|
4293 |
if (ret < 0) { |
|
1135 | 4294 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 4295 |
RETURN ( nil ); |
4296 |
} |
|
4297 |
switch (buf.st_mode & S_IFMT) { |
|
4298 |
case S_IFDIR: |
|
4299 |
RETURN ( @symbol(directory) ); |
|
4300 |
case S_IFREG: |
|
4301 |
RETURN ( @symbol(regular) ); |
|
4302 |
#ifdef S_IFCHR |
|
4303 |
case S_IFCHR: |
|
4304 |
RETURN ( @symbol(characterSpecial) ); |
|
4305 |
#endif |
|
4306 |
#ifdef S_IFBLK |
|
4307 |
case S_IFBLK: |
|
4308 |
RETURN ( @symbol(blockSpecial) ); |
|
4309 |
#endif |
|
4310 |
#ifdef S_IFLNK |
|
4311 |
case S_IFLNK: |
|
4312 |
RETURN ( @symbol(symbolicLink) ); |
|
4313 |
#endif |
|
4314 |
#ifdef S_IFSOCK |
|
4315 |
case S_IFSOCK: |
|
4316 |
RETURN ( @symbol(socket) ); |
|
4317 |
#endif |
|
4318 |
#ifdef S_IFIFO |
|
4319 |
case S_IFIFO: |
|
4320 |
RETURN ( @symbol(fifo) ); |
|
4321 |
#endif |
|
4322 |
default: |
|
4323 |
RETURN ( @symbol(unknown) ); |
|
4324 |
} |
|
4325 |
} |
|
4326 |
%}. |
|
792 | 4327 |
^ self primitiveFailed |
616 | 4328 |
|
4329 |
" |
|
4330 |
OperatingSystem typeOf:'/' |
|
4331 |
OperatingSystem typeOf:'.' |
|
4332 |
OperatingSystem typeOf:'Make.proto' |
|
4333 |
" |
|
68 | 4334 |
! ! |
4335 |
||
1497 | 4336 |
!OperatingSystem class methodsFor:'interrupts & signals'! |
63 | 4337 |
|
10 | 4338 |
blockInterrupts |
95 | 4339 |
"disable interrupt processing - if disabled, incoming |
4340 |
interrupts will be registered and handled as soon as |
|
4341 |
interrupts are reenabled by OperatingSystemclass>>unblockInterrupts. |
|
4342 |
Returns the previous blocking status i.e. true if interrupts |
|
4343 |
where already blocked. You need this information for proper |
|
4344 |
unblocking, in case of nested block/unblock calls." |
|
4345 |
||
4346 |
%{ /* NOCONTEXT */ |
|
710 | 4347 |
RETURN ( __BLOCKINTERRUPTS() ); |
10 | 4348 |
%} |
4349 |
! |
|
4350 |
||
616 | 4351 |
defaultSignal:signalNumber |
4352 |
"revert to the default action on arrival of a (Unix-)signal. |
|
4353 |
Dont confuse Unix signals with smalltalk signals. |
|
4354 |
WARNING: for some signals, it is no good idea to revert to default; |
|
4355 |
for example, the default for SIGINT (i.e. ^C) is to exit; while the |
|
4356 |
default for SIGQUIT (^ \) is to dump core. |
|
4357 |
Also, NOTICE that signal numbers are not portable between unix |
|
4358 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
4359 |
a signal." |
|
4360 |
||
4361 |
%{ /* NOCONTEXT */ |
|
4362 |
||
4363 |
if (__isSmallInteger(signalNumber)) { |
|
831 | 4364 |
#ifdef SIG_DFL |
1135 | 4365 |
signal(__intVal(signalNumber), SIG_DFL); |
616 | 4366 |
RETURN (self); |
831 | 4367 |
#endif |
616 | 4368 |
} |
4369 |
%}. |
|
4370 |
" |
|
4371 |
this error is triggered on non-integer argument |
|
4372 |
" |
|
792 | 4373 |
^ self primitiveFailed |
616 | 4374 |
|
4375 |
"you better save a snapshot image before trying this ..." |
|
4376 |
" |
|
4377 |
'if you hit ^C now, Smalltalk will exit immediately' printNewline. |
|
4378 |
OperatingSystem defaultSignal:(OperatingSystem sigINT). |
|
4379 |
1 to:1000000 do:[:i| ]. |
|
4380 |
OperatingSystem enableSignal:(OperatingSystem sigINT). |
|
4381 |
'normal ^C handling again.' printNewline |
|
4382 |
" |
|
4383 |
! |
|
4384 |
||
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4385 |
disableChildSignalInterrupts |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4386 |
"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
|
4387 |
(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
|
4388 |
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
|
4389 |
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
|
4390 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4391 |
^ 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
|
4392 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4393 |
"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
|
4394 |
! |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
4395 |
|
616 | 4396 |
disableIOInterruptsOn:fd |
4397 |
"turn off IO interrupts for a filedescriptor" |
|
4398 |
||
4399 |
%{ /* NOCONTEXT */ |
|
4400 |
||
4401 |
int ret, flags, f; |
|
4402 |
||
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4403 |
#if (defined(F_GETFL) && defined(F_SETFL) && defined(FASYNC)) || defined(SYSV4) |
616 | 4404 |
if (__isSmallInteger(fd)) { |
1135 | 4405 |
f = __intVal(fd); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4406 |
# if defined(SYSV4) |
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
756
diff
changeset
|
4407 |
ret = ioctl(f, I_SETSIG, 0); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4408 |
# else /*! SYSV4*/ |
616 | 4409 |
flags = fcntl(f, F_GETFL, 0); |
4410 |
/* |
|
4411 |
* if already clear, there is no need for this syscall ... |
|
4412 |
*/ |
|
4413 |
if (flags & FASYNC) { |
|
4414 |
ret = fcntl(f, F_SETFL, flags & ~FASYNC); |
|
4415 |
if (ret >= 0) ret = flags; |
|
4416 |
} else { |
|
4417 |
ret = flags; |
|
4418 |
} |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4419 |
# endif /* !SYSV4 */ |
1135 | 4420 |
RETURN ( __MKSMALLINT(ret) ); |
616 | 4421 |
} |
4422 |
#endif |
|
4423 |
%}. |
|
4424 |
" |
|
4425 |
this error is triggered on non-integer argument |
|
4426 |
or if the OS does not support IO interrupts. |
|
4427 |
" |
|
792 | 4428 |
^ self primitiveFailed |
10 | 4429 |
! |
4430 |
||
63 | 4431 |
disableSignal:signalNumber |
95 | 4432 |
"disable (Unix-) signal processing for signalNumber. |
4433 |
Dont confuse Unix signals with smalltalk signals. |
|
63 | 4434 |
WARNING: for some signals, it is no good idea to disable |
95 | 4435 |
them; for example, disabling the SIGINT signal turns off ^C |
63 | 4436 |
handling. |
68 | 4437 |
Also, NOTICE that signal numbers are not portable between unix |
4438 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
4439 |
a signal. |
|
63 | 4440 |
Use only for fully debugged stand alone applications." |
4441 |
||
4442 |
%{ /* NOCONTEXT */ |
|
4443 |
||
252 | 4444 |
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
|
4445 |
int sigNo = __intVal(signalNumber); |
831 | 4446 |
|
4447 |
if (sigNo == 0) { |
|
4448 |
RETURN (self); |
|
4449 |
} |
|
4450 |
#ifdef SIG_IGN |
|
4451 |
signal(sigNo, SIG_IGN); |
|
185 | 4452 |
RETURN (self); |
831 | 4453 |
#endif |
63 | 4454 |
} |
68 | 4455 |
%}. |
4456 |
" |
|
4457 |
this error is triggered on non-integer argument |
|
4458 |
" |
|
792 | 4459 |
^ self primitiveFailed |
68 | 4460 |
|
4461 |
" |
|
4462 |
'now, ^C is totally ignored ...' printNewline. |
|
4463 |
OperatingSystem disableSignal:(OperatingSystem sigINT). |
|
4464 |
1 to:1000000 do:[:i| ]. |
|
4465 |
OperatingSystem enableSignal:(OperatingSystem sigINT). |
|
4466 |
'^C handled again.' printNewline |
|
4467 |
" |
|
4468 |
! |
|
4469 |
||
616 | 4470 |
disableTimer |
831 | 4471 |
"disable timer interrupts. |
4472 |
WARNING: |
|
4473 |
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
|
4474 |
disabled, because no scheduling or timeouts are possible." |
616 | 4475 |
|
4476 |
%{ /* NOCONTEXT */ |
|
4477 |
||
4478 |
#if defined(ITIMER_REAL) |
|
4479 |
struct itimerval dt; |
|
4480 |
||
4481 |
dt.it_interval.tv_sec = 0; |
|
4482 |
dt.it_interval.tv_usec = 0; |
|
4483 |
dt.it_value.tv_sec = 0; |
|
4484 |
dt.it_value.tv_usec = 0; |
|
4485 |
setitimer(ITIMER_REAL, &dt, 0); |
|
4486 |
RETURN (true); |
|
831 | 4487 |
#endif /* ITIMER_REAL */ |
616 | 4488 |
%} |
4489 |
. |
|
4490 |
^ false |
|
4491 |
! |
|
4492 |
||
4493 |
disableUserInterrupts |
|
4494 |
"disable userInterrupt processing; |
|
4495 |
when disabled, no ^C processing takes place. |
|
831 | 4496 |
WARNING: |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4497 |
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
|
4498 |
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
|
4499 |
We recommend setting up a handler for the signal instead of disabling it." |
831 | 4500 |
|
4501 |
self disableSignal:(self sigBREAK). |
|
4502 |
self disableSignal:(self sigINT). |
|
616 | 4503 |
! |
4504 |
||
4505 |
enableAbortInterrupts |
|
4506 |
"enable abort signalhandling, and make it a regular signalInterrupt. |
|
4507 |
(the default will dump core and exit - which is not a good idea for |
|
4508 |
end-user applications ...). |
|
4509 |
This is especially useful, if linked-in C-libraries call abort() ..." |
|
4510 |
||
831 | 4511 |
self enableSignal:(self sigABRT) |
616 | 4512 |
! |
4513 |
||
4514 |
enableChildSignalInterrupts |
|
4515 |
"enable childSignal interrupts |
|
4516 |
(SIGCHLD, if the architecture supports it). |
|
831 | 4517 |
After enabling, these signals will send the message |
616 | 4518 |
'childSignalInterrupt' to the ChildSignalInterruptHandler object." |
4519 |
||
831 | 4520 |
self enableSignal:(self sigCHLD) |
616 | 4521 |
! |
4522 |
||
4523 |
enableFpExceptionInterrupts |
|
4524 |
"enable floating point exception interrupts (if the |
|
4525 |
architecture supports it). |
|
831 | 4526 |
After enabling, fpu-exceptions will send the message |
616 | 4527 |
'fpuExceptionInterrupt' to the FPUExceptionInterruptHandler object." |
4528 |
||
831 | 4529 |
self enableSignal:(self sigFP) |
616 | 4530 |
! |
4531 |
||
4532 |
enableHardSignalInterrupts |
|
4533 |
"enable hard signal exception interrupts (trap, buserror & segm. violation). |
|
831 | 4534 |
After enabling, these exceptions will send the message |
616 | 4535 |
'signalInterrupt' to the SignalInterruptHandler object." |
68 | 4536 |
|
855
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
4537 |
"/ 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
|
4538 |
"/ 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
|
4539 |
|
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
4540 |
"/ ... 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
|
4541 |
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
|
4542 |
|
640
be94dfc60eaa
Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents:
630
diff
changeset
|
4543 |
self enableSignal:(self sigBUS). |
be94dfc60eaa
Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents:
630
diff
changeset
|
4544 |
self enableSignal:(self sigSEGV) |
616 | 4545 |
! |
4546 |
||
4547 |
enableIOInterruptsOn:fd |
|
4548 |
"turn on IO interrupts for a filedescriptor" |
|
4549 |
||
4550 |
%{ /* NOCONTEXT */ |
|
4551 |
||
4552 |
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
|
4553 |
#ifndef __signalIoInterrupt |
616 | 4554 |
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
|
4555 |
#endif |
616 | 4556 |
static int firstCall = 1; |
4557 |
||
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4558 |
#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
|
4559 |
/* |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4560 |
* SIGIO/SIGPOLL - data available for I/O |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4561 |
* (used to wake up waiting processes) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4562 |
*/ |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4563 |
#ifdef SIGIO |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4564 |
# define THESIGNAL SIGIO |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4565 |
#else |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4566 |
# ifdef SIGPOLL |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4567 |
# define THESIGNAL SIGPOLL |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4568 |
# else |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4569 |
# ifdef SIGURG |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4570 |
# define THESIGNAL SIGURG |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4571 |
# endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4572 |
# endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4573 |
#endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4574 |
|
616 | 4575 |
if (__isSmallInteger(fd)) { |
4576 |
if (firstCall) { |
|
762
cea705669628
ok, stefan was right: HAS_SIGACTION works
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
4577 |
#ifdef HAS_SIGACTION |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4578 |
struct sigaction act; |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4579 |
|
1487 | 4580 |
/* |
4581 |
* Do not add SA_RESTART here. A signal can cause a |
|
4582 |
* thread switch, another thread can do a garbage collect |
|
4583 |
* and restarted system calls may write into old |
|
4584 |
* (collected) addresses. |
|
4585 |
*/ |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4586 |
|
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4587 |
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
|
4588 |
sigemptyset(&act.sa_mask); |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4589 |
act.sa_handler = __signalIoInterrupt; |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4590 |
sigaction(THESIGNAL, &act, 0); |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4591 |
#else |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4592 |
# ifdef HAS_SIGVEC |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4593 |
struct sigvec vec; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4594 |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4595 |
vec.sv_flags = SV_INTERRUPT; |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4596 |
sigemptyset(&vec.sv_mask); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4597 |
vec.sv_handler = __signalIoInterrupt; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4598 |
sigvec(THESIGNAL, &vec, NULL); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4599 |
# else |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4600 |
signal(THESIGNAL, __signalIoInterrupt); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4601 |
# endif |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4602 |
#endif |
616 | 4603 |
firstCall = 0; |
4604 |
} |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4605 |
#undef THESIGNAL |
616 | 4606 |
|
1135 | 4607 |
f = __intVal(fd); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4608 |
# if defined(SYSV4) |
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
756
diff
changeset
|
4609 |
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
|
4610 |
# else /*! SYSV4*/ |
616 | 4611 |
flags = fcntl(f, F_GETFL, 0); |
4612 |
/* |
|
4613 |
* if already set, there is no need for this syscall ... |
|
4614 |
*/ |
|
4615 |
if (flags & FASYNC) { |
|
4616 |
ret = flags; |
|
4617 |
} else { |
|
4618 |
ret = fcntl(f, F_SETFL, flags | FASYNC); |
|
4619 |
if (ret >= 0) ret = flags; |
|
4620 |
} |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4621 |
# endif /*!SYSV4*/ |
1135 | 4622 |
RETURN ( __MKSMALLINT(ret) ); |
68 | 4623 |
} |
616 | 4624 |
#endif |
68 | 4625 |
%}. |
4626 |
" |
|
4627 |
this error is triggered on non-integer argument |
|
616 | 4628 |
or if the system does not support SIGIO |
68 | 4629 |
" |
792 | 4630 |
^ self primitiveFailed |
616 | 4631 |
! |
4632 |
||
4633 |
enableQuitInterrupts |
|
4634 |
"enable quitInterrupt (usually ^\) handling, and make it a userInterrupt. |
|
4635 |
(the default will dump core and exit - which is not a good idea for |
|
4636 |
end-user applications ...)" |
|
4637 |
||
831 | 4638 |
self enableSignal:(self sigQUIT) |
68 | 4639 |
! |
4640 |
||
4641 |
enableSignal:signalNumber |
|
95 | 4642 |
"enable (Unix-)signal processing for signalNumber. |
4643 |
Dont confuse Unix signals with smalltalk signals. |
|
68 | 4644 |
The signal will be delivered to one of the standard handlers |
4645 |
(SIGINT, SIGQUIT, etc) or to a general handler, which |
|
4646 |
sends #signalInterrupt:. |
|
4647 |
||
4648 |
NOTICE that signal numbers are not portable between unix |
|
4649 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
4650 |
a signal." |
|
4651 |
||
4652 |
%{ /* NOCONTEXT */ |
|
4653 |
||
4654 |
#ifdef NSIG |
|
4655 |
# define SIG_LIMIT NSIG |
|
4656 |
#else |
|
4657 |
# ifdef SIGUSR2 |
|
4658 |
# define SIG_LIMIT SIGUSR2 |
|
4659 |
# else |
|
4660 |
# ifdef SIGUSR |
|
4661 |
# define SIG_LIMIT SIGUSR |
|
4662 |
# endif |
|
4663 |
# endif |
|
4664 |
#endif |
|
4665 |
||
4666 |
#if defined(SIGPOLL) && !defined(SIGIO) |
|
4667 |
# define SIGIO SIGPOLL |
|
4668 |
#endif |
|
4669 |
||
4670 |
#ifdef SIGCHLD |
|
4671 |
# define CHILD_SIGNAL SIGCHLD |
|
4672 |
#else |
|
4673 |
# ifdef SIGCLD |
|
4674 |
# define CHILD_SIGNAL SIGCLD |
|
4675 |
# endif |
|
4676 |
#endif |
|
4677 |
||
4678 |
int sigNr; |
|
443 | 4679 |
#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
|
4680 |
# ifndef __signalUserInterrupt |
831 | 4681 |
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
|
4682 |
# endif |
443 | 4683 |
#endif |
4684 |
#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
|
4685 |
# ifndef __signalFpExceptionInterrupt |
831 | 4686 |
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
|
4687 |
# endif |
443 | 4688 |
#endif |
4689 |
#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
|
4690 |
# ifndef __signalIoInterrupt |
831 | 4691 |
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
|
4692 |
# endif |
443 | 4693 |
#endif |
68 | 4694 |
#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
|
4695 |
# ifndef __signalChildInterrupt |
831 | 4696 |
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
|
4697 |
# endif |
68 | 4698 |
#endif |
443 | 4699 |
#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
|
4700 |
# ifndef __signalPIPEInterrupt |
831 | 4701 |
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
|
4702 |
# endif |
443 | 4703 |
#endif |
4704 |
#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
|
4705 |
# ifndef __signalBUSInterrupt |
831 | 4706 |
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
|
4707 |
# endif |
443 | 4708 |
#endif |
4709 |
#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
|
4710 |
# ifndef __signalSEGVInterrupt |
831 | 4711 |
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
|
4712 |
# endif |
443 | 4713 |
#endif |
4714 |
#ifdef SIGALRM |
|
831 | 4715 |
# 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
|
4716 |
# ifndef __signalTimerInterrupt |
831 | 4717 |
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
|
4718 |
# endif |
831 | 4719 |
# endif |
4720 |
#endif |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4721 |
#ifndef __signalInterrupt |
831 | 4722 |
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
|
4723 |
#endif |
831 | 4724 |
void (*handler)(SIGHANDLER_ARG); |
68 | 4725 |
|
252 | 4726 |
if (__isSmallInteger(signalNumber) |
1135 | 4727 |
&& ((sigNr = __intVal(signalNumber)) >= 0) |
831 | 4728 |
#ifdef SIG_LIMIT |
4729 |
&& (sigNr <= SIG_LIMIT) |
|
4730 |
#endif |
|
4731 |
) { |
|
185 | 4732 |
/* |
4733 |
* standard signals are forced into standard handlers |
|
4734 |
* - all others go into general signalInterrupt |
|
4735 |
*/ |
|
68 | 4736 |
#if defined(SIGPOLL) && defined(SIGIO) |
185 | 4737 |
if (sigNr == SIGPOLL) |
4738 |
sigNr = SIGIO; |
|
68 | 4739 |
#endif |
185 | 4740 |
switch (sigNr) { |
831 | 4741 |
case 0: |
4742 |
/* enabling a non-supported signal */ |
|
4743 |
RETURN (self); |
|
4744 |
||
4745 |
#ifdef SIGBREAK |
|
4746 |
case SIGBREAK: |
|
4747 |
#endif |
|
443 | 4748 |
#ifdef SIGINT |
185 | 4749 |
case SIGINT: |
443 | 4750 |
#endif |
4751 |
#ifdef SIGQUIT |
|
185 | 4752 |
case SIGQUIT: |
443 | 4753 |
#endif |
831 | 4754 |
#if defined(SIGINT) || defined(SIGQUIT) || defined(SIGBREAK) |
329 | 4755 |
handler = __signalUserInterrupt; |
185 | 4756 |
break; |
443 | 4757 |
#endif |
4758 |
||
4759 |
#ifdef SIGFPE |
|
185 | 4760 |
case SIGFPE: |
329 | 4761 |
handler = __signalFpExceptionInterrupt; |
185 | 4762 |
break; |
443 | 4763 |
#endif |
4764 |
||
4765 |
#ifdef SIGPIPE |
|
185 | 4766 |
case SIGPIPE: |
329 | 4767 |
handler = __signalPIPEInterrupt; |
185 | 4768 |
break; |
443 | 4769 |
#endif |
68 | 4770 |
#ifdef SIGBUS |
185 | 4771 |
case SIGBUS: |
329 | 4772 |
handler = __signalBUSInterrupt; |
185 | 4773 |
break; |
68 | 4774 |
#endif |
443 | 4775 |
#ifdef SIGSEGV |
185 | 4776 |
case SIGSEGV: |
329 | 4777 |
handler = __signalSEGVInterrupt; |
185 | 4778 |
break; |
443 | 4779 |
#endif |
68 | 4780 |
#ifdef SIGIO |
185 | 4781 |
case SIGIO: |
329 | 4782 |
handler = __signalIoInterrupt; |
185 | 4783 |
break; |
68 | 4784 |
#endif |
4785 |
||
4786 |
#ifdef CHILD_SIGNAL |
|
185 | 4787 |
case CHILD_SIGNAL: |
329 | 4788 |
handler = __signalChildInterrupt; |
185 | 4789 |
break; |
68 | 4790 |
#endif |
443 | 4791 |
#ifdef SIGALRM |
831 | 4792 |
# ifndef WIN32 |
185 | 4793 |
case SIGALRM: |
329 | 4794 |
handler = __signalTimerInterrupt; |
185 | 4795 |
break; |
831 | 4796 |
# endif |
443 | 4797 |
#endif |
185 | 4798 |
|
4799 |
default: |
|
329 | 4800 |
handler = __signalInterrupt; |
185 | 4801 |
break; |
4802 |
} |
|
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4803 |
|
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4804 |
{ |
762
cea705669628
ok, stefan was right: HAS_SIGACTION works
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
4805 |
#ifdef HAS_SIGACTION |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4806 |
struct sigaction act; |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4807 |
|
1487 | 4808 |
/* |
4809 |
* Do not add SA_RESTART here. A signal can cause a |
|
4810 |
* thread switch, another thread can do a garbage collect |
|
4811 |
* and restarted system calls may write into old |
|
4812 |
* (collected) addresses. |
|
4813 |
*/ |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4814 |
|
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4815 |
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
|
4816 |
sigemptyset(&act.sa_mask); |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4817 |
act.sa_handler = handler; |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4818 |
sigaction(sigNr, &act, 0); |
213 | 4819 |
#else |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4820 |
# ifdef HAS_SIGVEC |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4821 |
struct sigvec vec; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4822 |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4823 |
vec.sv_flags = SV_INTERRUPT; |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4824 |
sigemptyset(&vec.sv_mask); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4825 |
vec.sv_handler = handler; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
4826 |
sigvec(sigNr, &vec, NULL); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4827 |
# else |
831 | 4828 |
(void) signal(sigNr, handler); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4829 |
# endif |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4830 |
#endif |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
4831 |
} |
213 | 4832 |
|
185 | 4833 |
/* |
4834 |
* maybe, we should return the old enable-status |
|
4835 |
* as boolean here ... |
|
4836 |
*/ |
|
4837 |
RETURN (self); |
|
68 | 4838 |
} |
4839 |
%}. |
|
4840 |
||
4841 |
" |
|
4842 |
this error is triggered on non-integer argument, or |
|
4843 |
if the signal number is not in the valid range (1..NSIG) |
|
4844 |
" |
|
792 | 4845 |
^ self primitiveFailed |
63 | 4846 |
! |
4847 |
||
831 | 4848 |
enableTimer:milliSeconds |
616 | 4849 |
"trigger a timerInterrupt, to be signalled after some (real) time." |
4850 |
||
4851 |
%{ /* NOCONTEXT */ |
|
831 | 4852 |
int millis; |
4853 |
||
4854 |
millis = __intVal(milliSeconds); |
|
616 | 4855 |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4856 |
#if defined(ITIMER_REAL) |
831 | 4857 |
{ |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4858 |
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
|
4859 |
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
|
4860 |
#ifndef __signalTimerInterrupt |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4861 |
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
|
4862 |
#endif |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4863 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4864 |
if (firstCall) { |
831 | 4865 |
# ifdef HAS_SIGACTION |
4866 |
struct sigaction act; |
|
4867 |
||
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4868 |
act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */ |
831 | 4869 |
sigemptyset(&act.sa_mask); |
4870 |
act.sa_handler = __signalTimerInterrupt; |
|
4871 |
sigaction(SIGALRM, &act, 0); |
|
4872 |
# else |
|
4873 |
# 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
|
4874 |
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
|
4875 |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
4876 |
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
|
4877 |
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
|
4878 |
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
|
4879 |
sigvec(SIGALRM, &vec, NULL); |
831 | 4880 |
# else |
4881 |
signal(SIGALRM, __signalTimerInterrupt); |
|
4882 |
# endif |
|
4883 |
# endif |
|
4884 |
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
|
4885 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4886 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4887 |
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
|
4888 |
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
|
4889 |
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
|
4890 |
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
|
4891 |
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
|
4892 |
RETURN (true); |
831 | 4893 |
} |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
4894 |
#else |
831 | 4895 |
# ifdef WIN32 |
4896 |
{ |
|
4897 |
/* |
|
4898 |
* two mechanisms - which one to use ? |
|
4899 |
*/ |
|
4900 |
# define USE_TimerProc |
|
4901 |
# ifdef USE_TimerProc |
|
4902 |
||
4903 |
extern VOID CALLBACK __win32TimerProc(HWND, UINT, UINT, DWORD); |
|
4904 |
SetTimer(NULL, 0, millis, __win32TimerProc); |
|
4905 |
||
4906 |
# else /* USE_TimeProc */ |
|
4907 |
||
4908 |
extern void CALLBACK __win32TimeProc(UINT, UINT, DWORD, DWORD, DWORD, DWORD); |
|
4909 |
timeSetEvent(millis, 5, __win32TimeProc, 0, TIME_ONESHOT); |
|
4910 |
# endif |
|
640
be94dfc60eaa
Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents:
630
diff
changeset
|
4911 |
} |
831 | 4912 |
# endif /* WIN32 */ |
4913 |
#endif /* ITIMER_REAL */ |
|
4914 |
%}. |
|
616 | 4915 |
^ false |
4916 |
! |
|
4917 |
||
1 | 4918 |
enableUserInterrupts |
4919 |
"enable userInterrupt (^C) handling; |
|
95 | 4920 |
when enabled, ^C in the terminal window will send the message |
4921 |
'userInterrupt' to the UserInterruptHandler object." |
|
1 | 4922 |
|
831 | 4923 |
self enableSignal:(self sigINT). |
4924 |
self enableSignal:(self sigBREAK). |
|
63 | 4925 |
! |
4926 |
||
616 | 4927 |
interruptPending |
4928 |
"return true, if an interrupt is pending. The returned value is |
|
4929 |
invalid if interrupts are not currently blocked, since otherwise |
|
4930 |
the interrupt is usually already handled before arriving here, |
|
4931 |
or may be served while returning from here." |
|
4932 |
||
4933 |
%{ /* NOCONTEXT */ |
|
4934 |
extern OBJ __INTERRUPTPENDING(); |
|
4935 |
||
4936 |
RETURN ( __INTERRUPTPENDING() ); |
|
4937 |
%} |
|
1 | 4938 |
! |
4939 |
||
704 | 4940 |
killProcess:processId |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
4941 |
"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
|
4942 |
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
|
4943 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4944 |
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
|
4945 |
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
|
4946 |
OperatingSystem>>getStatusOfProcess:aProcessId." |
704 | 4947 |
|
4948 |
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
|
4949 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
4950 |
"Modified: 28.12.1995 / 15:06:18 / stefan" |
704 | 4951 |
! |
4952 |
||
616 | 4953 |
nameForSignal:aSignalNumber |
4954 |
"for a given Unix signalnumber, return a descriptive string" |
|
4955 |
||
4956 |
aSignalNumber == self sigHUP ifTrue:[^ 'hangup']. |
|
4957 |
aSignalNumber == self sigINT ifTrue:[^ 'interrupt']. |
|
4958 |
aSignalNumber == self sigKILL ifTrue:[^ 'kill']. |
|
4959 |
aSignalNumber == self sigQUIT ifTrue:[^ 'quit']. |
|
4960 |
aSignalNumber == self sigILL ifTrue:[^ 'illegal instruction']. |
|
4961 |
aSignalNumber == self sigTRAP ifTrue:[^ 'trap']. |
|
4962 |
aSignalNumber == self sigABRT ifTrue:[^ 'abort']. |
|
4963 |
aSignalNumber == self sigIOT ifTrue:[^ 'iot trap']. |
|
4964 |
aSignalNumber == self sigEMT ifTrue:[^ 'emt trap']. |
|
4965 |
aSignalNumber == self sigFP ifTrue:[^ 'fp exception']. |
|
4966 |
aSignalNumber == self sigBUS ifTrue:[^ 'bus error']. |
|
4967 |
aSignalNumber == self sigSEGV ifTrue:[^ 'segmentation violation']. |
|
4968 |
aSignalNumber == self sigSYS ifTrue:[^ 'bad system call']. |
|
4969 |
aSignalNumber == self sigPIPE ifTrue:[^ 'broken pipe']. |
|
4970 |
aSignalNumber == self sigALRM ifTrue:[^ 'alarm timer']. |
|
4971 |
aSignalNumber == self sigTERM ifTrue:[^ 'termination']. |
|
4972 |
aSignalNumber == self sigSTOP ifTrue:[^ 'stop']. |
|
4973 |
aSignalNumber == self sigTSTP ifTrue:[^ 'tty stop']. |
|
4974 |
aSignalNumber == self sigCONT ifTrue:[^ 'continue']. |
|
4975 |
aSignalNumber == self sigCHLD ifTrue:[^ 'child death']. |
|
4976 |
aSignalNumber == self sigTTIN ifTrue:[^ 'background tty input']. |
|
4977 |
aSignalNumber == self sigTTOU ifTrue:[^ 'background tty output']. |
|
4978 |
aSignalNumber == self sigIO ifTrue:[^ 'io available']. |
|
4979 |
aSignalNumber == self sigXCPU ifTrue:[^ 'cpu time expired']. |
|
4980 |
aSignalNumber == self sigXFSZ ifTrue:[^ 'file size limit']. |
|
4981 |
aSignalNumber == self sigVTALRM ifTrue:[^ 'virtual alarm timer']. |
|
4982 |
aSignalNumber == self sigPROF ifTrue:[^ 'profiling timer']. |
|
4983 |
aSignalNumber == self sigWINCH ifTrue:[^ 'winsize changed']. |
|
4984 |
aSignalNumber == self sigLOST ifTrue:[^ 'resource lost']. |
|
4985 |
aSignalNumber == self sigUSR1 ifTrue:[^ 'user signal 1']. |
|
4986 |
aSignalNumber == self sigUSR2 ifTrue:[^ 'user signal 2']. |
|
4987 |
aSignalNumber == self sigMSG ifTrue:[^ 'HFT message']. |
|
4988 |
aSignalNumber == self sigPWR ifTrue:[^ 'power-fail']. |
|
4989 |
aSignalNumber == self sigPRE ifTrue:[^ 'programming exception']. |
|
4990 |
aSignalNumber == self sigGRANT ifTrue:[^ 'HFT access wanted']. |
|
4991 |
aSignalNumber == self sigRETRACT ifTrue:[^ 'HFT access relinquish']. |
|
4992 |
aSignalNumber == self sigSOUND ifTrue:[^ 'HFT sound complete']. |
|
4993 |
aSignalNumber == self sigDANGER ifTrue:[^ 'low on paging space']. |
|
4994 |
||
4995 |
"notice: many systems map SIGPOLL and/or SIGUSR onto SIGIO |
|
4996 |
therefore, keep SIGIO always above the two below" |
|
4997 |
aSignalNumber == self sigPOLL ifTrue:[^ 'io available']. |
|
4998 |
aSignalNumber == self sigURG ifTrue:[^ 'urgent']. |
|
4999 |
||
5000 |
^ 'unknown signal' |
|
5001 |
||
68 | 5002 |
" |
616 | 5003 |
OperatingSystem nameForSignal:9 |
5004 |
OperatingSystem nameForSignal:(OperatingSystem sigPOLL) |
|
68 | 5005 |
" |
616 | 5006 |
! |
5007 |
||
5008 |
operatingSystemSignal:signalNumber |
|
5009 |
"return the signal to be raised when an |
|
5010 |
operatingSystem-signal occurs, or nil" |
|
5011 |
||
5012 |
OSSignals notNil ifTrue:[ |
|
5013 |
^ OSSignals at:signalNumber ifAbsent:[nil] |
|
5014 |
]. |
|
5015 |
^ nil |
|
10 | 5016 |
! |
5017 |
||
616 | 5018 |
operatingSystemSignal:signalNumber install:aSignal |
5019 |
"install a signal to be raised when an operatingSystem-signal occurs" |
|
5020 |
||
5021 |
OSSignals isNil ifTrue:[ |
|
5022 |
OSSignals := Array new:32 |
|
5023 |
]. |
|
5024 |
OSSignals at:signalNumber put:aSignal |
|
5025 |
! |
|
5026 |
||
5027 |
sendSignal:signalNumber to:processId |
|
5028 |
"send a unix signal to some process (maybe myself). |
|
5029 |
Returns false if any error occurred, true otherwise. |
|
5030 |
||
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5031 |
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
|
5032 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5033 |
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
|
5034 |
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
|
5035 |
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
|
5036 |
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
|
5037 |
|
616 | 5038 |
%{ |
792 | 5039 |
#ifndef MSDOS_LIKE |
616 | 5040 |
if (__bothSmallInteger(signalNumber, processId)) { |
5041 |
if (kill(__intVal(processId), __intVal(signalNumber)) < 0) { |
|
1135 | 5042 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
616 | 5043 |
RETURN ( false ); |
216 | 5044 |
} |
616 | 5045 |
RETURN ( true ); |
10 | 5046 |
} |
792 | 5047 |
#endif |
68 | 5048 |
%}. |
792 | 5049 |
"/ |
5050 |
"/ either invalid argument (non-integers) |
|
5051 |
"/ or not supported by OS |
|
5052 |
"/ |
|
5053 |
^ self primitiveFailed |
|
1 | 5054 |
! |
5055 |
||
5056 |
startSpyTimer |
|
63 | 5057 |
"trigger a spyInterrupt, to be signalled after some short (virtual) time. |
359 | 5058 |
This is used by the old MessageTally for profiling. |
63 | 5059 |
Should be changed to use real profiling timer if available. |
68 | 5060 |
On systems, where no virtual timer is available, use the real timer |
359 | 5061 |
(which is of course less correct). |
5062 |
OBSOLETE: the new messageTally runs as a high prio process, not using |
|
5063 |
spy interrupts." |
|
1 | 5064 |
|
5065 |
%{ /* NOCONTEXT */ |
|
5066 |
||
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5067 |
#ifndef __spyInterrupt |
329 | 5068 |
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
|
5069 |
#endif |
10 | 5070 |
#if defined(ITIMER_VIRTUAL) |
1 | 5071 |
struct itimerval dt; |
5072 |
||
13 | 5073 |
# ifdef SIGVTALRM |
329 | 5074 |
signal(SIGVTALRM, __spyInterrupt); |
13 | 5075 |
# else |
329 | 5076 |
signal(SIGALRM, __spyInterrupt); |
13 | 5077 |
# endif |
5078 |
||
348 | 5079 |
dt.it_interval.tv_sec = 0; |
5080 |
dt.it_interval.tv_usec = 0; |
|
5081 |
dt.it_value.tv_sec = 0; |
|
5082 |
dt.it_value.tv_usec = 1000; /* 1000 Hz */ |
|
5083 |
setitimer(ITIMER_VIRTUAL, &dt, 0); |
|
5084 |
||
13 | 5085 |
RETURN (true); |
1 | 5086 |
#endif |
5087 |
%} |
|
13 | 5088 |
. |
5089 |
^ false |
|
1 | 5090 |
! |
5091 |
||
5092 |
stopSpyTimer |
|
359 | 5093 |
"stop spy timing - disable spy timer. |
5094 |
OBSOLETE: the new messageTally runs as a high prio process, not using |
|
5095 |
spy interrupts." |
|
1 | 5096 |
|
5097 |
%{ /* NOCONTEXT */ |
|
5098 |
||
10 | 5099 |
#if defined(ITIMER_VIRTUAL) |
1 | 5100 |
struct itimerval dt; |
5101 |
||
5102 |
dt.it_interval.tv_sec = 0; |
|
5103 |
dt.it_interval.tv_usec = 0; |
|
5104 |
dt.it_value.tv_sec = 0; |
|
5105 |
dt.it_value.tv_usec = 0; |
|
5106 |
setitimer(ITIMER_VIRTUAL, &dt, 0); |
|
13 | 5107 |
RETURN (true); |
10 | 5108 |
#endif |
5109 |
%} |
|
13 | 5110 |
. |
5111 |
^ false |
|
10 | 5112 |
! |
5113 |
||
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5114 |
terminateProcess:processId |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5115 |
"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
|
5116 |
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
|
5117 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5118 |
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
|
5119 |
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
|
5120 |
OperatingSystem>>getStatusOfProcess:aProcessId." |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5121 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5122 |
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
|
5123 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5124 |
"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
|
5125 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
5126 |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5127 |
terminateProcessGroup:processGroupId |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5128 |
"terminate a unix process group. |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5129 |
The process has a chance to do some cleanup. |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5130 |
|
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5131 |
WARNING: in order to avoid zombie processes (on unix), |
1487 | 5132 |
you may have to fetch the processes exitstatus with |
5133 |
OperatingSystem>>getStatusOfProcess:aProcessId." |
|
1280
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5134 |
|
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5135 |
self sendSignal:(self sigTERM) to:(processGroupId negated). |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5136 |
|
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5137 |
"Modified: 28.12.1995 / 15:05:37 / stefan" |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5138 |
"Created: 23.4.1996 / 16:40:34 / stefan" |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5139 |
! |
b7ae6227f48b
Allow setting of process group in exec:....
Stefan Vogel <sv@exept.de>
parents:
1247
diff
changeset
|
5140 |
|
616 | 5141 |
unblockInterrupts |
5142 |
"enable interrupt processing - if any interrupts are pending, |
|
5143 |
these will be handled immediately. |
|
5144 |
When unblocking interrupts, take care of nested block/unblock |
|
5145 |
calls - you must only unblock after a blockcall if they where |
|
5146 |
really not blocked before. See OperatingSystemclass>>blockInterrupts." |
|
5147 |
%{ |
|
5148 |
__UNBLOCKINTERRUPTS(); |
|
1040
60e4c4bbbca2
return nil from unblockInterrupts (thats what the inlined code returns)
Claus Gittinger <cg@exept.de>
parents:
1034
diff
changeset
|
5149 |
RETURN (nil); |
616 | 5150 |
%} |
5151 |
! ! |
|
5152 |
||
1497 | 5153 |
!OperatingSystem class methodsFor:'misc'! |
616 | 5154 |
|
5155 |
exit |
|
710 | 5156 |
"shutdown smalltalk immediately - this method does not return. |
5157 |
Return 'good'-status (0) to the parent unix process." |
|
616 | 5158 |
|
5159 |
%{ /* NOCONTEXT */ |
|
5160 |
__mainExit(0); |
|
5161 |
%} |
|
5162 |
"OperatingSystem exit - dont evaluate this" |
|
5163 |
! |
|
5164 |
||
5165 |
exit:exitCode |
|
5166 |
"shutdown smalltalk immediately - |
|
5167 |
returning an exit-code to the parent unix process." |
|
5168 |
||
5169 |
%{ /* NOCONTEXT */ |
|
5170 |
int code = 1; |
|
5171 |
||
5172 |
if (__isSmallInteger(exitCode)) { |
|
1135 | 5173 |
code = __intVal(exitCode); |
616 | 5174 |
} |
5175 |
__mainExit(code); |
|
5176 |
%} |
|
5177 |
"OperatingSystem exit:1 - dont evaluate this" |
|
5178 |
! |
|
5179 |
||
5180 |
exitWithCoreDump |
|
5181 |
"shutdown smalltalk immediately - dumping core. |
|
5182 |
This always returns 'bad'-status to the parent unix process. |
|
5183 |
Notice, that no cleanup is performed at all - you may have to |
|
5184 |
manually remove any tempfiles. |
|
5185 |
Use this only for debugging ST/X itself" |
|
5186 |
||
5187 |
%{ /* NOCONTEXT */ |
|
5188 |
abort(); |
|
5189 |
%} |
|
831 | 5190 |
" |
5191 |
OperatingSystem exitWithCoreDump - dont evaluate this |
|
5192 |
" |
|
616 | 5193 |
! |
5194 |
||
5195 |
slowFork:aBoolean |
|
1247 | 5196 |
"set/clear the `avoid-fork-if-possible-because-its-slow' flag. |
5197 |
Only used internally on SYSV3 systems" |
|
5198 |
||
616 | 5199 |
SlowFork := aBoolean |
1247 | 5200 |
|
5201 |
"Modified: 22.4.1996 / 13:13:09 / cg" |
|
616 | 5202 |
! ! |
5203 |
||
1497 | 5204 |
!OperatingSystem class methodsFor:'os queries'! |
616 | 5205 |
|
5206 |
getCPUDefine |
|
831 | 5207 |
"return a string which was used to identify this CPU type when STX was |
616 | 5208 |
compiled, and which should be passed down when compiling methods. |
831 | 5209 |
For example, on linux, this may be '-Di386'; on a vax, this would be '-Dvax'. |
5210 |
This is normally not of interest to 'normal' users; however, it is passed |
|
5211 |
down to the c-compiler when methods are incrementally compiled to machine code." |
|
616 | 5212 |
|
5213 |
%{ /* NOCONTEXT */ |
|
831 | 5214 |
# ifndef CPU_DEFINE |
5215 |
# define CPU_DEFINE "-DunknownCPU" |
|
5216 |
# endif |
|
5217 |
||
616 | 5218 |
RETURN ( __MKSTRING(CPU_DEFINE COMMA_CON)); |
5219 |
%} |
|
5220 |
" |
|
5221 |
OperatingSystem getCPUDefine |
|
5222 |
" |
|
5223 |
! |
|
5224 |
||
5225 |
getCPUType |
|
5226 |
"return a string giving the type of machine we're running on. |
|
831 | 5227 |
Here, the machine for which ST/X was compiled is returned |
5228 |
(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
|
5229 |
This may normally not be of any interest to you ..." |
616 | 5230 |
|
5231 |
|cpu| |
|
5232 |
||
5233 |
%{ /* NOCONTEXT */ |
|
5234 |
||
5235 |
# ifdef vax |
|
5236 |
# define CPU_STRING "vax" |
|
5237 |
# endif |
|
5238 |
# ifdef mips |
|
5239 |
# define CPU_STRING "mips" |
|
5240 |
# endif |
|
5241 |
# ifdef i386 |
|
5242 |
# define CPU_STRING "i386" |
|
5243 |
# endif |
|
5244 |
# ifdef ns32k |
|
5245 |
# define CPU_STRING "ns32k" |
|
5246 |
# endif |
|
5247 |
# ifdef mc68k |
|
5248 |
# define CPU_STRING "mc68k" |
|
5249 |
# endif |
|
5250 |
# ifdef mc88k |
|
5251 |
# define CPU_STRING "mc88k" |
|
5252 |
# endif |
|
5253 |
# ifdef sparc |
|
5254 |
# define CPU_STRING "sparc" |
|
5255 |
# endif |
|
5256 |
# ifdef hppa |
|
5257 |
# define CPU_STRING "hppa" |
|
5258 |
# endif |
|
5259 |
# ifdef rs6000 |
|
5260 |
# define CPU_STRING "rs6000" |
|
5261 |
# endif |
|
831 | 5262 |
# ifdef powerPC |
5263 |
# define CPU_STRING "powerPC" |
|
5264 |
# endif |
|
616 | 5265 |
# ifdef alpha |
5266 |
# define CPU_STRING "alpha" |
|
5267 |
# endif |
|
5268 |
# ifdef transputer |
|
5269 |
# define CPU_STRING "transputer" |
|
5270 |
# endif |
|
5271 |
# ifdef ibm370 |
|
5272 |
# define CPU_STRING "ibm370" |
|
5273 |
# endif |
|
5274 |
||
5275 |
# ifndef CPU_STRING |
|
5276 |
# define CPU_STRING "unknown" |
|
5277 |
# endif |
|
5278 |
||
830 | 5279 |
cpu = __MKSTRING(CPU_STRING COMMA_CON); |
616 | 5280 |
# undef CPU_STRING |
831 | 5281 |
%}. |
616 | 5282 |
^ cpu |
5283 |
||
5284 |
" |
|
5285 |
OperatingSystem getCPUType |
|
5286 |
" |
|
5287 |
||
5288 |
"examples: are we running on a ss-10/solaris ?" |
|
5289 |
" |
|
5290 |
(OperatingSystem getCPUType = 'sparc') |
|
5291 |
and:[OperatingSystem getOSType = 'solaris'] |
|
5292 |
" |
|
5293 |
||
5294 |
"or on a pc/solaris ?" |
|
5295 |
" |
|
5296 |
(OperatingSystem getCPUType = 'i386') |
|
5297 |
and:[OperatingSystem getOSType = 'solaris'] |
|
5298 |
" |
|
5299 |
! |
|
5300 |
||
5301 |
getCommandOutputFrom:aCommand |
|
5302 |
"execute a simple command (such as hostname) and |
|
5303 |
return the commands output as a string" |
|
5304 |
||
5305 |
|p result| |
|
5306 |
||
5307 |
ForkFailed ifFalse:[ |
|
5308 |
PipeStream openErrorSignal handle:[:ex | |
|
5309 |
ForkFailed := true. |
|
5310 |
'OS: cannot fork/popen' errorPrintNL. |
|
5311 |
ex return. |
|
5312 |
] do:[ |
|
5313 |
p := PipeStream readingFrom:aCommand. |
|
5314 |
p notNil ifTrue:[ |
|
5315 |
result := p nextLine. |
|
5316 |
p close |
|
5317 |
] |
|
5318 |
] |
|
5319 |
]. |
|
5320 |
^ result |
|
5321 |
! |
|
5322 |
||
5323 |
getDomainName |
|
5324 |
"return the domain this host is in. |
|
5325 |
Notice: |
|
1487 | 5326 |
not all systems support this; on some, 'unknown' is returned." |
616 | 5327 |
|
5328 |
|name| |
|
5329 |
||
5330 |
DomainName notNil ifTrue:[ |
|
1487 | 5331 |
^ DomainName |
616 | 5332 |
]. |
5333 |
||
5334 |
%{ /* STACK: 2048 */ |
|
5335 |
#if defined(HAS_GETDOMAINNAME) |
|
5336 |
char buffer[128]; |
|
5337 |
||
5338 |
if (getdomainname(buffer, sizeof(buffer)) == 0) { |
|
1487 | 5339 |
name = __MKSTRING(buffer COMMA_CON); |
616 | 5340 |
} |
5341 |
#else |
|
5342 |
# if defined(HAS_UNAME) && defined(HAS_UTS_DOMAINNAME) |
|
5343 |
struct utsname ubuff; |
|
5344 |
||
5345 |
if (uname(&ubuff) >= 0) { |
|
1487 | 5346 |
name = __MKSTRING(ubuff.domainname COMMA_CON); |
1433 | 5347 |
} |
5348 |
# else |
|
5349 |
# if defined(HAS_SYSINFO) && defined(SI_SRPC_DOMAIN) |
|
5350 |
char buffer[256]; |
|
5351 |
int ret; |
|
5352 |
||
5353 |
if ((ret = sysinfo(SI_SRPC_DOMAIN, buffer, sizeof(buffer))) >= 0 && ret <= sizeof(buffer)) { |
|
1487 | 5354 |
name = __MKSTRING(buffer COMMA_CON); |
1433 | 5355 |
} |
5356 |
# endif |
|
616 | 5357 |
# endif |
5358 |
#endif |
|
5359 |
%}. |
|
5360 |
name isNil ifTrue:[ |
|
1487 | 5361 |
name := self getEnvironment:'DOMAIN'. |
5362 |
name isNil ifTrue:[ |
|
5363 |
name := self getCommandOutputFrom:'domainname' |
|
5364 |
] |
|
616 | 5365 |
]. |
5366 |
name isNil ifTrue:[ |
|
1487 | 5367 |
'OS: cannot find out domainname' errorPrintNL. |
5368 |
name := 'unknown'. |
|
616 | 5369 |
]. |
5370 |
DomainName := name. |
|
5371 |
^ name |
|
5372 |
||
5373 |
" |
|
5374 |
OperatingSystem getDomainName |
|
5375 |
" |
|
1433 | 5376 |
|
5377 |
"Modified: 26.4.1996 / 10:04:54 / stefan" |
|
616 | 5378 |
! |
5379 |
||
5380 |
getEnvironment:aStringOrSymbol |
|
5381 |
"get an environment string" |
|
10 | 5382 |
|
5383 |
%{ /* NOCONTEXT */ |
|
5384 |
||
616 | 5385 |
char *env; |
5386 |
||
5387 |
if (__isString(aStringOrSymbol) || __isSymbol(aStringOrSymbol)) { |
|
1135 | 5388 |
env = (char *)getenv(__stringVal(aStringOrSymbol)); |
616 | 5389 |
if (env) { |
830 | 5390 |
RETURN ( __MKSTRING(env COMMA_CON) ); |
616 | 5391 |
} |
5392 |
} |
|
5393 |
%} |
|
5394 |
. |
|
5395 |
^ nil |
|
5396 |
||
5397 |
" |
|
5398 |
OperatingSystem getEnvironment:'LANG' |
|
5399 |
OperatingSystem getEnvironment:'LOGIN' |
|
5400 |
OperatingSystem getEnvironment:'HOME' |
|
5401 |
OperatingSystem getEnvironment:'NNTPSERVER' |
|
5402 |
OperatingSystem getEnvironment:'MAIL' |
|
5403 |
OperatingSystem getEnvironment:'PATH' |
|
5404 |
" |
|
5405 |
! |
|
5406 |
||
5407 |
getHostName |
|
5408 |
"return the hostname we are running on - if there is |
|
5409 |
a HOST environment variable, we are much faster here ... |
|
5410 |
Notice: |
|
5411 |
not all systems support this; on some, 'unknown' is returned." |
|
5412 |
||
5413 |
|name| |
|
5414 |
||
5415 |
HostName notNil ifTrue:[ |
|
5416 |
^ HostName |
|
5417 |
]. |
|
5418 |
||
5419 |
%{ /* STACK: 2048 */ |
|
5420 |
#if defined(HAS_GETHOSTNAME) |
|
5421 |
char buffer[128]; |
|
5422 |
||
5423 |
if (gethostname(buffer, sizeof(buffer)) == 0) { |
|
830 | 5424 |
name = __MKSTRING(buffer COMMA_CON); |
616 | 5425 |
} |
5426 |
#else |
|
5427 |
# if defined(HAS_UNAME) |
|
5428 |
struct utsname ubuff; |
|
5429 |
||
5430 |
if (uname(&ubuff) >= 0) { |
|
830 | 5431 |
name = __MKSTRING(ubuff.nodename COMMA_CON); |
616 | 5432 |
} |
831 | 5433 |
# else |
5434 |
# ifdef WIN32 |
|
5435 |
char buffer[128]; |
|
5436 |
int buffSize = sizeof(buffer); |
|
5437 |
||
5438 |
if (GetComputerName(buffer, &buffSize) == TRUE) { |
|
1135 | 5439 |
name = __MKSTRING(buffer COMMA_CON); |
831 | 5440 |
} |
5441 |
# endif |
|
1 | 5442 |
# endif |
616 | 5443 |
#endif |
5444 |
%}. |
|
5445 |
name isNil ifTrue:[ |
|
5446 |
name := self getEnvironment:'HOST'. |
|
5447 |
name isNil ifTrue:[ |
|
5448 |
name := self getCommandOutputFrom:'hostname' |
|
5449 |
] |
|
5450 |
]. |
|
5451 |
name isNil ifTrue:[ |
|
5452 |
'OS: cannot find out hostname' errorPrintNL. |
|
5453 |
name := 'unknown'. |
|
5454 |
]. |
|
5455 |
HostName := name. |
|
5456 |
^ name |
|
5457 |
||
5458 |
" |
|
5459 |
OperatingSystem getHostName |
|
5460 |
" |
|
5461 |
! |
|
5462 |
||
1034 | 5463 |
getLocaleInfo |
5464 |
"return a dictionary filled with values from the locale information; |
|
5465 |
Not all fields may be present, depending on the OS's setup and capabilities. |
|
5466 |
Possible fields are: |
|
5467 |
decimalPoint <String> |
|
5468 |
||
5469 |
thousandsSep <String> |
|
5470 |
||
5471 |
internationalCurrencySymbol <String> |
|
5472 |
||
5473 |
currencySymbol <String> |
|
5474 |
||
5475 |
monetaryDecimalPoint <String> |
|
5476 |
||
5477 |
monetaryThousandsSeparator <String> |
|
5478 |
||
5479 |
positiveSign <String> |
|
5480 |
||
5481 |
negativeSign <String> |
|
5482 |
||
5483 |
internationalFractionalDigits <Integer> |
|
5484 |
||
5485 |
fractionalDigits <Integer> |
|
5486 |
||
5487 |
positiveSignPrecedesCurrencySymbol <Boolean> |
|
5488 |
||
5489 |
negativeSignPrecedesCurrencySymbol <Boolean> |
|
5490 |
||
5491 |
positiveSignSeparatedBySpaceFromCurrencySymbol <Boolean> |
|
5492 |
||
5493 |
negativeSignSeparatedBySpaceFromCurrencySymbol <Boolean> |
|
5494 |
||
5495 |
positiveSignPosition <Symbol> |
|
5496 |
one of: #parenthesesAround, |
|
5497 |
#signPrecedes, |
|
5498 |
#signSuceeds, |
|
5499 |
#signPrecedesCurrencySymbol, |
|
5500 |
#signSuceedsCurrencySymbol |
|
5501 |
||
5502 |
negativeSignPosition <like above> |
|
5503 |
||
5504 |
it is up to the application to deal with undefined values. |
|
5505 |
||
5506 |
Notice, that (for now), the system does not use this information; |
|
5507 |
it should be used by applications as required. |
|
5508 |
" |
|
5509 |
||
5510 |
|info val| |
|
5511 |
||
5512 |
LocaleInfo notNil ifTrue:[ |
|
5513 |
"/ return the internal info; useful on systems which do not |
|
5514 |
"/ support this. |
|
5515 |
^ LocaleInfo |
|
5516 |
]. |
|
5517 |
||
5518 |
info := IdentityDictionary new. |
|
5519 |
%{ |
|
5520 |
char *decimalPoint; /* something like "." (US) or "," (german) */ |
|
5521 |
char *thousandsSep; /* something like "," (US) or "." (german) */ |
|
5522 |
char *intCurrencySymbol; /* international currency symbol; something like "USD " "DM " */ |
|
5523 |
char *currencySymbol; /* local currency symbol; something like "USD " "DM " */ |
|
5524 |
char *monDecimalPoint; /* money: decimal point */ |
|
5525 |
char *monThousandsSep; /* money: thousands sep */ |
|
5526 |
char *positiveSign; |
|
5527 |
char *negativeSign; |
|
5528 |
int intFractDigits; /* money: international digits after decPoint */ |
|
5529 |
int fractDigits; /* money: local digits after decPoint */ |
|
5530 |
int csPosPrecedes; /* money: 1 if currency symbol precedes a positive value; 0 if it sceeds */ |
|
5531 |
int csNegPrecedes; /* money: 1 if currency symbol precedes a negative value; 0 if it sceeds */ |
|
5532 |
int csPosSepBySpace; /* money: 1 if currency symbol should be separated by a space from a positive value; 0 if no space */ |
|
5533 |
int csNegSepBySpace; /* money: 1 if currency symbol should be separated by a space from a negative value; 0 if no space */ |
|
5534 |
int csPosSignPosition; /* money: 0: ()'s around the value & currency symbol */ |
|
5535 |
int csNegSignPosition; /* 1: sign precedes the value & currency symbol */ |
|
5536 |
/* 2: sign succeeds the value & currency symbol */ |
|
5537 |
/* 3: sign immediately precedes the currency symbol */ |
|
5538 |
/* 4: sign immediately suceeds the currency symbol */ |
|
5539 |
||
5540 |
#if defined(HAS_LOCALECONV) |
|
5541 |
struct lconv *conf; |
|
5542 |
||
5543 |
conf = localeconv(); |
|
5544 |
if (conf) { |
|
5545 |
decimalPoint = conf->decimal_point; |
|
5546 |
thousandsSep = conf->thousands_sep; |
|
5547 |
intCurrencySymbol = conf->int_curr_symbol; |
|
5548 |
currencySymbol = conf->currency_symbol; |
|
5549 |
monDecimalPoint = conf->mon_decimal_point; |
|
5550 |
monThousandsSep = conf->mon_thousands_sep; |
|
5551 |
positiveSign = conf->positive_sign; |
|
5552 |
negativeSign = conf->negative_sign; |
|
5553 |
intFractDigits = conf->int_frac_digits; |
|
5554 |
fractDigits = conf->frac_digits; |
|
5555 |
csPosPrecedes = conf->p_cs_precedes; |
|
5556 |
csNegPrecedes = conf->n_cs_precedes; |
|
5557 |
csPosSepBySpace = conf->p_sep_by_space; |
|
5558 |
csNegSepBySpace = conf->n_sep_by_space; |
|
5559 |
csPosSignPosition = conf->p_sign_posn; |
|
5560 |
csNegSignPosition = conf->n_sign_posn; |
|
5561 |
} |
|
5562 |
#else |
|
5563 |
decimalPoint = (char *)0; |
|
5564 |
thousandsSep = (char *)0; |
|
5565 |
intCurrencySymbol = (char *)0; |
|
5566 |
currencySymbol = (char *)0; |
|
5567 |
monDecimalPoint = (char *)0; |
|
5568 |
monThousandsSep = (char *)0; |
|
5569 |
positiveSign = (char *)0; |
|
5570 |
negativeSign =(char *)0; |
|
5571 |
intFractDigits = -1; |
|
5572 |
fractDigits = -1; |
|
5573 |
csPosPrecedes = -1; |
|
5574 |
csNegPrecedes = -1; |
|
5575 |
csPosSepBySpace = -1; |
|
5576 |
csNegSepBySpace = -1; |
|
5577 |
csPosSignPosition = -1; |
|
5578 |
csNegSignPosition = -1; |
|
5579 |
#endif |
|
5580 |
if (decimalPoint) { |
|
5581 |
val = __MKSTRING(decimalPoint); |
|
5582 |
__AT_PUT_(info, @symbol(decimalPoint), val); |
|
5583 |
} |
|
5584 |
if (thousandsSep) { |
|
5585 |
val = __MKSTRING(thousandsSep); |
|
5586 |
__AT_PUT_(info, @symbol(thousandsSeparator), val); |
|
5587 |
} |
|
5588 |
if (intCurrencySymbol) { |
|
5589 |
val = __MKSTRING(intCurrencySymbol); |
|
5590 |
__AT_PUT_(info, @symbol(internationCurrencySymbol), val); |
|
5591 |
} |
|
5592 |
if (currencySymbol) { |
|
5593 |
val = __MKSTRING(currencySymbol); |
|
5594 |
__AT_PUT_(info, @symbol(currencySymbol), val); |
|
5595 |
} |
|
5596 |
if (monDecimalPoint) { |
|
5597 |
val = __MKSTRING(monDecimalPoint); |
|
5598 |
__AT_PUT_(info, @symbol(monetaryDecimalPoint), val); |
|
5599 |
} |
|
5600 |
if (monThousandsSep) { |
|
5601 |
val = __MKSTRING(monThousandsSep); |
|
5602 |
__AT_PUT_(info, @symbol(monetaryThousandsSeparator), val); |
|
5603 |
} |
|
5604 |
if (positiveSign) { |
|
5605 |
val = __MKSTRING(positiveSign); |
|
5606 |
__AT_PUT_(info, @symbol(positiveSign), val); |
|
5607 |
} |
|
5608 |
if (negativeSign) { |
|
5609 |
val = __MKSTRING(negativeSign); |
|
5610 |
__AT_PUT_(info, @symbol(negativeSign), val); |
|
5611 |
} |
|
5612 |
if (intFractDigits >= 0) { |
|
5613 |
__AT_PUT_(info, @symbol(internationalFractionalDigits), __MKSMALLINT(intFractDigits)); |
|
5614 |
} |
|
5615 |
if (fractDigits >= 0) { |
|
5616 |
__AT_PUT_(info, @symbol(fractionalDigits), __MKSMALLINT(fractDigits)); |
|
5617 |
} |
|
5618 |
if (csPosPrecedes >= 0) { |
|
5619 |
if (csPosPrecedes == 0) { |
|
5620 |
val = false; |
|
5621 |
} else { |
|
5622 |
val = true; |
|
5623 |
} |
|
5624 |
__AT_PUT_(info, @symbol(positiveSignPrecedesCurrencySymbol), val ); |
|
5625 |
} |
|
5626 |
if (csNegPrecedes >= 0) { |
|
5627 |
if (csNegPrecedes == 0) { |
|
5628 |
val = false; |
|
5629 |
} else { |
|
5630 |
val = true; |
|
5631 |
} |
|
5632 |
__AT_PUT_(info, @symbol(negativeSignPrecedesCurrencySymbol), val ); |
|
5633 |
} |
|
5634 |
if (csPosSepBySpace >= 0) { |
|
5635 |
if (csPosSepBySpace == 0) { |
|
5636 |
val = false; |
|
5637 |
} else { |
|
5638 |
val = true; |
|
5639 |
} |
|
5640 |
__AT_PUT_(info, @symbol(positiveSignSeparatedBySpaceFromCurrencySymbol), val); |
|
5641 |
} |
|
5642 |
if (csNegSepBySpace >= 0) { |
|
5643 |
if (csNegSepBySpace == 0) { |
|
5644 |
val = false; |
|
5645 |
} else { |
|
5646 |
val = true; |
|
5647 |
} |
|
5648 |
__AT_PUT_(info, @symbol(negativeSignSeparatedBySpaceFromCurrencySymbol), val); |
|
5649 |
} |
|
5650 |
switch (csPosSignPosition) { |
|
5651 |
case 0: |
|
5652 |
val = @symbol(parenthesesAround); |
|
5653 |
break; |
|
5654 |
||
5655 |
case 1: |
|
5656 |
val = @symbol(signPrecedes); |
|
5657 |
break; |
|
5658 |
||
5659 |
case 2: |
|
5660 |
val = @symbol(signSuceeds); |
|
5661 |
break; |
|
5662 |
||
5663 |
case 3: |
|
5664 |
val = @symbol(signPrecedesCurrencySymbol); |
|
5665 |
break; |
|
5666 |
||
5667 |
case 4: |
|
5668 |
val = @symbol(signSuceedsCurrencySymbol); |
|
5669 |
break; |
|
5670 |
||
5671 |
default: |
|
5672 |
val = nil; |
|
5673 |
} |
|
5674 |
if (val != nil) { |
|
5675 |
__AT_PUT_(info, @symbol(positiveSignPosition), val); |
|
5676 |
} |
|
5677 |
||
5678 |
switch (csNegSignPosition) { |
|
5679 |
case 0: |
|
5680 |
val = @symbol(parenthesesAround); |
|
5681 |
break; |
|
5682 |
||
5683 |
case 1: |
|
5684 |
val = @symbol(signPrecedes); |
|
5685 |
break; |
|
5686 |
||
5687 |
case 2: |
|
5688 |
val = @symbol(signSuceeds); |
|
5689 |
break; |
|
5690 |
||
5691 |
case 3: |
|
5692 |
val = @symbol(signPrecedesCurrencySymbol); |
|
5693 |
break; |
|
5694 |
||
5695 |
case 4: |
|
5696 |
val = @symbol(signSuceedsCurrencySymbol); |
|
5697 |
break; |
|
5698 |
||
5699 |
default: |
|
5700 |
val = nil; |
|
5701 |
} |
|
5702 |
if (val != nil) { |
|
5703 |
__AT_PUT_(info, @symbol(negativeSignPosition), val); |
|
5704 |
} |
|
5705 |
%}. |
|
5706 |
^ info |
|
5707 |
||
5708 |
" |
|
5709 |
OperatingSystem getLocaleInfo |
|
5710 |
" |
|
5711 |
||
5712 |
"Created: 23.12.1995 / 14:19:20 / cg" |
|
5713 |
! |
|
5714 |
||
616 | 5715 |
getOSDefine |
5716 |
"return a string which was used to identify this machine when stx was |
|
5717 |
compiled, and which should be passed down when compiling methods. |
|
5718 |
For example, on linux, this is '-DLINUX'." |
|
5719 |
||
5720 |
%{ /* NOCONTEXT */ |
|
831 | 5721 |
#ifdef WIN32 |
5722 |
# ifndef OS_DEFINE |
|
5723 |
# define OS_DEFINE "-DWIN32" |
|
5724 |
# endif |
|
5725 |
#endif |
|
5726 |
||
616 | 5727 |
#ifndef OS_DEFINE |
5728 |
# define OS_DEFINE "-DunknownOS" |
|
5729 |
#endif |
|
831 | 5730 |
|
616 | 5731 |
RETURN ( __MKSTRING(OS_DEFINE COMMA_CON)); |
5732 |
%} |
|
5733 |
" |
|
5734 |
OperatingSystem getOSDefine |
|
5735 |
" |
|
5736 |
! |
|
5737 |
||
5738 |
getOSType |
|
5739 |
"return a string giving the type of OS we're running on. |
|
5740 |
This can be used to adapt programs to certain environment |
|
5741 |
differences (for example: mail-lock strategy ...)" |
|
5742 |
||
5743 |
|os| |
|
5744 |
||
5745 |
%{ /* NOCONTEXT */ |
|
5746 |
||
5747 |
# ifdef MSDOS |
|
5748 |
# define OS_STRING "msdos" |
|
5749 |
# endif |
|
5750 |
||
831 | 5751 |
# ifdef WIN32 |
5752 |
char *OS_STRING = "win32"; |
|
5753 |
||
5754 |
# endif |
|
5755 |
||
616 | 5756 |
# ifdef MSWINDOWS |
5757 |
# define OS_STRING "mswindows" |
|
5758 |
# endif |
|
5759 |
||
5760 |
# ifdef NT |
|
5761 |
# define OS_STRING "nt" |
|
5762 |
# endif |
|
5763 |
||
5764 |
# ifdef VMS |
|
5765 |
# define OS_STRING "vms" |
|
5766 |
# endif |
|
5767 |
||
5768 |
# ifdef MVS |
|
5769 |
# define OS_STRING "mvs" |
|
5770 |
# endif |
|
5771 |
||
5772 |
# ifdef OS2 |
|
5773 |
# define OS_STRING "os2" |
|
5774 |
# endif |
|
5775 |
||
5776 |
# ifdef sinix |
|
5777 |
# define OS_STRING "sinix" |
|
5778 |
# endif |
|
5779 |
||
5780 |
# ifdef ultrix |
|
5781 |
# define OS_STRING "ultrix" |
|
5782 |
# endif |
|
5783 |
||
5784 |
# ifdef sco |
|
5785 |
# define OS_STRING "sco" |
|
5786 |
# endif |
|
5787 |
||
5788 |
# ifdef hpux |
|
5789 |
# define OS_STRING "hpux" |
|
5790 |
# endif |
|
5791 |
||
5792 |
# ifdef LINUX |
|
5793 |
# define OS_STRING "linux" |
|
5794 |
# endif |
|
5795 |
||
5796 |
# ifdef sunos |
|
5797 |
# define OS_STRING "sunos" |
|
5798 |
# endif |
|
5799 |
||
5800 |
# ifdef solaris |
|
5801 |
# define OS_STRING "solaris" |
|
5802 |
# endif |
|
5803 |
||
5804 |
# ifdef IRIS |
|
5805 |
# define OS_STRING "irix" |
|
5806 |
# endif |
|
5807 |
||
5808 |
# ifdef aix |
|
5809 |
# define OS_STRING "aix" |
|
5810 |
# endif |
|
5811 |
||
5812 |
# ifdef realIX |
|
5813 |
# define OS_STRING "realIX" |
|
5814 |
# endif |
|
5815 |
||
5816 |
/* |
|
5817 |
* no concrete info; become somewhat vague ... |
|
5818 |
*/ |
|
5819 |
# ifndef OS_STRING |
|
5820 |
# ifdef MACH |
|
5821 |
# define OS_STRING "mach" |
|
5822 |
# endif |
|
5823 |
# endif |
|
5824 |
||
5825 |
# ifndef OS_STRING |
|
5826 |
# ifdef BSD |
|
5827 |
# define OS_STRING "bsd" |
|
5828 |
# endif |
|
5829 |
||
5830 |
# ifdef SYSV |
|
5831 |
# ifdef SYSV3 |
|
5832 |
# define OS_STRING "sys5_3" |
|
5833 |
# else |
|
5834 |
# ifdef SYSV4 |
|
5835 |
# define OS_STRING "sys5_4" |
|
5836 |
# else |
|
5837 |
# define OS_STRING "sys5" |
|
5838 |
# endif |
|
5839 |
# endif |
|
5840 |
# endif |
|
5841 |
# endif |
|
5842 |
||
5843 |
/* |
|
5844 |
* become very vague ... |
|
5845 |
*/ |
|
5846 |
# ifndef OS_STRING |
|
5847 |
# ifdef POSIX |
|
5848 |
# define OS_STRING "posix" |
|
5849 |
# endif |
|
5850 |
# endif |
|
5851 |
# ifndef OS_STRING |
|
5852 |
# ifdef UNIX |
|
5853 |
# define OS_STRING "unix" |
|
5854 |
# endif |
|
5855 |
# endif |
|
5856 |
||
5857 |
# ifndef OS_STRING |
|
5858 |
# define OS_STRING "unknown" |
|
5859 |
# endif |
|
5860 |
||
830 | 5861 |
os = __MKSTRING(OS_STRING COMMA_CON); |
616 | 5862 |
# undef OS_STRING |
831 | 5863 |
%}. |
616 | 5864 |
^ os |
5865 |
||
5866 |
"OperatingSystem getOSType" |
|
5867 |
! |
|
5868 |
||
5869 |
getProcessId |
|
5870 |
"return the (unix-)processId" |
|
5871 |
||
5872 |
%{ /* NOCONTEXT */ |
|
5873 |
||
5874 |
int pid = 0; |
|
5875 |
#ifdef UNIX_LIKE |
|
5876 |
pid = getpid(); |
|
5877 |
#endif |
|
1135 | 5878 |
RETURN ( __MKSMALLINT(pid) ); |
616 | 5879 |
%} |
5880 |
" |
|
5881 |
OperatingSystem getProcessId |
|
5882 |
" |
|
5883 |
! |
|
5884 |
||
5885 |
getSystemID |
|
5886 |
"if supported by the OS, return the systemID; |
|
5887 |
a unique per machine identification. |
|
5888 |
WARNING: |
|
5889 |
not all systems support this; on some, 'unknown' is returned." |
|
5890 |
||
5891 |
%{ /* NO_CONTEXT */ |
|
5892 |
#if defined(IRIX5) && !defined(HAS_GETHOSTID) |
|
5893 |
char idBuffer[MAXSYSIDSIZE]; |
|
5894 |
int retVal; |
|
5895 |
OBJ arr; |
|
5896 |
||
5897 |
if ((retVal = syssgi(SGI_SYSID, idBuffer)) == 0) { |
|
5898 |
arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(MAXSYSIDSIZE); |
|
5899 |
bcopy(idBuffer, __ByteArrayInstPtr(arr)->ba_element, MAXSYSIDSIZE); |
|
5900 |
RETURN (arr); |
|
5901 |
} |
|
5902 |
#endif |
|
5903 |
#if defined(HAS_GETHOSTID) |
|
5904 |
int runningId; |
|
5905 |
OBJ arr; |
|
5906 |
||
5907 |
runningId = gethostid(); |
|
5908 |
arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(4); |
|
5909 |
*(int *)(__ByteArrayInstPtr(arr)->ba_element) = runningId; |
|
5910 |
RETURN (arr); |
|
5911 |
#endif |
|
5912 |
%}. |
|
5913 |
^ 'unknown' |
|
5914 |
||
5915 |
" |
|
5916 |
OperatingSystem getSystemID |
|
5917 |
" |
|
5918 |
! |
|
5919 |
||
5920 |
getSystemInfo |
|
831 | 5921 |
"return info on the system weare running on. |
5922 |
If the system supports the uname system call, that info is returned; |
|
616 | 5923 |
otherwise, some simulated info is returned. |
831 | 5924 |
|
616 | 5925 |
WARNING: |
831 | 5926 |
Do not depend on the amount and contents of the returned information, some |
5927 |
systems may return more/less than others. Also, the contents depends on the |
|
5928 |
OS, for example, linux returns 'ix86', while WIN32 returns 'x86'. |
|
5929 |
||
5930 |
This method is mainly provided to augment error reports with some system |
|
5931 |
information. |
|
5932 |
(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
|
5933 |
may be based upon this info) |
616 | 5934 |
|
5935 |
The returned info may (or may not) contain: |
|
831 | 5936 |
#system -> some operating system identification (irix, Linux, nt, win32s ...) |
5937 |
#version -> OS version (some os version identification) |
|
5938 |
#release -> OS release (3.5, 1.2.1 ...) |
|
5939 |
#node -> some host identification (hostname) |
|
5940 |
#domain -> domain name (hosts domain) |
|
5941 |
#machine -> type of machine (i586, mips ...) |
|
616 | 5942 |
" |
5943 |
||
5944 |
|sys node rel ver mach dom mtyp brel info| |
|
5945 |
||
1060
119d45f975e1
increased getSystemInfos stack - just to make certain
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
5946 |
%{ /* STACK: 4096 */ |
616 | 5947 |
#if defined(HAS_UNAME) |
5948 |
struct utsname ubuff; |
|
5949 |
||
5950 |
if (uname(&ubuff) >= 0) { |
|
830 | 5951 |
sys = __MKSTRING(ubuff.sysname COMMA_CON); |
5952 |
node = __MKSTRING(ubuff.nodename COMMA_CON); |
|
5953 |
rel = __MKSTRING(ubuff.release COMMA_CON); |
|
5954 |
ver = __MKSTRING(ubuff.version COMMA_CON); |
|
5955 |
mach = __MKSTRING(ubuff.machine COMMA_CON); |
|
616 | 5956 |
# ifdef HAS_UTS_DOMAINNAME |
830 | 5957 |
dom = __MKSTRING(ubuff.domainname COMMA_CON); |
616 | 5958 |
# endif |
5959 |
} |
|
831 | 5960 |
#else /* no uname */ |
5961 |
# ifdef WIN32 |
|
5962 |
||
5963 |
char vsnBuffer[32]; |
|
5964 |
char *s; |
|
5965 |
int winVer; |
|
5966 |
DWORD vsn; |
|
5967 |
SYSTEM_INFO sysInfo; |
|
5968 |
||
5969 |
vsn = GetVersion(); |
|
5970 |
||
5971 |
if (HIWORD(vsn) & 0x8000) { |
|
5972 |
s = "win32s"; |
|
5973 |
} else { |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5974 |
s = "nt"; |
831 | 5975 |
} |
5976 |
sys = __MKSTRING(s COMMA_CON); |
|
5977 |
winVer = LOWORD(vsn); |
|
5978 |
sprintf(vsnBuffer, "%d.%d", LOBYTE(winVer), HIBYTE(winVer)); |
|
5979 |
rel = __MKSTRING(vsnBuffer COMMA_CON); |
|
5980 |
||
5981 |
GetSystemInfo(&sysInfo); |
|
5982 |
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
|
5983 |
sprintf(vsnBuffer, "%d", sysInfo.dwProcessorType); |
831 | 5984 |
mach = __MKSTRING(vsnBuffer COMMA_CON); |
5985 |
} |
|
5986 |
||
5987 |
# endif /* WIN32 */ |
|
5988 |
#endif /* no uname */ |
|
616 | 5989 |
%}. |
5990 |
sys isNil ifTrue:[ |
|
5991 |
sys := self getSystemType. |
|
5992 |
]. |
|
5993 |
node isNil ifTrue:[ |
|
5994 |
node := self getHostName |
|
5995 |
]. |
|
5996 |
dom isNil ifTrue:[ |
|
5997 |
dom := self getDomainName |
|
5998 |
]. |
|
831 | 5999 |
mach isNil ifTrue:[ |
6000 |
mach := self getCPUType |
|
6001 |
]. |
|
616 | 6002 |
|
6003 |
info := IdentityDictionary new. |
|
6004 |
info at:#system put:sys. |
|
6005 |
info at:#node put:node. |
|
6006 |
rel notNil ifTrue:[info at:#release put:rel]. |
|
6007 |
ver notNil ifTrue:[info at:#version put:ver]. |
|
6008 |
mach notNil ifTrue:[info at:#machine put:mach]. |
|
6009 |
dom notNil ifTrue:[info at:#domain put:dom]. |
|
6010 |
^ info |
|
6011 |
||
6012 |
" |
|
6013 |
OperatingSystem getSystemInfo |
|
6014 |
" |
|
6015 |
! |
|
6016 |
||
6017 |
getSystemType |
|
6018 |
"return a string giving the type of system we're running on. |
|
6019 |
This is almost the same as getOSType, but the returned string |
|
6020 |
is slightly different for some systems (i.e. iris vs. irix). |
|
6021 |
Dont depend on this - use getOSType. I dont really see a point |
|
831 | 6022 |
here ... |
6023 |
(except for slight differences between next/mach and other machs)" |
|
616 | 6024 |
|
6025 |
|sys| |
|
6026 |
||
6027 |
%{ |
|
6028 |
# ifdef NEXT |
|
6029 |
# define SYS_STRING "next" |
|
6030 |
# endif |
|
6031 |
||
6032 |
# ifdef IRIS |
|
6033 |
# define SYS_STRING "iris" |
|
6034 |
# endif |
|
6035 |
||
831 | 6036 |
# ifdef WIN32 |
6037 |
# define SYS_STRING "win32" |
|
6038 |
# endif |
|
6039 |
||
616 | 6040 |
# ifdef SYS_STRING |
830 | 6041 |
sys = __MKSTRING(SYS_STRING COMMA_CON); |
616 | 6042 |
# undef SYS_STRING |
6043 |
# endif |
|
831 | 6044 |
%}. |
616 | 6045 |
sys isNil ifTrue:[ |
6046 |
^ self getOSType |
|
6047 |
]. |
|
6048 |
^ sys |
|
6049 |
||
6050 |
" |
|
6051 |
OperatingSystem getSystemType |
|
6052 |
" |
|
6053 |
! |
|
6054 |
||
6055 |
isBSDlike |
|
6056 |
"return true, if the OS we're running on is a 'real' unix." |
|
6057 |
||
6058 |
%{ /* NOCONTEXT */ |
|
6059 |
||
6060 |
#if defined(BSD) || defined(MACH) || defined(SYSV4) |
|
6061 |
RETURN ( true ); |
|
13 | 6062 |
#endif |
831 | 6063 |
%}. |
13 | 6064 |
^ false |
10 | 6065 |
! |
6066 |
||
616 | 6067 |
isMSDOSlike |
6068 |
"return true, if the OS we're running on is dos like |
|
6069 |
(in contrast to unix-like)." |
|
6070 |
||
6071 |
%{ /* NOCONTEXT */ |
|
6072 |
||
6073 |
#if defined(MSDOS_LIKE) |
|
6074 |
RETURN ( true ); |
|
6075 |
#endif |
|
831 | 6076 |
%}. |
616 | 6077 |
^ false |
6078 |
! |
|
6079 |
||
831 | 6080 |
isMSWINDOWSlike |
6081 |
"return true, if the OS we're running on is MS-Windows like." |
|
6082 |
||
6083 |
%{ /* NOCONTEXT */ |
|
6084 |
||
6085 |
#if defined(WIN32) |
|
6086 |
RETURN ( true ); |
|
6087 |
#endif |
|
6088 |
||
6089 |
%}. |
|
6090 |
^ false |
|
6091 |
! |
|
6092 |
||
6093 |
isOS2like |
|
6094 |
"return true, if the OS we're running on is OS2 like" |
|
6095 |
||
6096 |
%{ /* NOCONTEXT */ |
|
6097 |
||
6098 |
#if defined(OS2) |
|
6099 |
RETURN (true); |
|
6100 |
#endif |
|
6101 |
||
6102 |
%}. |
|
6103 |
^ false |
|
6104 |
! |
|
6105 |
||
1034 | 6106 |
isUNIXlike |
6107 |
"return true, if the OS we're running on is a unix like." |
|
6108 |
||
6109 |
%{ /* NOCONTEXT */ |
|
6110 |
||
6111 |
#if !defined(UNIX_LIKE) |
|
6112 |
RETURN ( false ); |
|
6113 |
#endif |
|
6114 |
%}. |
|
6115 |
^ true |
|
6116 |
! |
|
6117 |
||
616 | 6118 |
maxFileNameLength |
6119 |
"return the max number of characters in a filename. |
|
831 | 6120 |
CAVEAT: |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6121 |
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
|
6122 |
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
|
6123 |
We return a somewhat conservative number here." |
10 | 6124 |
|
6125 |
%{ /* NOCONTEXT */ |
|
616 | 6126 |
|
6127 |
/* |
|
6128 |
* XXX: newer systems provide a query function for this ... use it |
|
6129 |
*/ |
|
6130 |
# if defined(BSD) || defined(SYSV4) || defined(LONGFILENAMES) |
|
831 | 6131 |
RETURN ( __MKSMALLINT(255) ); |
616 | 6132 |
# endif |
6133 |
||
6134 |
# ifdef realIX |
|
831 | 6135 |
RETURN ( __MKSMALLINT(127) ); |
616 | 6136 |
# endif |
6137 |
||
6138 |
# ifdef SYSV |
|
831 | 6139 |
RETURN ( __MKSMALLINT(14) ); |
616 | 6140 |
# endif |
6141 |
||
6142 |
# ifdef MSDOS |
|
831 | 6143 |
RETURN ( __MKSMALLINT(9) ); |
616 | 6144 |
# endif |
6145 |
||
831 | 6146 |
# ifdef WIN32 |
616 | 6147 |
/* |
6148 |
* mhmh - depends on the filesystem type |
|
6149 |
*/ |
|
831 | 6150 |
RETURN ( __MKSMALLINT(9) ); |
616 | 6151 |
# endif |
6152 |
%}. |
|
6153 |
"unix default" |
|
831 | 6154 |
|
616 | 6155 |
^ 14 |
6156 |
! |
|
6157 |
||
1034 | 6158 |
setLocaleInfo:anInfoDictionary |
6159 |
"set the locale information; if set, this oerrides the OS's settings. |
|
6160 |
(internal in ST/X only - the OS's settings remain unaffected) |
|
6161 |
See description of fields in #getLocaleInfo. |
|
6162 |
||
6163 |
Notice, that (for now), the system does not use this information; |
|
6164 |
it should be used by applications as required." |
|
6165 |
||
6166 |
LocaleInfo := anInfoDictionary |
|
6167 |
||
6168 |
" |
|
6169 |
|d| |
|
6170 |
||
6171 |
d := IdentityDictionary new. |
|
6172 |
d at:#decimalPoint put:'.' . |
|
6173 |
d at:#thousandsSeparator put:',' . |
|
6174 |
d at:#currencySymbol put:'USD' . |
|
6175 |
d at:#monetaryDecimalPoint put:'.' . |
|
6176 |
d at:#monetaryThousandsSeparator put:'.' . |
|
6177 |
d at:#fractionalDigits put:2 . |
|
6178 |
d at:#positiveSign put:'+' . |
|
6179 |
d at:#negativeSign put:'-' . |
|
6180 |
d at:#positiveSignPrecedesCurrencySymbol put:true . |
|
6181 |
d at:#negativeSignPrecedesCurrencySymbol put:false . |
|
6182 |
OperatingSystem setLocaleInfo:d |
|
6183 |
" |
|
6184 |
! |
|
6185 |
||
616 | 6186 |
supportsIOInterrupts |
6187 |
"return true, if the OS supports IO availability interrupts |
|
6188 |
(i.e. SIGPOLL/SIGIO). |
|
6189 |
||
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6190 |
Currently, this mechanism does work for SYSV4 only ..." |
616 | 6191 |
|
6192 |
%{ /* NOCONTEXT */ |
|
1062
baa5827a7a40
Do not transparently restart system calls after a (Unix-)signal.
Stefan Vogel <sv@exept.de>
parents:
1060
diff
changeset
|
6193 |
#if defined(SYSV4) && defined(USE_SIGIO) && 0 |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6194 |
|
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6195 |
# if defined(SIGPOLL) || defined(SIGIO) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6196 |
# 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
|
6197 |
/* |
765
93bdb4f0e095
no, SIGIO does not work on SGI ...
Claus Gittinger <cg@exept.de>
parents:
764
diff
changeset
|
6198 |
* 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
|
6199 |
* (not even on SGI ...) |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6200 |
*/ |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6201 |
# if !defined(NEXT) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6202 |
RETURN (true); |
616 | 6203 |
# endif |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6204 |
# endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6205 |
# endif |
616 | 6206 |
|
10 | 6207 |
#endif |
831 | 6208 |
%}. |
13 | 6209 |
^ false |
123 | 6210 |
! |
6211 |
||
616 | 6212 |
supportsNonBlockingIO |
6213 |
"return true, if the OS supports nonblocking IO." |
|
6214 |
||
6215 |
%{ /* NOCONTEXT */ |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6216 |
#if defined(F_GETFL) && defined(F_SETFL) && defined(FNDELAY) |
616 | 6217 |
RETURN (true); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
6218 |
#endif |
831 | 6219 |
%}. |
616 | 6220 |
^ false |
123 | 6221 |
! |
6222 |
||
616 | 6223 |
supportsSelect |
6224 |
"return true, if the OS supports selecting on multiple |
|
6225 |
filedescriptors via select." |
|
6226 |
||
6227 |
%{ /* NOCONTEXT */ |
|
831 | 6228 |
#if defined(WIN32) |
6229 |
RETURN (false); |
|
6230 |
#endif |
|
616 | 6231 |
#if defined(sco) |
6232 |
/* |
|
831 | 6233 |
* sco has a select, but its broken: always waiting 1 second |
616 | 6234 |
*/ |
6235 |
RETURN(false); |
|
6236 |
#endif |
|
6237 |
%} |
|
6238 |
. |
|
6239 |
^ true |
|
6240 |
! ! |
|
6241 |
||
1497 | 6242 |
!OperatingSystem class methodsFor:'shared memory access'! |
616 | 6243 |
|
6244 |
shmAttach:id address:addr flags:flags |
|
1247 | 6245 |
"low level entry to shmat()-system call. |
6246 |
Not supported on all operatingSystems" |
|
6247 |
||
616 | 6248 |
%{ /* NOCONTEXT */ |
6249 |
#ifdef WANT_SHM |
|
6250 |
void *address, *shmaddr; |
|
6251 |
int shmflg, shmid; |
|
6252 |
||
6253 |
if (__isSmallInteger(addr) |
|
6254 |
&& __bothSmallInteger(flags, id)) { |
|
1487 | 6255 |
shmaddr = (void *) __intVal(addr); |
6256 |
shmflg = __intVal(flags); |
|
6257 |
shmid = __intVal(id); |
|
6258 |
||
6259 |
address = shmat(shmid, shmaddr, shmflg); |
|
6260 |
if (address != (void *)-1) { |
|
6261 |
RETURN (__MKEXTERNALBYTES(addr)); |
|
6262 |
} |
|
6263 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
|
6264 |
RETURN (nil); |
|
616 | 6265 |
} |
6266 |
#endif |
|
6267 |
%}. |
|
792 | 6268 |
^ self primitiveFailed |
1247 | 6269 |
|
6270 |
"Modified: 22.4.1996 / 13:15:12 / cg" |
|
370 | 6271 |
! |
6272 |
||
616 | 6273 |
shmDetach:addr |
1247 | 6274 |
"low level entry to shmdt()-system call. |
6275 |
Not supported on all operatingSystems" |
|
6276 |
||
616 | 6277 |
%{ /* NOCONTEXT */ |
6278 |
#ifdef WANT_SHM |
|
6279 |
void *shmaddr; |
|
6280 |
int rslt; |
|
6281 |
||
6282 |
if (__isSmallInteger(addr)) { |
|
1487 | 6283 |
shmaddr = (void *) __intVal(addr); |
6284 |
||
6285 |
rslt = shmdt(shmaddr); |
|
6286 |
if (rslt != -1) { |
|
6287 |
RETURN (true); |
|
6288 |
} |
|
6289 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
|
6290 |
RETURN (false); |
|
370 | 6291 |
} |
616 | 6292 |
#endif |
6293 |
%}. |
|
792 | 6294 |
^ self primitiveFailed |
1247 | 6295 |
|
6296 |
"Modified: 22.4.1996 / 13:15:03 / cg" |
|
616 | 6297 |
! |
6298 |
||
6299 |
shmGet:key size:size flags:flags |
|
1247 | 6300 |
"low level entry to shmget()-system call. |
6301 |
This is not for public use and not supported with all operatingSystems. |
|
616 | 6302 |
- use the provided wrapper class SharedExternalBytes instead." |
6303 |
||
6304 |
%{ /* NOCONTEXT */ |
|
6305 |
#ifdef WANT_SHM |
|
6306 |
if (__bothSmallInteger(key, size) |
|
6307 |
&& __isSmallInteger(flags)) { |
|
1487 | 6308 |
int rslt; |
6309 |
||
6310 |
rslt = shmget(__intVal(key), __intVal(size), __intVal(flags)); |
|
6311 |
if (rslt != -1) { |
|
6312 |
RETURN (__MKSMALLINT(rslt)); |
|
6313 |
} |
|
6314 |
OperatingSystem_LastErrorNumber = __MKSMALLINT(errno); |
|
6315 |
RETURN (nil); |
|
616 | 6316 |
} |
6317 |
#endif |
|
370 | 6318 |
%}. |
792 | 6319 |
^ self primitiveFailed |
1247 | 6320 |
|
6321 |
"Modified: 22.4.1996 / 13:14:46 / cg" |
|
1 | 6322 |
! ! |
6323 |
||
1497 | 6324 |
!OperatingSystem class methodsFor:'time and date'! |
1 | 6325 |
|
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6326 |
computeDatePartsOf:osTime for:aBlock |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6327 |
"compute year, month and day from the OS time, osTime |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6328 |
and evaluate the argument, a 3-arg block with these. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6329 |
Conversion is to localtime including any daylight saving adjustments." |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6330 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6331 |
|year month day osSeconds| |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6332 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6333 |
osSeconds := osTime // 1000. |
1 | 6334 |
%{ |
6335 |
struct tm *tmPtr; |
|
6336 |
long t; |
|
6337 |
||
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6338 |
t = __longIntVal(osSeconds); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6339 |
|
1 | 6340 |
tmPtr = localtime(&t); |
1135 | 6341 |
year = __MKSMALLINT(tmPtr->tm_year + 1900); |
6342 |
month = __MKSMALLINT(tmPtr->tm_mon + 1); |
|
6343 |
day = __MKSMALLINT(tmPtr->tm_mday); |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6344 |
%}. |
1 | 6345 |
aBlock value:year value:month value:day |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6346 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6347 |
" |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6348 |
OperatingSystem computeDatePartsOf:0 for:[:y :m :d | |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6349 |
y printCR. m printCR. d printCR |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6350 |
] |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6351 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6352 |
! |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6353 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6354 |
computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millis:millis |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6355 |
"return the OS-dependent time for the given time and day. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6356 |
The arguments are assumed to be in localtime including |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6357 |
any daylight saving adjustings." |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6358 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6359 |
|osSeconds| |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6360 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6361 |
%{ |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6362 |
struct tm tm; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6363 |
long t; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6364 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6365 |
if (__bothSmallInteger(y, m) |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6366 |
&& __bothSmallInteger(d, h) |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6367 |
&& __bothSmallInteger(min, s)) { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6368 |
tm.tm_hour = __intVal(h); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6369 |
tm.tm_min = __intVal(min); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6370 |
tm.tm_sec = __intVal(s); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6371 |
|
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6372 |
tm.tm_year = __intVal(y) - 1900; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6373 |
tm.tm_mon = __intVal(m) - 1; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6374 |
tm.tm_mday = __intVal(d); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6375 |
tm.tm_isdst = -1; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6376 |
|
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6377 |
t = mktime(&tm); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6378 |
osSeconds = __MKUINT(t); |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6379 |
} |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6380 |
%}. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6381 |
osSeconds notNil ifTrue:[ |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6382 |
^ osSeconds * 1000 + millis |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6383 |
]. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6384 |
^ self primitiveFailed |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6385 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6386 |
" |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6387 |
OperatingSystem computeOSTimeFromYear:1970 month:1 day:1 hour:0 minute:0 seconds:0 millis:0 |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6388 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6389 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6390 |
! |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6391 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6392 |
computeTimeAndDateFrom:osTime |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6393 |
"given an OS-dependent time in osTime, return an Array |
1511
823fcfbbb741
weekDay/yearDay start with0 in tm_ struct, but
Claus Gittinger <cg@exept.de>
parents:
1510
diff
changeset
|
6394 |
containing (full-) year, month, day, hour, minute and seconds, |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6395 |
offset to UTC, daylight savings time flag, milliseconds, |
1511
823fcfbbb741
weekDay/yearDay start with0 in tm_ struct, but
Claus Gittinger <cg@exept.de>
parents:
1510
diff
changeset
|
6396 |
dayInYear (1..) and dayInWeek (1..). |
616 | 6397 |
Conversion is to localtime including any daylight saving adjustments." |
6398 |
||
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6399 |
|low hi year month day hours minutes seconds millis utcOffset |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6400 |
dst yDay wDay osSeconds ret| |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6401 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6402 |
millis := osTime \\ 1000. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6403 |
osSeconds := osTime // 1000. |
63 | 6404 |
%{ |
6405 |
struct tm *tmPtr; |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6406 |
struct tm *gmTmPtr; |
63 | 6407 |
long t; |
6408 |
||
1441 | 6409 |
#if defined(ultrix) || defined(sunos) /* mhmh - isnt this ifdef BSD ? */ |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6410 |
# define TIMEZONE tmPtr->tm_gmtoff |
811 | 6411 |
#else |
831 | 6412 |
# ifdef MSDOS_LIKE |
1487 | 6413 |
# define TIMEZONE 0 |
831 | 6414 |
# else |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6415 |
# define TIMEZONE timezone |
831 | 6416 |
# endif |
811 | 6417 |
#endif |
6418 |
||
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6419 |
t = __longIntVal(osSeconds); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6420 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6421 |
tmPtr = localtime(&t); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6422 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6423 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6424 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6425 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6426 |
year = __MKSMALLINT(tmPtr->tm_year + 1900); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6427 |
month = __MKSMALLINT(tmPtr->tm_mon + 1); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6428 |
day = __MKSMALLINT(tmPtr->tm_mday); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6429 |
|
1511
823fcfbbb741
weekDay/yearDay start with0 in tm_ struct, but
Claus Gittinger <cg@exept.de>
parents:
1510
diff
changeset
|
6430 |
yDay = __MKSMALLINT(tmPtr->tm_yday+1); |
1512
d4e6376dce78
weekDay fix (sunday is 0 in tm_wday)
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
6431 |
wDay = __MKSMALLINT(tmPtr->tm_wday == 0 ? 7 : tmPtr->tm_wday); |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6432 |
|
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6433 |
if (tmPtr->tm_isdst == 0) { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6434 |
dst = false; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6435 |
utcOffset = __MKSMALLINT(TIMEZONE); |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6436 |
} else { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6437 |
dst = true; |
800
067094efdaed
use HAS_ALTZONE / HAS_DAYLIGHT
Claus Gittinger <cg@exept.de>
parents:
798
diff
changeset
|
6438 |
#ifdef HAS_ALTZONE |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6439 |
utcOffset = __MKSMALLINT(altzone); |
800
067094efdaed
use HAS_ALTZONE / HAS_DAYLIGHT
Claus Gittinger <cg@exept.de>
parents:
798
diff
changeset
|
6440 |
#else |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6441 |
utcOffset = __MKSMALLINT(TIMEZONE) + 3600; |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6442 |
#endif |
63 | 6443 |
} |
241 | 6444 |
%}. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6445 |
"I would love to have SELF-like inline objects ..." |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6446 |
ret := Array new:11. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6447 |
ret at:1 put:year. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6448 |
ret at:2 put:month. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6449 |
ret at:3 put:day. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6450 |
ret at:4 put:hours. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6451 |
ret at:5 put:minutes. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6452 |
ret at:6 put:seconds. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6453 |
ret at:7 put:utcOffset. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6454 |
ret at:8 put:dst. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6455 |
ret at:9 put:millis. |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6456 |
ret at:10 put:yDay. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6457 |
ret at:11 put:wDay. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6458 |
^ ret |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6459 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6460 |
" |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6461 |
OperatingSystem computeTimeAndDateFrom:0 |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6462 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6463 |
! |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6464 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6465 |
computeTimePartsOf:osTime for:aBlock |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6466 |
"compute hours, minutes, seconds and milliseconds from the osTime |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6467 |
and evaluate the argument, a 4-arg block with these. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6468 |
Conversion is to localtime including any daylight saving adjustments." |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6469 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6470 |
|hours minutes seconds millis osSeconds| |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6471 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6472 |
osSeconds := osTime // 1000. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6473 |
millis := osTime \\ 1000. |
616 | 6474 |
%{ |
6475 |
struct tm *tmPtr; |
|
6476 |
long t; |
|
6477 |
||
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6478 |
t = __longIntVal(osSeconds); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6479 |
|
616 | 6480 |
tmPtr = localtime(&t); |
1135 | 6481 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
6482 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
|
6483 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6484 |
%}. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6485 |
aBlock value:hours value:minutes value:seconds value:millis |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6486 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6487 |
" |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6488 |
OperatingSystem computeTimePartsOf:100 for:[:h :m :s :milli | |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6489 |
h printCR. m printCR. s printCR. millis printCR |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6490 |
] |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6491 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6492 |
! |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6493 |
|
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6494 |
computeUTCTimeAndDateFrom:osTime |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6495 |
"given an OS-dependent time in osTime, return an Array |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6496 |
containing year, month, day, hour, minute and seconds, |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6497 |
offset to UTC, daylight savings time flag, milliseconds, |
1511
823fcfbbb741
weekDay/yearDay start with0 in tm_ struct, but
Claus Gittinger <cg@exept.de>
parents:
1510
diff
changeset
|
6498 |
dayInYear (1..) and dayInWeek (1..). |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6499 |
Conversion is to UTC." |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6500 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6501 |
|low hi year month day hours minutes seconds millis utcOffset |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6502 |
dst yDay wDay osSeconds ret| |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6503 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6504 |
millis := osTime \\ 1000. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6505 |
osSeconds := osTime // 1000. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6506 |
%{ |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6507 |
struct tm *tmPtr; |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6508 |
struct tm *gmTmPtr; |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6509 |
long t; |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6510 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6511 |
#if defined(ultrix) || defined(sunos) /* mhmh - isnt this ifdef BSD ? */ |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6512 |
# define TIMEZONE tmPtr->tm_gmtoff |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6513 |
#else |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6514 |
# ifdef MSDOS_LIKE |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6515 |
# define TIMEZONE 0 |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6516 |
# else |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6517 |
# define TIMEZONE timezone |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6518 |
# endif |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6519 |
#endif |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6520 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6521 |
t = __longIntVal(osSeconds); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6522 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6523 |
tmPtr = gmtime(&t); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6524 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6525 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6526 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6527 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6528 |
year = __MKSMALLINT(tmPtr->tm_year + 1900); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6529 |
month = __MKSMALLINT(tmPtr->tm_mon + 1); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6530 |
day = __MKSMALLINT(tmPtr->tm_mday); |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6531 |
|
1511
823fcfbbb741
weekDay/yearDay start with0 in tm_ struct, but
Claus Gittinger <cg@exept.de>
parents:
1510
diff
changeset
|
6532 |
yDay = __MKSMALLINT(tmPtr->tm_yday + 1); |
1512
d4e6376dce78
weekDay fix (sunday is 0 in tm_wday)
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
6533 |
wDay = __MKSMALLINT(tmPtr->tm_wday == 0 ? 7 : tmPtr->tm_wday); |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6534 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6535 |
if (tmPtr->tm_isdst == 0) { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6536 |
dst = false; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6537 |
utcOffset = __MKSMALLINT(TIMEZONE); |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6538 |
} else { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6539 |
dst = true; |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6540 |
#ifdef HAS_ALTZONE |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6541 |
utcOffset = __MKSMALLINT(altzone); |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6542 |
#else |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6543 |
utcOffset = __MKSMALLINT(TIMEZONE) + 3600; |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6544 |
#endif |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6545 |
} |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6546 |
%}. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6547 |
"I would love to have SELF-like inline objects ..." |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6548 |
ret := Array new:11. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6549 |
ret at:1 put:year. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6550 |
ret at:2 put:month. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6551 |
ret at:3 put:day. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6552 |
ret at:4 put:hours. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6553 |
ret at:5 put:minutes. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6554 |
ret at:6 put:seconds. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6555 |
ret at:7 put:utcOffset. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6556 |
ret at:8 put:dst. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6557 |
ret at:9 put:millis. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6558 |
ret at:10 put:yDay. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6559 |
ret at:11 put:wDay. |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6560 |
^ ret |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6561 |
|
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6562 |
" |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6563 |
OperatingSystem computeUTCTimeAndDateFrom:0 |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6564 |
" |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6565 |
! |
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6566 |
|
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6567 |
computeUTCTimePartsOf:osTime for:aBlock |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6568 |
"compute hours, minutes, seconds and milliseconds from the osTime |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6569 |
and evaluate the argument, a 4-arg block with these. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6570 |
Conversion is to UTC." |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6571 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6572 |
|hours minutes seconds millis osSeconds| |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6573 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6574 |
osSeconds := osTime // 1000. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6575 |
millis := osTime \\ 1000. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6576 |
%{ |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6577 |
struct tm *tmPtr; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6578 |
long t; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6579 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6580 |
t = __longIntVal(osSeconds); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6581 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6582 |
tmPtr = gmtime(&t); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6583 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6584 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6585 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6586 |
%}. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6587 |
aBlock value:hours value:minutes value:seconds value:millis |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6588 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6589 |
" |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6590 |
OperatingSystem computeUTCTimePartsOf:100 for:[:h :m :s :milli | |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6591 |
h printCR. m printCR. s printCR. milli printCR |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6592 |
] |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6593 |
" |
275 | 6594 |
! |
6595 |
||
1 | 6596 |
getMillisecondTime |
185 | 6597 |
"This returns the millisecond timers value. |
6598 |
The range is limited to 0..1fffffff (i.e. the SmallInteger range) to avoid |
|
6599 |
LargeInteger arithmetic when doing timeouts and delays. |
|
792 | 6600 |
Since this value is wrapping around in regular intervals, this can only be used for |
185 | 6601 |
short relative time deltas. |
6602 |
Use the millisecondTimeXXX:-methods to compare and add time deltas - these know about the wrap. |
|
6603 |
||
6604 |
BAD DESIGN: |
|
6605 |
This should be changed to return some instance of RelativeTime, |
|
6606 |
and these computations moved there. |
|
95 | 6607 |
|
6608 |
Dont use this method in application code since it is an internal (private) |
|
6609 |
interface. For compatibility with ST-80, use Time millisecondClockValue. |
|
6610 |
" |
|
1 | 6611 |
|
6612 |
%{ /* NOCONTEXT */ |
|
6613 |
||
6614 |
long t; |
|
185 | 6615 |
#if !defined(HAS_GETTIMEOFDAY) && defined(SYSV) && defined(HZ) |
6616 |
/* |
|
6617 |
* sys5 time |
|
6618 |
*/ |
|
1 | 6619 |
long ticks; |
6620 |
struct tms tb; |
|
6621 |
||
6622 |
ticks = times(&tb); |
|
6623 |
t = (ticks * 1000) / HZ; |
|
792 | 6624 |
#else |
6625 |
# ifdef MSDOS_LIKE |
|
6626 |
struct _timeb timebuffer; |
|
6627 |
||
6628 |
_ftime(&timebuffer); |
|
6629 |
t = (timebuffer.time * 1000) + timebuffer.millitm; |
|
6630 |
# else /* assume HAS_GETTIMEOFDAY */ |
|
185 | 6631 |
/* |
6632 |
* bsd time |
|
6633 |
*/ |
|
1 | 6634 |
struct timeval tb; |
6635 |
struct timezone tzb; |
|
6636 |
||
6637 |
gettimeofday(&tb, &tzb); |
|
6638 |
t = tb.tv_sec*1000 + tb.tv_usec/1000; |
|
792 | 6639 |
# endif |
68 | 6640 |
#endif |
1135 | 6641 |
RETURN ( __MKSMALLINT(t & 0x1FFFFFFF) ); |
1 | 6642 |
%} |
6643 |
! |
|
6644 |
||
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6645 |
getOSTime |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6646 |
"This returns the millisecond OS time. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6647 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6648 |
Dont use this method in application code since it is an internal (private) |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6649 |
interface. For compatibility with ST-80, use Time>>millisecondClockValue. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6650 |
or use instances of Time, Date or AbsoluteTime to work with. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6651 |
" |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6652 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6653 |
|seconds millis| |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6654 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6655 |
%{ |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6656 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6657 |
long t; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6658 |
#if !defined(HAS_GETTIMEOFDAY) && defined(SYSV) && defined(HZ) |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6659 |
/* |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6660 |
* sys5 time we have to fake the information |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6661 |
* the returned value inexact. |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6662 |
*/ |
616 | 6663 |
int now; |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6664 |
long ticks; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6665 |
struct tms tb; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6666 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6667 |
now = time(0); /* seconds since 1970 ... */ |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6668 |
seconds = __MKUINT(now); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6669 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6670 |
ticks = times(&tb); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6671 |
t = (ticks * 1000) / HZ; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6672 |
t = t % 1000; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6673 |
millis = __MKSMALLINT(t); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6674 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6675 |
#else |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6676 |
# ifdef MSDOS_LIKE |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6677 |
struct _timeb timebuffer; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6678 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6679 |
_ftime(&timebuffer); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6680 |
seconds = __MKUINT(timebuffer.time); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6681 |
millis = __MKSMALLINT(timebuffer.millitm); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6682 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6683 |
# else /* assume HAS_GETTIMEOFDAY */ |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6684 |
/* |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6685 |
* bsd time |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6686 |
*/ |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6687 |
struct timeval tb; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6688 |
struct timezone tzb; |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6689 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6690 |
gettimeofday(&tb, &tzb); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6691 |
seconds = __MKUINT(tb.tv_sec); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6692 |
millis = __MKSMALLINT(tb.tv_usec / 1000); |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6693 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6694 |
# endif |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6695 |
#endif |
831 | 6696 |
%}. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6697 |
^ (seconds * 1000) + millis |
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6698 |
|
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6699 |
" |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6700 |
OperatingSystem getOSTime printCR. |
1499
0df07e1d0c2f
osTime is now a largeInteger, which includes the milliseconds.
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
6701 |
Delay waitForSeconds:0.2. |
1510
d7987cc00dc4
added interface for UTC timeAndDate handling;
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
6702 |
OperatingSystem getOSTime printCR. |
831 | 6703 |
" |
616 | 6704 |
! |
6705 |
||
6706 |
maximumMillisecondTimeDelta |
|
6707 |
"this returns the maximum delta supported by millisecondCounter |
|
6708 |
based methods. The returned value is half the value at which the |
|
6709 |
timer wraps." |
|
6710 |
||
6711 |
%{ /* NOCONTEXT */ |
|
1135 | 6712 |
RETURN ( __MKSMALLINT(0x0FFFFFFF) ); |
616 | 6713 |
%} |
6714 |
! |
|
6715 |
||
6716 |
millisecondDelay:millis |
|
6717 |
"delay execution for millis milliseconds or until the next event |
|
6718 |
arrives. |
|
6719 |
All lower priority threads will also sleep for the duration, |
|
6720 |
interrupts (and therefore, higher prio processes) are |
|
6721 |
still handled. |
|
6722 |
Better use a Delay, to only delay the calling thread. |
|
6723 |
(however, a delay cannot be used in the event handler or scheduler)" |
|
6724 |
||
6725 |
|now then delta| |
|
6726 |
||
831 | 6727 |
%{ /* NOCONTEXT */ |
6728 |
#ifdef WIN32 |
|
6729 |
int t = __intVal(millis); |
|
6730 |
||
6731 |
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
|
6732 |
Sleep(t); |
831 | 6733 |
} |
6734 |
RETURN (self); |
|
6735 |
#endif |
|
6736 |
%}. |
|
6737 |
||
616 | 6738 |
now := OperatingSystem getMillisecondTime. |
6739 |
then := OperatingSystem millisecondTimeAdd:now and:millis. |
|
6740 |
||
6741 |
[OperatingSystem millisecondTime:then isAfter:now] whileTrue:[ |
|
6742 |
delta := OperatingSystem millisecondTimeDeltaBetween:then and:now. |
|
6743 |
self selectOnAnyReadable:nil writable:nil exception:nil withTimeOut:delta. |
|
6744 |
now := OperatingSystem getMillisecondTime. |
|
6745 |
] |
|
6746 |
||
6747 |
" |
|
6748 |
OperatingSystem millisecondDelay:2000 |
|
6749 |
" |
|
6750 |
! |
|
6751 |
||
6752 |
millisecondTime:msTime1 isAfter:msTime2 |
|
6753 |
"return true if msTime1 is after msTime2, false if not. |
|
6754 |
The two arguments are supposed to be millisecond times |
|
6755 |
(such as returned getMillisecondTime) which wrap at 16r1FFFFFFF. |
|
6756 |
||
6757 |
This should really be moved to some RelativeTime class." |
|
6758 |
||
6759 |
(msTime1 > msTime2) ifTrue:[ |
|
6760 |
((msTime1 - msTime2) >= 16r10000000) ifTrue:[ |
|
6761 |
^ false |
|
6762 |
]. |
|
6763 |
^ true |
|
6764 |
]. |
|
6765 |
((msTime2 - msTime1) > 16r10000000) ifTrue:[ |
|
6766 |
^ true |
|
6767 |
]. |
|
6768 |
^ false |
|
6769 |
! |
|
6770 |
||
6771 |
millisecondTimeAdd:msTime1 and:msTime2 |
|
6772 |
"Add two millisecond times (such as returned getMillisecondTime). |
|
6773 |
The returned value is msTime1 + msTime2 where a wrap occurs at:16r1FFFFFFF. |
|
6774 |
||
6775 |
This should really be moved to some RelativeTime class." |
|
6776 |
||
6777 |
|sum| |
|
6778 |
||
6779 |
sum := msTime1 + msTime2. |
|
6780 |
(sum > 16r1FFFFFFF) ifTrue:[^ sum - 16r20000000]. |
|
6781 |
(sum < 0) ifTrue:[^ sum + 16r20000000]. |
|
6782 |
^ sum |
|
6783 |
! |
|
6784 |
||
1 | 6785 |
millisecondTimeDeltaBetween:msTime1 and:msTime2 |
95 | 6786 |
"subtract two millisecond times (such as returned getMillisecondTime) |
185 | 6787 |
and return the difference. Since milli-times wrap (at 16r01FFFFFFF), |
95 | 6788 |
some special handling is built-in here. |
185 | 6789 |
The returned value is msTime1 - msTime2. The returned value is invalid |
6790 |
if the delta is >= 0x10000000. |
|
63 | 6791 |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
6792 |
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
|
6793 |
better yet: create a subclass of Integer named LimitedRangeInteger." |
1 | 6794 |
|
6795 |
(msTime1 > msTime2) ifTrue:[ |
|
185 | 6796 |
^ msTime1 - msTime2 |
1 | 6797 |
]. |
6798 |
^ msTime1 + 16r10000000 - msTime2 |
|
95 | 6799 |
|
6800 |
" |
|
6801 |
OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:1 |
|
6802 |
OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:(16 / 3) |
|
6803 |
OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:1000 |
|
6804 |
||
6805 |
OperatingSystem millisecondTimeDeltaBetween:0 and:16r0FFFFFFF |
|
6806 |
OperatingSystem millisecondTimeDeltaBetween:(13/3) and:16r0FFFFFFF |
|
6807 |
OperatingSystem millisecondTimeDeltaBetween:999 and:16r0FFFFFFF |
|
6808 |
||
6809 |
OperatingSystem millisecondTime:0 isAfter:16r0FFFFFFF |
|
6810 |
OperatingSystem millisecondTime:(13/3) isAfter:16r0FFFFFFF |
|
6811 |
OperatingSystem millisecondTime:999 isAfter:16r0FFFFFFF |
|
6812 |
||
6813 |
OperatingSystem millisecondTime:0 isAfter:0 |
|
6814 |
OperatingSystem millisecondTime:(13/3) isAfter:0 |
|
6815 |
OperatingSystem millisecondTime:999 isAfter:0 |
|
6816 |
||
6817 |
OperatingSystem millisecondTime:1 isAfter:0 |
|
6818 |
OperatingSystem millisecondTime:(13/3) isAfter:2 |
|
6819 |
OperatingSystem millisecondTime:999 isAfter:900 |
|
6820 |
||
6821 |
|t1 t2| |
|
6822 |
||
6823 |
t1 := Time millisecondClockValue. |
|
6824 |
(Delay forMilliseconds:1) wait. |
|
6825 |
t2 := Time millisecondClockValue. |
|
6826 |
OperatingSystem millisecondTimeDeltaBetween:t2 and:t1 |
|
6827 |
" |
|
1 | 6828 |
! |
6829 |
||
6830 |
sleep:numberOfSeconds |
|
308 | 6831 |
"cease ANY action for some time. This suspends the whole smalltalk |
6832 |
(unix-) process for some time. |
|
1 | 6833 |
Not really useful since not even low-prio processes and interrupt |
95 | 6834 |
handling will run during the sleep. |
6835 |
Use either OperatingSystem>>millisecondDelay: (which makes all |
|
6836 |
threads sleep, but handles interrupts) or use a Delay (which makes |
|
6837 |
only the calling thread sleep)." |
|
1 | 6838 |
|
6839 |
%{ /* NOCONTEXT */ |
|
6840 |
||
252 | 6841 |
if (__isSmallInteger(numberOfSeconds)) { |
1135 | 6842 |
sleep(__intVal(numberOfSeconds)); |
185 | 6843 |
RETURN ( self ); |
1 | 6844 |
} |
68 | 6845 |
%}. |
6846 |
" |
|
6847 |
argument not integer |
|
6848 |
" |
|
792 | 6849 |
^ self primitiveFailed |
95 | 6850 |
|
6851 |
" |
|
6852 |
OperatingSystem sleep:2 |
|
6853 |
" |
|
10 | 6854 |
! ! |
6855 |
||
1497 | 6856 |
!OperatingSystem class methodsFor:'users & groups'! |
616 | 6857 |
|
6858 |
getEffectiveGroupID |
|
6859 |
"return the current users (thats you) effective numeric group id. |
|
6860 |
This is only different from getGroupID, if you have ST/X running |
|
6861 |
as a setuid program (of which you should think about twice)." |
|
6862 |
||
6863 |
%{ /* NOCONTEXT */ |
|
6864 |
||
6865 |
#ifdef UNIX_LIKE |
|
6866 |
int uid; |
|
6867 |
||
6868 |
uid = getegid(); |
|
6869 |
RETURN ( __MKSMALLINT(uid) ); |
|
6870 |
#endif |
|
6871 |
/* --- return same as getGroupID --- */ |
|
6872 |
%}. |
|
6873 |
^ self getGroupID |
|
6874 |
||
6875 |
" |
|
6876 |
OperatingSystem getEffectiveGroupID |
|
6877 |
" |
|
6878 |
! |
|
6879 |
||
6880 |
getEffectiveUserID |
|
6881 |
"return the current users (thats you) effective numeric user id. |
|
6882 |
This is only different from getUserID, if you have ST/X running |
|
6883 |
as a setuid program (of which you should think about twice)." |
|
10 | 6884 |
|
6885 |
%{ /* NOCONTEXT */ |
|
6886 |
||
616 | 6887 |
#ifdef UNIX_LIKE |
6888 |
int uid; |
|
6889 |
||
6890 |
uid = geteuid(); |
|
6891 |
RETURN ( __MKSMALLINT(uid) ); |
|
6892 |
#endif |
|
6893 |
/* --- return same as getUserID --- */ |
|
6894 |
%}. |
|
6895 |
^ self getUserID |
|
6896 |
||
6897 |
" |
|
6898 |
OperatingSystem getEffectiveUserID |
|
6899 |
" |
|
6900 |
! |
|
6901 |
||
1549
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
6902 |
getFullUserNameFromID:userID |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
6903 |
"return a string with the users full name - if available. |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
6904 |
If not, return the login name as a fallBack." |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
6905 |
|
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
6906 |
|info gecos| |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
6907 |
|
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
6908 |
info := self userInfoOf:userID. |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
6909 |
(info notNil |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
6910 |
and:[info includesKey:#gecos]) ifTrue:[ |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6911 |
gecos := info at:#gecos. |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6912 |
(gecos includes:$,) ifTrue:[ |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6913 |
^ gecos copyTo:(gecos indexOf:$,) - 1 |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6914 |
]. |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6915 |
^ gecos |
1549
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
6916 |
]. |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
6917 |
^ self getUserNameFromID:userID |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
6918 |
|
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
6919 |
" |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
6920 |
OperatingSystem getFullUserNameFromID:0 |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
6921 |
OperatingSystem getFullUserNameFromID:(OperatingSystem getUserID) |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
6922 |
|
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
6923 |
OperatingSystem getUserNameFromID:(OperatingSystem getUserID) |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
6924 |
" |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
6925 |
|
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
6926 |
"Modified: 15.7.1996 / 12:44:21 / cg" |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
6927 |
! |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
6928 |
|
616 | 6929 |
getGroupID |
6930 |
"return the current users (thats you) numeric group id" |
|
6931 |
||
6932 |
%{ /* NOCONTEXT */ |
|
6933 |
||
6934 |
#ifdef UNIX_LIKE |
|
6935 |
int uid; |
|
6936 |
||
6937 |
uid = getgid(); |
|
6938 |
RETURN ( __MKSMALLINT(uid) ); |
|
6939 |
#else |
|
6940 |
# ifdef SYSTEM_HAS_GROUPS |
|
6941 |
/* ... */ |
|
10 | 6942 |
# endif |
6943 |
#endif |
|
68 | 6944 |
%}. |
616 | 6945 |
^ 1 "just a dummy for systems which do not have userIDs" |
6946 |
||
68 | 6947 |
" |
616 | 6948 |
OperatingSystem getGroupID |
6949 |
" |
|
6950 |
! |
|
6951 |
||
6952 |
getGroupNameFromID:aNumber |
|
6953 |
"return the group-name-string for a given numeric group-id" |
|
6954 |
||
6955 |
%{ /* NOCONTEXT */ |
|
6956 |
||
6957 |
#ifdef UNIX_LIKE |
|
6958 |
struct group *g; |
|
6959 |
||
6960 |
if (__isSmallInteger(aNumber)) { |
|
1135 | 6961 |
g = getgrgid(__intVal(aNumber)); |
616 | 6962 |
if (g) { |
830 | 6963 |
RETURN ( __MKSTRING(g->gr_name COMMA_CON) ); |
616 | 6964 |
} |
6965 |
} |
|
6966 |
#endif |
|
6967 |
%}. |
|
6968 |
^ '???' |
|
6969 |
||
6970 |
" |
|
6971 |
OperatingSystem getGroupNameFromID:0 |
|
6972 |
OperatingSystem getGroupNameFromID:10 |
|
6973 |
" |
|
6974 |
! |
|
6975 |
||
6976 |
getHomeDirectory |
|
6977 |
"return the name of the users home directory" |
|
6978 |
||
6979 |
^ OperatingSystem getEnvironment:'HOME' |
|
6980 |
||
6981 |
" |
|
6982 |
OperatingSystem getHomeDirectory |
|
6983 |
" |
|
6984 |
! |
|
6985 |
||
6986 |
getLoginName |
|
1549
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
6987 |
"return a string with the users login name" |
616 | 6988 |
|
6989 |
%{ /* NOCONTEXT */ |
|
6990 |
static char cachedName[64]; |
|
6991 |
static firstCall = 1; |
|
6992 |
||
831 | 6993 |
char *name = (char *)0; |
616 | 6994 |
#ifdef UNIX_LIKE |
6995 |
if (firstCall) { |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6996 |
name = (char *)getlogin(); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6997 |
if (! name || (name[0] == 0)) { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6998 |
name = (char *)getenv("LOGNAME"); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
6999 |
} |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7000 |
if (name && (strlen(name) < sizeof(cachedName))) { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7001 |
strcpy(cachedName, name); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7002 |
firstCall = 0; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7003 |
} |
616 | 7004 |
} else { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7005 |
name = cachedName; |
616 | 7006 |
} |
831 | 7007 |
#else |
7008 |
# ifdef MSDOS_LIKE |
|
7009 |
if (firstCall) { |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7010 |
int nameSize = sizeof(cachedName); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7011 |
|
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7012 |
if (GetUserName(cachedName, &nameSize) == TRUE) { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7013 |
name = cachedName; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7014 |
firstCall = 0; |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7015 |
} |
831 | 7016 |
} else { |
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7017 |
name = cachedName; |
831 | 7018 |
} |
7019 |
# endif |
|
7020 |
#endif |
|
7021 |
if (! name || (name[0] == 0) ) { |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7022 |
name = (char *)getenv("LOGNAME"); |
831 | 7023 |
} |
7024 |
if (! name || (name[0] == 0) ) { |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7025 |
name = "you"; |
831 | 7026 |
} |
7027 |
||
830 | 7028 |
RETURN ( __MKSTRING(name COMMA_CON) ); |
831 | 7029 |
%}. |
616 | 7030 |
" |
7031 |
OperatingSystem getLoginName |
|
7032 |
" |
|
7033 |
! |
|
7034 |
||
7035 |
getUserID |
|
7036 |
"return the current users (thats you) numeric user id" |
|
7037 |
||
7038 |
%{ /* NOCONTEXT */ |
|
7039 |
||
7040 |
#ifdef UNIX_LIKE |
|
7041 |
int uid; |
|
7042 |
||
7043 |
uid = getuid(); |
|
7044 |
RETURN ( __MKSMALLINT(uid) ); |
|
7045 |
#else |
|
7046 |
# ifdef SYSTEM_HAS_USERS |
|
7047 |
/* ... */ |
|
7048 |
# endif |
|
7049 |
#endif |
|
7050 |
%}. |
|
7051 |
^ 1 "just a dummy for systems which do not have userIDs" |
|
7052 |
||
7053 |
" |
|
7054 |
OperatingSystem getUserID |
|
68 | 7055 |
" |
616 | 7056 |
! |
7057 |
||
7058 |
getUserNameFromID:aNumber |
|
1549
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7059 |
"return the user-name-string for a given numeric user-id. |
df9d235c992e
added #getFullUserNameFromID:, to access the GECOS field
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
7060 |
This is the login name, not the fullName." |
616 | 7061 |
|
7062 |
%{ /* NOCONTEXT */ |
|
7063 |
||
7064 |
#ifdef UNIX_LIKE |
|
7065 |
struct passwd *p; |
|
7066 |
||
7067 |
if (__isSmallInteger(aNumber)) { |
|
1588
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7068 |
p = getpwuid(__intVal(aNumber)); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7069 |
if (p) { |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7070 |
RETURN ( __MKSTRING(p->pw_name COMMA_CON) ); |
0f9e80f6ae74
WANT_SYSTEM definition moved to sunIntern.h (for sunos)
Claus Gittinger <cg@exept.de>
parents:
1549
diff
changeset
|
7071 |
} |
616 | 7072 |
} |
7073 |
#endif |
|
7074 |
%}. |
|
7075 |
^ '? (' , aNumber printString , ')' |
|
7076 |
||
7077 |
" |
|
7078 |
OperatingSystem getUserNameFromID:0 |
|
7079 |
OperatingSystem getUserNameFromID:100 |
|
7080 |
OperatingSystem getUserNameFromID:9991 |
|
7081 |
" |
|
1 | 7082 |
! |
7083 |
||
616 | 7084 |
userInfoOf:aNameOrID |
7085 |
"return a dictionary filled with userinfo. The argument can be either |
|
7086 |
a string with the users name or its numeric id. |
|
7087 |
Notice, that not all systems provide (all of) this info; |
|
7088 |
DOS systems return nothing; |
|
7089 |
non-SYSV4 systems have no age/comment. |
|
7090 |
Portable applications may want to check the systemType and NOT depend |
|
7091 |
on all keys to be present in the returned dictionary. |
|
7092 |
Another notice: on some systems (SYSV4), the gecos field includes multiple |
|
7093 |
entries (i.e. not just the name), separated by commas. You may want to |
|
7094 |
extract any substring, up to the first comma to get the real life name." |
|
7095 |
||
7096 |
|info name passw uid gid age comment |
|
7097 |
gecos dir shell| |
|
7098 |
||
7099 |
%{ |
|
7100 |
#ifdef UNIX_LIKE |
|
7101 |
struct passwd *buf; |
|
7102 |
int ret; |
|
7103 |
||
7104 |
if (__isString(aNameOrID)) { |
|
7105 |
buf = getpwnam(__stringVal(aNameOrID)); |
|
7106 |
} else if (__isSmallInteger(aNameOrID)) { |
|
7107 |
buf = getpwuid(__intVal(aNameOrID)); |
|
7108 |
} else { |
|
7109 |
buf = (struct passwd *)0; |
|
7110 |
} |
|
7111 |
if (buf) { |
|
830 | 7112 |
name = __MKSTRING(buf->pw_name COMMA_CON); |
7113 |
passw = __MKSTRING(buf->pw_passwd COMMA_CON); |
|
616 | 7114 |
# ifdef SYSV4 |
830 | 7115 |
age = __MKSTRING(buf->pw_age COMMA_CON); |
7116 |
comment = __MKSTRING(buf->pw_comment COMMA_CON); |
|
616 | 7117 |
# endif |
830 | 7118 |
dir = __MKSTRING(buf->pw_dir COMMA_CON); |
7119 |
gecos = __MKSTRING(buf->pw_gecos COMMA_CON); |
|
7120 |
shell = __MKSTRING(buf->pw_shell COMMA_CON); |
|
616 | 7121 |
|
1135 | 7122 |
uid = __MKSMALLINT(buf->pw_uid); |
7123 |
gid = __MKSMALLINT(buf->pw_gid); |
|
616 | 7124 |
} |
7125 |
#endif |
|
7126 |
%}. |
|
7127 |
info := IdentityDictionary new. |
|
7128 |
name notNil ifTrue:[ |
|
7129 |
info at:#name put:name. |
|
7130 |
] ifFalse:[ |
|
7131 |
info at:#name put:'unknown' |
|
7132 |
]. |
|
7133 |
passw notNil ifTrue:[info at:#passwd put:passw]. |
|
7134 |
age notNil ifTrue:[info at:#age put:age]. |
|
7135 |
comment notNil ifTrue:[info at:#comment put:comment]. |
|
7136 |
gecos notNil ifTrue:[info at:#gecos put:gecos]. |
|
7137 |
shell notNil ifTrue:[info at:#shell put:shell]. |
|
7138 |
dir notNil ifTrue:[info at:#dir put:dir]. |
|
7139 |
uid notNil ifTrue:[info at:#uid put:uid]. |
|
7140 |
gid notNil ifTrue:[info at:#gid put:gid]. |
|
7141 |
^ info |
|
7142 |
||
7143 |
" |
|
7144 |
OperatingSystem userInfoOf:'root' |
|
7145 |
OperatingSystem userInfoOf:1 |
|
7146 |
OperatingSystem userInfoOf:'claus' |
|
7147 |
OperatingSystem userInfoOf:'fooBar' |
|
7148 |
OperatingSystem userInfoOf:(OperatingSystem getUserID) |
|
7149 |
" |
|
7150 |
! ! |
|
7151 |
||
1497 | 7152 |
!OperatingSystem class methodsFor:'waiting for events'! |
616 | 7153 |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7154 |
blockingChildProcessWait |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7155 |
"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
|
7156 |
%{ /*NOCONTEXT*/ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7157 |
#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
|
7158 |
RETURN(false); |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7159 |
#else |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7160 |
RETURN(true); |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7161 |
#endif |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7162 |
%} |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7163 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7164 |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7165 |
childProcessWait:blocking |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7166 |
"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
|
7167 |
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
|
7168 |
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
|
7169 |
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
|
7170 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7171 |
|pid status code core| |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7172 |
%{ |
1597 | 7173 |
#ifdef UNIX_LIKE |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7174 |
int p; |
1597 | 7175 |
# if defined(HAS_WAITPID) |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7176 |
int s; |
1597 | 7177 |
# define __WAIT waitpid(-1, &s, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED) |
7178 |
# else |
|
7179 |
# if defined(HAS_WAIT3) |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7180 |
union wait s; |
1597 | 7181 |
# define __WAIT wait3(&s, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED, 0) |
7182 |
# else /*!HAS_WAIT3*/ |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7183 |
int s; |
1597 | 7184 |
# define __WAIT wait(&s) |
7185 |
# define __BLOCKING_WAIT__ 1 |
|
7186 |
||
7187 |
# if !defined(WIFEXITED) |
|
7188 |
# define WIFEXITED(stat) (((int)((stat)&0377))==0) |
|
7189 |
# define WIFSIGNALED(stat) (((int)((stat)&0377))>0&&((int)(((stat)>>8)&0377))==0) |
|
7190 |
# define WIFSTOPPED(stat) (((int)((stat)&0377))==0177&&((int)(((stat)>>8)&0377))!=0) |
|
7191 |
||
7192 |
# define WEXITSTATUS(stat) ((int)(((stat)>>8)&0377)) |
|
7193 |
# define WTERMSIG(stat) (((int)((stat)&0377))&0177) |
|
7194 |
# define WSTOPSIG(stat) ((int)(((stat)>>8)&0377)) |
|
7195 |
# endif /*!WIFEXITED*/ |
|
7196 |
# if !defined(WCOREDUMP) |
|
7197 |
# define WCOREDUMP(stat) ((int)(((stat)>>8)&0200)) |
|
7198 |
# 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
|
7199 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7200 |
if (blocking != true) { |
1487 | 7201 |
/* |
7202 |
* We do not support nonBlocking waits, so signal an error |
|
7203 |
* Sorry about the goto, but with all these ifdefs ... |
|
7204 |
*/ |
|
7205 |
goto done; |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7206 |
} |
1597 | 7207 |
# endif /*!HAS_WAIT3*/ |
7208 |
# endif /*!HAS_WAITPID*/ |
|
7209 |
||
7210 |
# if __BLOCKING_WAIT__ |
|
1433 | 7211 |
__BEGIN_INTERRUPTABLE__ |
1597 | 7212 |
# endif |
1433 | 7213 |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7214 |
do { |
1487 | 7215 |
p = __WAIT; |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7216 |
} 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
|
7217 |
|
1597 | 7218 |
# if __BLOCKING_WAIT__ |
1433 | 7219 |
__END_INTERRUPTABLE__ |
1597 | 7220 |
# undef __BLOCKING_WAIT__ |
7221 |
# endif |
|
7222 |
||
7223 |
# undef __WAIT |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7224 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7225 |
if (p == 0) |
1487 | 7226 |
RETURN(nil) |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7227 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7228 |
if (p == -1) { |
1487 | 7229 |
if (errno == ECHILD) |
7230 |
RETURN(nil); |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7231 |
} else { |
1487 | 7232 |
pid = __MKSMALLINT(p); |
7233 |
if (WIFEXITED(s)) { |
|
7234 |
status = @symbol(exit); |
|
7235 |
code = __MKSMALLINT(WEXITSTATUS(s)); |
|
7236 |
core = WCOREDUMP(s) ? true : false; |
|
7237 |
} else if (WIFSIGNALED(s)) { |
|
7238 |
status = @symbol(signal); |
|
7239 |
code = __MKSMALLINT(WTERMSIG(s)); |
|
7240 |
} else if (WIFSTOPPED(s)) { |
|
7241 |
status = @symbol(stop); |
|
7242 |
code = __MKSMALLINT(WSTOPSIG(s)); |
|
7243 |
} |
|
1597 | 7244 |
# if defined(WIFCONTINUED) |
1487 | 7245 |
else if (WIFCONTINUED(s)) { |
7246 |
status = @symbol(continue); |
|
7247 |
} |
|
1597 | 7248 |
# endif |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7249 |
} |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7250 |
done: ; |
1597 | 7251 |
#endif /* UNIX_LIKE */ |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7252 |
%}. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7253 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7254 |
pid isNil ifTrue:[ |
1487 | 7255 |
^ self primitiveFailed |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7256 |
]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7257 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7258 |
^ 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
|
7259 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7260 |
" |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7261 |
OperatingSystem childProcessWait:false |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7262 |
" |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7263 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
7264 |
"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
|
7265 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
7266 |
|
10 | 7267 |
readCheck:fd |
95 | 7268 |
"return true, if data is available on a filedescriptor (i.e. read |
7269 |
is possible without blocking)" |
|
10 | 7270 |
|
7271 |
(self selectOnAnyReadable:(Array with:fd) |
|
185 | 7272 |
writable:nil |
7273 |
exception:nil |
|
7274 |
withTimeOut:0) == fd |
|
7275 |
ifTrue:[^ true]. |
|
10 | 7276 |
^ false |
7277 |
! |
|
7278 |
||
616 | 7279 |
selectOn:fd1 and:fd2 withTimeOut:millis |
7280 |
"wait for any fd to become ready; timeout after t milliseconds. |
|
7281 |
A zero timeout-time will immediately return (i.e. poll). |
|
7282 |
Return fd if i/o ok, nil if timed-out or interrupted. |
|
7283 |
Obsolete: |
|
7284 |
This is a leftover method and will vanish." |
|
7285 |
||
7286 |
^ self selectOnAnyReadable:(Array with:fd1 with:fd2) |
|
7287 |
writable:(Array with:fd1 with:fd2) |
|
7288 |
exception:nil |
|
7289 |
withTimeOut:millis |
|
10 | 7290 |
! |
7291 |
||
7292 |
selectOn:fd withTimeOut:millis |
|
7293 |
"wait for aFileDesriptor to become ready; timeout after t milliseconds. |
|
1 | 7294 |
Return true, if i/o ok, false if timed-out or interrupted. |
7295 |
With 0 as timeout argument, this can be used to check for availability |
|
7296 |
of read-data. |
|
7297 |
Experimental." |
|
7298 |
||
3 | 7299 |
^ self selectOnAnyReadable:(Array with:fd) |
185 | 7300 |
writable:(Array with:fd) |
7301 |
exception:nil |
|
7302 |
withTimeOut:millis |
|
1 | 7303 |
! |
7304 |
||
616 | 7305 |
selectOnAny:fdArray withTimeOut:millis |
7306 |
"wait for any fd in fdArray (an Array of integers) to become ready; |
|
7307 |
timeout after t milliseconds. An empty set will always wait. |
|
7308 |
Return first ready fd if i/o ok, nil if timed-out or interrupted. |
|
7309 |
Experimental." |
|
7310 |
||
7311 |
^ self selectOnAnyReadable:fdArray |
|
7312 |
writable:fdArray |
|
185 | 7313 |
exception:nil |
7314 |
withTimeOut:millis |
|
1 | 7315 |
! |
7316 |
||
10 | 7317 |
selectOnAnyReadable:fdArray withTimeOut:millis |
95 | 7318 |
"wait for any fd in fdArray (an Array of integers) to become ready for |
7319 |
reading. Timeout after t milliseconds. An empty set will always wait. |
|
7320 |
A zero timeout-time will immediately return (i.e. poll). |
|
3 | 7321 |
Return first ready fd if i/o ok, nil if timed-out or interrupted. |
7322 |
Experimental." |
|
7323 |
||
7324 |
^ self selectOnAnyReadable:fdArray |
|
185 | 7325 |
writable:nil |
7326 |
exception:nil |
|
7327 |
withTimeOut:millis |
|
3 | 7328 |
! |
7329 |
||
95 | 7330 |
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray withTimeOut:millis |
7331 |
"wait for any fd in readFdArray (an Array of integers) to become ready for |
|
7332 |
reading, writeFdArray to become ready for writing, or exceptFdArray to |
|
7333 |
arrive exceptional data (i.e. out-of-band data). |
|
7334 |
Timeout after t milliseconds or, if the timeout time is 0, immediately.. |
|
7335 |
Empty fd-sets will always wait. Zero time can be used to poll file- |
|
7336 |
descriptors (i.e. to check if I/O possible without blocking). |
|
7337 |
Return first ready fd if I/O ok, nil if timed-out or interrupted." |
|
3 | 7338 |
|
1 | 7339 |
%{ |
831 | 7340 |
#ifdef MSDOS_LIKE |
7341 |
/* |
|
7342 |
* support a delay-wait only |
|
7343 |
* (i.e. fail if any filedescriptor is selected upon) |
|
7344 |
*/ |
|
7345 |
int count; |
|
7346 |
int i; |
|
7347 |
int t; |
|
7348 |
OBJ fd; |
|
7349 |
||
7350 |
if (! __isSmallInteger(millis)) { |
|
7351 |
goto fail; |
|
7352 |
} |
|
7353 |
||
7354 |
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
|
7355 |
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
|
7356 |
goto fail; |
831 | 7357 |
} |
7358 |
count = __arraySize(readFdArray); |
|
7359 |
for (i=0; i<count;i++) { |
|
1135 | 7360 |
fd = __ArrayInstPtr(readFdArray)->a_element[i]; |
831 | 7361 |
if (fd != nil) { |
7362 |
goto fail; |
|
7363 |
} |
|
7364 |
} |
|
7365 |
} |
|
7366 |
if (writeFdArray != nil) { |
|
7367 |
if (! __isArray(writeFdArray)) { |
|
7368 |
goto fail; |
|
7369 |
} |
|
7370 |
count = __arraySize(writeFdArray); |
|
7371 |
for (i=0; i<count;i++) { |
|
1135 | 7372 |
fd = __ArrayInstPtr(writeFdArray)->a_element[i]; |
831 | 7373 |
if (fd != nil) { |
7374 |
goto fail; |
|
7375 |
} |
|
7376 |
} |
|
7377 |
} |
|
7378 |
if (exceptFdArray != nil) { |
|
7379 |
if (! __isArray(exceptFdArray)) { |
|
7380 |
goto fail; |
|
7381 |
} |
|
7382 |
count = __arraySize(exceptFdArray); |
|
7383 |
for (i=0; i<count;i++) { |
|
1135 | 7384 |
fd = __ArrayInstPtr(exceptFdArray)->a_element[i]; |
831 | 7385 |
if (fd != nil) { |
7386 |
goto fail; |
|
7387 |
} |
|
7388 |
} |
|
7389 |
} |
|
1135 | 7390 |
t = __intVal(millis); |
831 | 7391 |
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
|
7392 |
/* |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
7393 |
* delay only |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
7394 |
*/ |
831 | 7395 |
Sleep(t); |
7396 |
} |
|
7397 |
RETURN (nil); |
|
7398 |
||
7399 |
#else /* not MSDOS_LIKE */ |
|
1 | 7400 |
fd_set rset, wset, eset; |
831 | 7401 |
struct timeval wt, et; |
1 | 7402 |
int t, f, maxF, i, lX, bX; |
7403 |
OBJ fd, retFd; |
|
95 | 7404 |
int ret; |
300 | 7405 |
int count; |
1 | 7406 |
|
252 | 7407 |
if (__isSmallInteger(millis)) { |
185 | 7408 |
FD_ZERO(&rset); |
7409 |
FD_ZERO(&wset); |
|
7410 |
FD_ZERO(&eset); |
|
7411 |
||
7412 |
maxF = -1; |
|
308 | 7413 |
if (readFdArray != nil) { |
300 | 7414 |
if (! __isArray(readFdArray)) { |
7415 |
goto fail; |
|
7416 |
} |
|
7417 |
count = __arraySize(readFdArray); |
|
308 | 7418 |
|
7419 |
for (i=0; i<count;i++) { |
|
1135 | 7420 |
fd = __ArrayInstPtr(readFdArray)->a_element[i]; |
308 | 7421 |
if (fd != nil) { |
1135 | 7422 |
f = __intVal(fd); |
308 | 7423 |
if ((f >= 0) && (f < FD_SETSIZE)) { |
7424 |
FD_SET(f, &rset); |
|
7425 |
if (f > maxF) maxF = f; |
|
7426 |
} |
|
185 | 7427 |
} |
7428 |
} |
|
7429 |
} |
|
300 | 7430 |
|
308 | 7431 |
if (writeFdArray != nil) { |
300 | 7432 |
if (! __isArray(writeFdArray)) { |
7433 |
goto fail; |
|
7434 |
} |
|
7435 |
count = __arraySize(writeFdArray); |
|
308 | 7436 |
for (i=0; i<count;i++) { |
1135 | 7437 |
fd = __ArrayInstPtr(writeFdArray)->a_element[i]; |
308 | 7438 |
if (fd != nil) { |
1135 | 7439 |
f = __intVal(fd); |
308 | 7440 |
if ((f >= 0) && (f < FD_SETSIZE)) { |
7441 |
FD_SET(f, &wset); |
|
7442 |
if (f > maxF) maxF = f; |
|
7443 |
} |
|
185 | 7444 |
} |
7445 |
} |
|
7446 |
} |
|
300 | 7447 |
|
308 | 7448 |
if (exceptFdArray != nil) { |
300 | 7449 |
if (! __isArray(exceptFdArray)) { |
7450 |
goto fail; |
|
7451 |
} |
|
7452 |
count = __arraySize(exceptFdArray); |
|
308 | 7453 |
for (i=0; i<count;i++) { |
1135 | 7454 |
fd = __ArrayInstPtr(exceptFdArray)->a_element[i]; |
308 | 7455 |
if (fd != nil) { |
1135 | 7456 |
f = __intVal(fd); |
308 | 7457 |
if ((f >= 0) && (f < FD_SETSIZE)) { |
7458 |
FD_SET(f, &eset); |
|
7459 |
if (f > maxF) maxF = f; |
|
7460 |
} |
|
185 | 7461 |
} |
7462 |
} |
|
7463 |
} |
|
308 | 7464 |
|
1135 | 7465 |
t = __intVal(millis); |
774
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7466 |
if (t) { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7467 |
wt.tv_sec = t / 1000; |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7468 |
wt.tv_usec = (t % 1000) * 1000; |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7469 |
} else { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7470 |
wt.tv_sec = wt.tv_usec = 0; |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7471 |
} |
185 | 7472 |
|
7473 |
/* |
|
7474 |
* make certain, that interrupt gets us out of the select |
|
7475 |
*/ |
|
362 | 7476 |
__BEGIN_INTERRUPTABLE__ |
185 | 7477 |
errno = 0; |
774
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7478 |
|
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7479 |
if (t == 0) { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7480 |
/* |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7481 |
* 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
|
7482 |
* interruptable. |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7483 |
*/ |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7484 |
do { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7485 |
ret = select(maxF+1, &rset, &wset, &eset, &wt); |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7486 |
} while ((ret < 0) && (errno == EINTR)); |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7487 |
} else { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7488 |
do { |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7489 |
ret = select(maxF+1, &rset, &wset, &eset, &wt); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7490 |
/* |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7491 |
* 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
|
7492 |
* could otherwise stay in this loop forever ... |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7493 |
* 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
|
7494 |
* 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
|
7495 |
*/ |
774
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7496 |
} while (0 /* (ret < 0) && (errno == EINTR) */ ); |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
7497 |
} |
362 | 7498 |
__END_INTERRUPTABLE__ |
95 | 7499 |
|
185 | 7500 |
if (ret > 0) { |
7501 |
for (i=0; i <= maxF; i++) { |
|
7502 |
if (FD_ISSET(i, &rset) |
|
7503 |
|| FD_ISSET(i, &wset) |
|
7504 |
|| FD_ISSET(i, &eset)) { |
|
1135 | 7505 |
RETURN ( __MKSMALLINT(i) ); |
185 | 7506 |
} |
7507 |
} |
|
855
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
7508 |
} else { |
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
7509 |
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
|
7510 |
if (errno != EINTR) { |
1058
5d010b97ecb8
added methods to handle symbolic errno codes
Claus Gittinger <cg@exept.de>
parents:
1046
diff
changeset
|
7511 |
fprintf(stderr, "OS: select errno = %d\n", errno); |
1135 | 7512 |
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
|
7513 |
} |
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
7514 |
} |
185 | 7515 |
} |
308 | 7516 |
|
185 | 7517 |
/* |
7518 |
* return nil (means time expired) |
|
7519 |
*/ |
|
7520 |
RETURN ( nil ); |
|
1 | 7521 |
} |
831 | 7522 |
#endif /* not MSDOS_LIKE */ |
7523 |
||
300 | 7524 |
fail: ; |
68 | 7525 |
%}. |
7526 |
" |
|
300 | 7527 |
timeout argument not integer, |
7528 |
or any fd-array nonNil and not an array |
|
792 | 7529 |
or not supported by OS |
68 | 7530 |
" |
792 | 7531 |
^ self primitiveFailed |
1 | 7532 |
! |
7533 |
||
616 | 7534 |
setBlocking:aBoolean on:fd |
7535 |
"set/clear the blocking attribute - if set (which is the default) |
|
7536 |
a read on the fileDescriptor will block until data is available. |
|
7537 |
If cleared, a read operation will immediately return with a value of |
|
7538 |
nil." |
|
10 | 7539 |
|
7540 |
%{ /* NOCONTEXT */ |
|
7541 |
||
616 | 7542 |
int ret, flags; |
7543 |
int savInt; |
|
7544 |
||
7545 |
#if defined(F_GETFL) && defined(F_SETFL) |
|
7546 |
# if defined(FNDELAY) |
|
7547 |
if (__isSmallInteger(fd)) { |
|
1135 | 7548 |
int f = __intVal(fd); |
7549 |
||
7550 |
flags = fcntl(f, F_GETFL, 0); |
|
616 | 7551 |
if (aBoolean == true) { |
1135 | 7552 |
ret = fcntl(f, F_SETFL, flags & ~FNDELAY); |
616 | 7553 |
} else { |
1135 | 7554 |
ret = fcntl(f, F_SETFL, flags | FNDELAY); |
185 | 7555 |
} |
616 | 7556 |
if (ret >= 0) ret = flags; |
1135 | 7557 |
RETURN ( __MKSMALLINT(ret) ); |
77 | 7558 |
} |
616 | 7559 |
# endif |
77 | 7560 |
#endif |
308 | 7561 |
%}. |
77 | 7562 |
" |
616 | 7563 |
fd argument not integer |
185 | 7564 |
" |
792 | 7565 |
^ self primitiveFailed |
1 | 7566 |
! |
7567 |
||
616 | 7568 |
writeCheck:fd |
7569 |
"return true, if filedescriptor can be written without blocking" |
|
7570 |
||
7571 |
(self selectOnAnyReadable:nil |
|
7572 |
writable:(Array with:fd) |
|
7573 |
exception:nil |
|
7574 |
withTimeOut:0) == fd |
|
7575 |
ifTrue:[^ true]. |
|
7576 |
^ false |
|
1 | 7577 |
! ! |
434 | 7578 |
|
1497 | 7579 |
!OperatingSystem class methodsFor:'documentation'! |
630 | 7580 |
|
7581 |
version |
|
1615
0dc932c45c67
added support for advisory file locks (on systems that support them)
Claus Gittinger <cg@exept.de>
parents:
1600
diff
changeset
|
7582 |
^ '$Header: /cvs/stx/stx/libbasic/Attic/Unix.st,v 1.156 1996-07-27 12:12:21 cg Exp $' |
630 | 7583 |
! ! |
616 | 7584 |
OperatingSystem initialize! |