author | Claus Gittinger <cg@exept.de> |
Thu, 29 Feb 1996 03:22:16 +0100 | |
changeset 1040 | 60e4c4bbbca2 |
parent 1034 | 4d3ef5de3ec8 |
child 1045 | c7a38395a1d4 |
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 |
439 | 51 |
# ifndef WANT_SYSTEM |
52 |
# define WANT_SYSTEM |
|
53 |
# endif |
|
443 | 54 |
# define WANT_SHM |
433 | 55 |
#endif |
56 |
||
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
57 |
#ifdef IRIX5 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
58 |
# define WANT_SYSTEM |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
59 |
#endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
60 |
|
514
81fa80a953e2
system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents:
513
diff
changeset
|
61 |
#ifdef ultrix |
81fa80a953e2
system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents:
513
diff
changeset
|
62 |
# define WANT_SYSTEM |
81fa80a953e2
system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents:
513
diff
changeset
|
63 |
#endif |
81fa80a953e2
system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents:
513
diff
changeset
|
64 |
|
515
43d76695a662
interruptable system() on hpux
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
65 |
#ifdef hpux |
43d76695a662
interruptable system() on hpux
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
66 |
# define WANT_SYSTEM |
43d76695a662
interruptable system() on hpux
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
67 |
#endif |
43d76695a662
interruptable system() on hpux
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
68 |
|
805 | 69 |
#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
|
70 |
# 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
|
71 |
#endif |
9620f7dc79d2
interruptable system() on unixware - should now move WANT_SYSTEM into xxxIntern files
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
72 |
|
831 | 73 |
/* |
74 |
* notice: although many systems' include files |
|
75 |
* already block against multiple inclusion, some |
|
76 |
* do not. Therefore, this is done here again. |
|
77 |
* (it does not hurt) |
|
78 |
*/ |
|
79 |
||
439 | 80 |
#ifdef WANT_REALPATH |
831 | 81 |
|
439 | 82 |
# include <sys/param.h> |
83 |
# define _SYS_PARAM_H_INCLUDED_ |
|
84 |
||
85 |
# include <errno.h> |
|
86 |
# define _ERRNO_H_INCLUDED_ |
|
87 |
||
88 |
# include <sys/stat.h> |
|
89 |
# define _SYS_STAT_H_INCLUDED_ |
|
443 | 90 |
|
439 | 91 |
#endif /* WANT_REALPATH */ |
92 |
||
831 | 93 |
|
94 |
||
434 | 95 |
#ifdef WANT_SHM |
443 | 96 |
extern int shmctl(), shmget(), shmdt(); |
97 |
extern char * shmat(); |
|
98 |
||
434 | 99 |
# include <sys/types.h> |
437 | 100 |
# define _SYS_TYPES_H_INCLUDED_ |
439 | 101 |
|
434 | 102 |
# include <sys/ipc.h> |
437 | 103 |
# define _SYS_IPC_H_INCLUDED_ |
439 | 104 |
|
434 | 105 |
# include <sys/shm.h> |
437 | 106 |
# define _SYS_SHM_H_INCLUDED_ |
831 | 107 |
|
439 | 108 |
#endif /* WANT_SHM */ |
434 | 109 |
|
831 | 110 |
|
434 | 111 |
#ifdef IRIX5 |
112 |
# include <sys/syssgi.h> |
|
113 |
#endif |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
114 |
|
831 | 115 |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
116 |
#ifdef transputer |
831 | 117 |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
118 |
# define unlink(f) ((remove(f) == 0) ? 0 : -1) |
831 | 119 |
|
120 |
#else /* not transputer */ |
|
121 |
||
122 |
# ifndef _SIGNAL_H_INCLUDED_ |
|
123 |
# include <signal.h> |
|
124 |
# define _SIGNAL_H_INCLUDED_ |
|
125 |
# endif |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
126 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
127 |
# ifdef SYSV |
831 | 128 |
# ifndef _SYS_TYPES_H_INCLUDED_ |
129 |
# include <sys/types.h> |
|
130 |
# define _SYS_TYPES_H_INCLUDED_ |
|
131 |
# endif |
|
132 |
# ifndef _SYS_PARAM_H_INCLUDED_ |
|
133 |
# include <sys/param.h> |
|
134 |
# define _SYS_PARAM_H_INCLUDED_ |
|
135 |
# endif |
|
136 |
# ifndef _SYS_TIMES_H_INCLUDED_ |
|
137 |
# include <sys/times.h> |
|
138 |
# define _SYS_TIMES_H_INCLUDED_ |
|
139 |
# endif |
|
140 |
# ifndef _SYS_FILE_H_INCLUDED_ |
|
141 |
# include <sys/file.h> |
|
142 |
# define _SYS_FILE_H_INCLUDED_ |
|
143 |
# endif |
|
144 |
||
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
145 |
# if ! defined(sco3_2) |
831 | 146 |
# ifndef _UNISTD_H_INCLUDED_ |
147 |
# include <unistd.h> |
|
148 |
# define _UNISTD_H_INCLUDED_ |
|
149 |
# endif |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
150 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
151 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
152 |
# if defined(isc3_2) || defined(sco3_2) |
831 | 153 |
# ifndef _SYS_TIME_H_INCLUDED_ |
154 |
# include <sys/time.h> |
|
155 |
# define _SYS_TIME_H_INCLUDED_ |
|
156 |
# endif |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
157 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
158 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
159 |
# if !defined(isc3_2) |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
160 |
# if defined(PCS) && defined(mips) |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
161 |
# include "/usr/include/bsd/sys/time.h" |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
162 |
# include "/usr/include/sys/time.h" |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
163 |
# else |
831 | 164 |
# ifndef _TIME_H_INCLUDED_ |
165 |
# include <time.h> |
|
166 |
# define _TIME_H_INCLUDED_ |
|
167 |
# endif |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
168 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
169 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
170 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
171 |
# if defined(isc3_2) |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
172 |
# include <sys/bsdtypes.h> |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
173 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
174 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
175 |
# else /* not SYSV */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
176 |
|
802 | 177 |
# ifdef MSDOS_LIKE |
831 | 178 |
|
179 |
# ifndef _SYS_TYPES_H_INCLUDED_ |
|
180 |
# include <sys/types.h> |
|
181 |
# define _SYS_TYPES_H_INCLUDED_ |
|
182 |
# endif |
|
183 |
# ifndef _TIME_H_INCLUDED_ |
|
184 |
# include <time.h> |
|
185 |
# define _TIME_H_INCLUDED_ |
|
186 |
# endif |
|
187 |
# ifndef _SYS_TIMEB_H_INCLUDED_ |
|
188 |
# include <sys/timeb.h> |
|
189 |
# define _SYS_TIMEB_H_INCLUDED_ |
|
190 |
# endif |
|
191 |
||
192 |
# else /* not MSDOS_like */ |
|
193 |
||
194 |
# ifndef _SYS_TIME_H_INCLUDED_ |
|
195 |
# include <sys/time.h> |
|
196 |
# define _SYS_TIME_H_INCLUDED_ |
|
197 |
# endif |
|
198 |
# ifndef _SYS_TYPES_H_INCLUDED_ |
|
199 |
# include <sys/types.h> |
|
200 |
# define _SYS_TYPES_H_INCLUDED_ |
|
201 |
# endif |
|
202 |
||
203 |
# endif /* not MSDOS */ |
|
792 | 204 |
# endif /* not SYSV */ |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
205 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
206 |
# ifdef aix |
831 | 207 |
|
208 |
# ifndef _TIME_H_INCLUDED_ |
|
209 |
# include <time.h> |
|
914
d00401a9450e
Fix syntax error (#defined -> #define).
Stefan Vogel <sv@exept.de>
parents:
855
diff
changeset
|
210 |
# define _TIME_H_INCLUDED_ |
831 | 211 |
# endif |
212 |
# ifndef _SYS_SELECT_H_INCLUDED_ |
|
213 |
# include <sys/select.h> |
|
214 |
# define _SYS_SELECT_H_INCLUDED_ |
|
215 |
# endif |
|
216 |
||
792 | 217 |
# endif /* aix */ |
218 |
||
219 |
# ifndef MSDOS_LIKE |
|
220 |
# include <pwd.h> |
|
221 |
# include <grp.h> |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
222 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
223 |
|
831 | 224 |
# ifndef _SYS_STAT_H_INCLUDED_ |
225 |
# include <sys/stat.h> |
|
226 |
# endif |
|
227 |
||
228 |
# ifndef _ERRNO_H_INCLUDED_ |
|
229 |
# include <errno.h> |
|
230 |
# define _ERRNO_H_INCLUDED_ |
|
231 |
# endif |
|
232 |
||
233 |
# ifndef _STDIO_H_INCLUDED_ |
|
234 |
# include <stdio.h> |
|
235 |
# define _STDIO_H_INCLUDED_ |
|
236 |
# endif |
|
237 |
||
238 |
# ifndef _FCNTL_H_INCLUDED_ |
|
239 |
# include <fcntl.h> |
|
240 |
# define _FCNTL_H_INCLUDED_ |
|
241 |
# endif |
|
242 |
||
243 |
# ifdef WIN32 |
|
244 |
# undef INT |
|
245 |
# undef Array |
|
246 |
# undef Number |
|
247 |
# undef Method |
|
248 |
# undef Point |
|
249 |
||
250 |
/* # include <windows.h> /* */ |
|
251 |
# include <stdarg.h> /* */ |
|
252 |
# include <windef.h> /* */ |
|
253 |
# include <winbase.h> /* */ |
|
254 |
# include <wingdi.h> /* */ |
|
255 |
# include <winuser.h> /* */ |
|
256 |
||
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
257 |
# 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
|
258 |
# define Array __DEF_Array |
831 | 259 |
# endif |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
260 |
# 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
|
261 |
# define Number __DEF_Number |
831 | 262 |
# endif |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
263 |
# 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
|
264 |
# define Method __DEF_Method |
831 | 265 |
# endif |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
266 |
# 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
|
267 |
# define Point __DEF_Point |
831 | 268 |
# endif |
269 |
# endif |
|
270 |
||
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
271 |
|
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
272 |
# if defined(LINUX) |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
273 |
# define HAS_LOCALECONV |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
274 |
# endif |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
275 |
|
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
276 |
# if defined (HAS_LOCALECONV) |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
277 |
# ifndef _LOCALE_H_INCLUDED_ |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
278 |
# include <locale.h> |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
279 |
# define _LOCALE_H_INCLUDED_ |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
280 |
# endif |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
281 |
# endif |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
282 |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
283 |
/* |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
284 |
* posix systems should define these ... |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
285 |
* but on some (older) systems, they are not. |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
286 |
*/ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
287 |
# ifndef S_IXUSR |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
288 |
# ifdef S_IEXEC |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
289 |
# define S_IXUSR S_IEXEC |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
290 |
# define S_IXGRP (S_IEXEC>>3) |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
291 |
# define S_IXOTH (S_IEXEC>>6) |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
292 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
293 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
294 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
295 |
# ifndef S_IXUSR |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
296 |
# define S_IXUSR 0100 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
297 |
# define S_IXGRP 0010 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
298 |
# define S_IXOTH 0001 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
299 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
300 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
301 |
# ifndef S_IRUSR |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
302 |
# define S_IRUSR 0400 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
303 |
# define S_IRGRP 0040 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
304 |
# define S_IROTH 0004 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
305 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
306 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
307 |
# ifndef S_IWUSR |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
308 |
# define S_IWUSR 0200 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
309 |
# define S_IWGRP 0020 |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
310 |
# define S_IWOTH 0002 |
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 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
313 |
# ifndef MAXPATHLEN |
792 | 314 |
# ifndef MSDOS_LIKE |
315 |
# include <sys/param.h> |
|
316 |
# endif |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
317 |
# ifndef MAXPATHLEN |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
318 |
# ifdef FILENAME_MAX /* i.e. MSDOS_LIKE */ |
792 | 319 |
# define MAXPATHLEN FILENAME_MAX |
320 |
# else |
|
321 |
# define MAXPATHLEN 1024 |
|
322 |
# endif |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
323 |
# endif |
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 |
# if defined(HAS_UNAME) |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
327 |
# include <sys/utsname.h> |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
328 |
# endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
329 |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
330 |
# if defined(SYSV4) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
331 |
# include <stropts.h> |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
332 |
# endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
333 |
|
763
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
334 |
/* |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
335 |
* 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
|
336 |
*/ |
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
337 |
# ifndef SA_RESTART |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
338 |
# 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
|
339 |
# endif |
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
340 |
# ifndef SA_SIGINFO |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
341 |
# 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
|
342 |
# endif |
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
343 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
344 |
# 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
|
345 |
# include <sys/wait.h> |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
346 |
# endif |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
347 |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
348 |
#endif /* ! transputer */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
349 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
350 |
/* |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
351 |
* 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
|
352 |
*/ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
353 |
#ifndef errno |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
354 |
extern errno; |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
355 |
#endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
356 |
|
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
357 |
/* |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
358 |
* some (old ?) systems do not define this ... |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
359 |
*/ |
675 | 360 |
#if !defined(R_OK) && !defined(_AIX) |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
361 |
# define R_OK 4 /* Test for Read permission */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
362 |
# define W_OK 2 /* Test for Write permission */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
363 |
# define X_OK 1 /* Test for eXecute permission */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
364 |
# define F_OK 0 /* Test for existence of File */ |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
365 |
#endif |
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
366 |
|
832 | 367 |
#ifdef WIN32 |
368 |
# define SIGHANDLER_ARG int |
|
369 |
#else |
|
370 |
# define SIGHANDLER_ARG |
|
371 |
#endif |
|
372 |
||
437 | 373 |
%} |
374 |
! ! |
|
375 |
||
376 |
!OperatingSystem primitiveFunctions! |
|
377 |
%{ |
|
378 |
||
379 |
/* |
|
380 |
* some systems' system() is broken in that it does not correctly |
|
381 |
* handle EINTR and returns failure even though it actually succeeded. |
|
382 |
* (LINUX is one of them) |
|
383 |
* Here is a fixed version. If you encounter EINTR returns from |
|
384 |
* OperatingSystem>>executeCommand, you ought to define WANT_SYSTEM |
|
385 |
* in the xxxIntern.h file to get this fixed version. |
|
386 |
* |
|
387 |
* As an added BONUS, this system() enables interrupts while waiting |
|
388 |
* 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
|
389 |
* (i.e. it is RT safe) |
437 | 390 |
*/ |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
391 |
|
433 | 392 |
#if defined(WANT_SYSTEM) |
393 |
||
434 | 394 |
/* # define DPRINTF(x) printf x */ |
395 |
# define DPRINTF(x) /* nothing */ |
|
433 | 396 |
|
437 | 397 |
# ifndef _STDDEF_H_INCLUDED_ |
398 |
# include <stddef.h> |
|
399 |
# define _STDDEF_H_INCLUDED_ |
|
400 |
# endif |
|
401 |
||
402 |
# ifndef _STDLIB_H_INCLUDED_ |
|
403 |
# include <stdlib.h> |
|
404 |
# define _STDLIB_H_INCLUDED_ |
|
405 |
# endif |
|
406 |
||
407 |
# ifndef _UNISTD_H_INCLUDED_ |
|
408 |
# include <unistd.h> |
|
409 |
# define _UNISTD_H_INCLUDED_ |
|
410 |
# endif |
|
411 |
||
412 |
# ifndef _SYS_WAIT_H_INCLUDED |
|
413 |
# include <sys/wait.h> |
|
414 |
# define _SYS_WAIT_H_INCLUDED |
|
415 |
# endif |
|
416 |
||
417 |
# ifndef _SIGNAL_H_INCLUDED_ |
|
418 |
# include <signal.h> |
|
419 |
# define _SIGNAL_H_INCLUDED_ |
|
420 |
# endif |
|
421 |
||
422 |
# ifndef _SYS_TYPES_H_INCLUDED_ |
|
423 |
# include <sys/types.h> |
|
424 |
# define _SYS_TYPES_H_INCLUDED_ |
|
425 |
# endif |
|
433 | 426 |
|
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
427 |
# if (!defined(HAVE_GNU_LD) && !defined (__ELF__)) || !defined(LINUX) |
433 | 428 |
# define __environ environ |
512 | 429 |
# if !defined(LINUX) |
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
430 |
# define __sigemptyset sigemptyset |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
431 |
# define __sigaction sigaction |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
432 |
# define __sigaddset sigaddset |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
433 |
# define __sigprocmask sigprocmask |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
434 |
# define __execve execve |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
435 |
# define __wait wait |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
436 |
# define __waitpid waitpid |
674 | 437 |
# if defined(HAS_VFORK) |
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
438 |
# define FORK vfork |
514
81fa80a953e2
system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents:
513
diff
changeset
|
439 |
# else |
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
440 |
# define FORK fork |
514
81fa80a953e2
system() now interruptable with ultrix
Claus Gittinger <cg@exept.de>
parents:
513
diff
changeset
|
441 |
# endif |
512 | 442 |
# endif /* ! LINUX */ |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
443 |
extern char **environ; |
433 | 444 |
# endif |
445 |
||
446 |
# define SHELL_PATH "/bin/sh" /* Path of the shell. */ |
|
447 |
# define SHELL_NAME "sh" /* Name to give it. */ |
|
448 |
||
449 |
# ifndef FORK |
|
450 |
# define FORK __fork |
|
451 |
# endif |
|
452 |
||
453 |
# ifndef CONST |
|
454 |
# ifdef __GNUC__ |
|
455 |
# define CONST const |
|
456 |
# else |
|
457 |
# define CONST /* nothing */ |
|
458 |
# endif |
|
459 |
# endif |
|
460 |
||
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
461 |
static int |
511
7626c5474c7f
interruptable system() for IRIX5
Claus Gittinger <cg@exept.de>
parents:
507
diff
changeset
|
462 |
mySystem(line) |
433 | 463 |
register CONST char *line; |
464 |
{ |
|
465 |
int status, save; |
|
466 |
pid_t pid; |
|
467 |
struct sigaction sa, intr, quit; |
|
468 |
sigset_t block, omask; |
|
469 |
||
470 |
if (line == NULL) |
|
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
471 |
return -1; |
433 | 472 |
|
473 |
sa.sa_handler = SIG_IGN; |
|
474 |
sa.sa_flags = 0; |
|
475 |
__sigemptyset (&sa.sa_mask); |
|
476 |
||
477 |
if (__sigaction (SIGINT, &sa, &intr) < 0) { |
|
478 |
DPRINTF(("1: errno=%d\n", errno)); |
|
479 |
return -1; |
|
480 |
} |
|
481 |
if (__sigaction (SIGQUIT, &sa, &quit) < 0) { |
|
482 |
save = errno; |
|
483 |
(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL); |
|
484 |
errno = save; |
|
485 |
DPRINTF(("2: errno=%d\n", errno)); |
|
486 |
return -1; |
|
487 |
} |
|
488 |
||
489 |
__sigemptyset (&block); |
|
490 |
__sigaddset (&block, SIGCHLD); |
|
491 |
save = errno; |
|
492 |
if (__sigprocmask(SIG_BLOCK, &block, &omask) < 0) { |
|
493 |
if (errno == ENOSYS) |
|
494 |
errno = save; |
|
495 |
else { |
|
496 |
save = errno; |
|
497 |
(void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL); |
|
498 |
(void) __sigaction(SIGQUIT, &quit, (struct sigaction *) NULL); |
|
499 |
errno = save; |
|
500 |
DPRINTF(("3: errno=%d\n", errno)); |
|
501 |
return -1; |
|
502 |
} |
|
503 |
} |
|
504 |
||
505 |
pid = FORK (); |
|
506 |
if (pid == (pid_t) 0) { |
|
507 |
/* Child side. */ |
|
508 |
CONST char *new_argv[4]; |
|
509 |
new_argv[0] = SHELL_NAME; |
|
510 |
new_argv[1] = "-c"; |
|
511 |
new_argv[2] = line; |
|
512 |
new_argv[3] = NULL; |
|
513 |
||
514 |
/* Restore the signals. */ |
|
515 |
(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL); |
|
516 |
(void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL); |
|
517 |
(void) __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL); |
|
518 |
||
519 |
/* Exec the shell. */ |
|
520 |
(void) __execve (SHELL_PATH, (char *CONST *) new_argv, __environ); |
|
521 |
_exit (127); |
|
522 |
} else { |
|
523 |
if (pid < (pid_t) 0) { |
|
524 |
/* The fork failed. */ |
|
525 |
DPRINTF(("4: errno=%d\n", errno)); |
|
526 |
status = -1; |
|
527 |
} else { |
|
528 |
/* Parent side. */ |
|
529 |
#ifdef NO_WAITPID |
|
530 |
pid_t child; |
|
531 |
||
532 |
do { |
|
805 | 533 |
__BEGIN_INTERRUPTABLE__ |
433 | 534 |
child = __wait (&status); |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
535 |
__END_INTERRUPTABLE__ |
805 | 536 |
if (child < 0 && errno != EINTR) { |
433 | 537 |
DPRINTF(("5: errno=%d\n", errno)); |
538 |
status = -1; |
|
539 |
break; |
|
540 |
} |
|
541 |
} while (child != pid); |
|
542 |
#else |
|
543 |
pid_t child; |
|
544 |
||
545 |
/* claus: the original did not care for EINTR here ... */ |
|
546 |
do { |
|
805 | 547 |
__BEGIN_INTERRUPTABLE__ |
433 | 548 |
child = __waitpid (pid, &status, 0); |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
549 |
__END_INTERRUPTABLE__ |
433 | 550 |
} while ((child != pid) && (errno == EINTR)); |
551 |
if (child != pid) { |
|
552 |
DPRINTF(("6: errno=%d\n", errno)); |
|
553 |
status = -1; |
|
554 |
} |
|
555 |
#endif /* NO_WAITPID */ |
|
556 |
} |
|
557 |
} |
|
558 |
save = errno; |
|
559 |
if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL) |
|
560 |
| __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL) |
|
561 |
| __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)) != 0) { |
|
562 |
if (errno == ENOSYS) { |
|
563 |
errno = save; |
|
564 |
} else { |
|
565 |
status = -1; |
|
566 |
DPRINTF(("7: errno=%d\n", errno)); |
|
567 |
} |
|
568 |
} |
|
569 |
||
570 |
return status; |
|
571 |
} |
|
572 |
#endif /* WANT_SYSTEM */ |
|
573 |
||
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
574 |
|
433 | 575 |
/* |
576 |
* some systems do not have realpath(); |
|
577 |
* the alternative of reading from a 'pwp'-pipe |
|
578 |
* is way too slow. Here is a realpath for the rest of us. |
|
440 | 579 |
* define WANT_REALPATH in the xxxIntern-file to get it. |
433 | 580 |
*/ |
443 | 581 |
|
440 | 582 |
#if defined(HAS_REALPATH) |
583 |
# undef WANT_REALPATH |
|
584 |
#endif |
|
585 |
#if !defined(HAS_GETWD) && !defined(HAS_GETCWD) |
|
586 |
# undef WANT_REALPATH |
|
587 |
#endif |
|
588 |
||
589 |
#if defined(WANT_REALPATH) |
|
406 | 590 |
|
591 |
# ifndef NULL |
|
592 |
# define NULL (char *)0 |
|
593 |
# endif |
|
594 |
||
439 | 595 |
# define MAX_READLINKS 32 |
596 |
||
597 |
# ifndef MAXPATHLEN |
|
598 |
# define MAXPATHLEN 1024 |
|
599 |
# endif |
|
406 | 600 |
|
601 |
static |
|
602 |
char *realpath(path, resolved_path) |
|
603 |
char *path; |
|
604 |
char resolved_path []; |
|
605 |
{ |
|
606 |
char copy_path[MAXPATHLEN]; |
|
607 |
char link_path[MAXPATHLEN]; |
|
608 |
char *new_path = resolved_path; |
|
609 |
char *max_path; |
|
610 |
int readlinks = 0; |
|
611 |
int n; |
|
612 |
||
613 |
/* Make a copy of the source path since we may need to modify it. */ |
|
614 |
strcpy(copy_path, path); |
|
615 |
path = copy_path; |
|
616 |
max_path = copy_path + MAXPATHLEN - 2; |
|
617 |
/* If it's a relative pathname use getwd for starters. */ |
|
618 |
if (*path != '/') { |
|
619 |
#ifdef HAS_GETCWD |
|
620 |
getcwd(new_path, MAXPATHLEN - 1); |
|
621 |
#else |
|
622 |
getwd(new_path); |
|
623 |
#endif |
|
624 |
new_path += strlen(new_path); |
|
625 |
if (new_path[-1] != '/') |
|
626 |
*new_path++ = '/'; |
|
627 |
} |
|
628 |
else { |
|
629 |
*new_path++ = '/'; |
|
630 |
path++; |
|
631 |
} |
|
632 |
/* Expand each slash-separated pathname component. */ |
|
633 |
while (*path != '\0') { |
|
634 |
/* Ignore stray "/". */ |
|
635 |
if (*path == '/') { |
|
636 |
path++; |
|
637 |
continue; |
|
638 |
} |
|
639 |
if (*path == '.') { |
|
640 |
/* Ignore ".". */ |
|
641 |
if (path[1] == '\0' || path[1] == '/') { |
|
642 |
path++; |
|
643 |
continue; |
|
644 |
} |
|
645 |
if (path[1] == '.') { |
|
646 |
if (path[2] == '\0' || path[2] == '/') { |
|
647 |
path += 2; |
|
648 |
/* Ignore ".." at root. */ |
|
649 |
if (new_path == resolved_path + 1) |
|
650 |
continue; |
|
651 |
/* Handle ".." by backing up. */ |
|
652 |
while ((--new_path)[-1] != '/') |
|
653 |
; |
|
654 |
continue; |
|
655 |
} |
|
656 |
} |
|
657 |
} |
|
658 |
/* Safely copy the next pathname component. */ |
|
659 |
while (*path != '\0' && *path != '/') { |
|
660 |
if (path > max_path) { |
|
661 |
errno = ENAMETOOLONG; |
|
662 |
return NULL; |
|
663 |
} |
|
664 |
*new_path++ = *path++; |
|
665 |
} |
|
666 |
#ifdef S_IFLNK |
|
667 |
/* Protect against infinite loops. */ |
|
668 |
if (readlinks++ > MAX_READLINKS) { |
|
669 |
errno = ELOOP; |
|
670 |
return NULL; |
|
671 |
} |
|
672 |
/* See if latest pathname component is a symlink. */ |
|
673 |
*new_path = '\0'; |
|
674 |
n = readlink(resolved_path, link_path, MAXPATHLEN - 1); |
|
675 |
if (n < 0) { |
|
676 |
/* EINVAL means the file exists but isn't a symlink. */ |
|
677 |
if (errno != EINVAL) |
|
678 |
return NULL; |
|
679 |
} |
|
680 |
else { |
|
681 |
/* Note: readlink doesn't add the null byte. */ |
|
682 |
link_path[n] = '\0'; |
|
683 |
if (*link_path == '/') |
|
684 |
/* Start over for an absolute symlink. */ |
|
685 |
new_path = resolved_path; |
|
686 |
else |
|
687 |
/* Otherwise back up over this component. */ |
|
688 |
while (*(--new_path) != '/') |
|
689 |
; |
|
690 |
/* Safe sex check. */ |
|
691 |
if (strlen(path) + n >= MAXPATHLEN) { |
|
692 |
errno = ENAMETOOLONG; |
|
693 |
return NULL; |
|
694 |
} |
|
695 |
/* Insert symlink contents into path. */ |
|
696 |
strcat(link_path, path); |
|
697 |
strcpy(copy_path, link_path); |
|
698 |
path = copy_path; |
|
699 |
} |
|
700 |
#endif /* S_IFLNK */ |
|
701 |
*new_path++ = '/'; |
|
702 |
} |
|
703 |
/* Delete trailing slash but don't whomp a lone slash. */ |
|
704 |
if (new_path != resolved_path + 1 && new_path[-1] == '/') |
|
705 |
new_path--; |
|
706 |
/* Make sure it's null terminated. */ |
|
707 |
*new_path = '\0'; |
|
708 |
return resolved_path; |
|
709 |
} |
|
710 |
# define HAS_REALPATH |
|
711 |
#endif /* WANT_REALPATH && not HAS_REALPATH */ |
|
712 |
%} |
|
713 |
! ! |
|
714 |
||
2 | 715 |
!OperatingSystem class methodsFor:'documentation'! |
716 |
||
88 | 717 |
copyright |
718 |
" |
|
719 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
185 | 720 |
All Rights Reserved |
88 | 721 |
|
722 |
This software is furnished under a license and may be used |
|
723 |
only in accordance with the terms of that license and with the |
|
724 |
inclusion of the above copyright notice. This software may not |
|
725 |
be provided or otherwise made available to, or used by, any |
|
726 |
other person. No title to or ownership of the software is |
|
727 |
hereby transferred. |
|
728 |
" |
|
729 |
! |
|
730 |
||
2 | 731 |
documentation |
732 |
" |
|
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
733 |
this class realizes access to most (all ?) required operating system services; |
68 | 734 |
some of it is very specific for unix, so do not depend on |
735 |
things available here in your applications - some may not |
|
370 | 736 |
be found in other OS's or be slightly different ... |
68 | 737 |
|
738 |
(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
|
739 |
from you - in some situations it MAY be interesting to be |
792 | 740 |
able to get down to a select or fork system call easily (at least on Unix systems). |
68 | 741 |
You decide - portability vs. functionality) |
742 |
||
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
743 |
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
|
744 |
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
|
745 |
global variable OperatingSystem. |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
746 |
|
68 | 747 |
Class variables: |
748 |
||
185 | 749 |
HostName <String> remembered hostname |
750 |
||
575
4ad726f27891
oops cached HostName was clobbered by a domainName query
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
751 |
DomainName <String> remembered domainname |
4ad726f27891
oops cached HostName was clobbered by a domainName query
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
752 |
|
185 | 753 |
LastErrorNumber <Integer> the last value of errno |
754 |
||
755 |
LastExecStatus <Integer> the returned exec status after |
|
756 |
the last call of system |
|
757 |
||
758 |
OSSignals <Array> Array of signals to be raised for corresponding |
|
759 |
OperatingSystem signals. |
|
308 | 760 |
|
761 |
ForkFailed <Boolean> set if a fork (or popen) has failed; |
|
762 |
ST/X will avoid doing more forks/popens |
|
763 |
if this flag is set, for a slightly |
|
764 |
smoother operation. |
|
765 |
||
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
766 |
SlowFork <Boolean> if set, fork and popen are avoided; |
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
520
diff
changeset
|
767 |
(more or less obsolete now) |
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
768 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
769 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
770 |
ErrorSignal <Signal> Parentsignal of all OS error signals. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
771 |
not directly raised. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
772 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
773 |
AccessDeniedErrorSignal |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
774 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
775 |
FileNotFoundErrorSignal |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
776 |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
777 |
LocaleInfo <Dictionary> if non nil, that is taken instead of the operating |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
778 |
systems locale definitions (allows for overwriting |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
779 |
these, or provide a compatible info on systems which do |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
780 |
not support locales) |
2 | 781 |
" |
782 |
! ! |
|
783 |
||
95 | 784 |
!OperatingSystem class methodsFor:'initialization'! |
785 |
||
786 |
initialize |
|
185 | 787 |
"initialize the class" |
788 |
||
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
789 |
ObjectMemory addDependent:self. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
790 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
791 |
ErrorSignal isNil ifTrue:[ |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
792 |
ErrorSignal := Object errorSignal newSignalMayProceed:true.. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
793 |
ErrorSignal nameClass:self message:#errorSignal. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
794 |
ErrorSignal notifierString:'OS error encountered'. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
795 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
796 |
AccessDeniedErrorSignal := ErrorSignal newSignalMayProceed:true. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
797 |
AccessDeniedErrorSignal nameClass:self message:#accessDeniedError. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
798 |
AccessDeniedErrorSignal notifierString:'OS access denied'. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
799 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
800 |
FileNotFoundErrorSignal := ErrorSignal newSignalMayProceed:true. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
801 |
FileNotFoundErrorSignal nameClass:self message:#fileNotFoundErrorSignal. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
802 |
FileNotFoundErrorSignal notifierString:'OS file not found'. |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
803 |
] |
95 | 804 |
! |
805 |
||
806 |
update:something |
|
807 |
something == #earlyRestart ifTrue:[ |
|
185 | 808 |
" |
809 |
flush cached data |
|
810 |
" |
|
811 |
HostName := nil. |
|
575
4ad726f27891
oops cached HostName was clobbered by a domainName query
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
812 |
DomainName := nil. |
185 | 813 |
LastErrorNumber := nil. |
814 |
LastExecStatus := nil |
|
95 | 815 |
] |
816 |
! ! |
|
817 |
||
616 | 818 |
!OperatingSystem class methodsFor:'OS signal constants'! |
819 |
||
820 |
sigABRT |
|
821 |
"return the signal number for SIGABRT - 0 if not supported by OS |
|
822 |
(the numeric value is not the same across unix-systems)" |
|
823 |
||
824 |
%{ /* NOCONTEXT */ |
|
825 |
#ifdef SIGABRT |
|
710 | 826 |
RETURN ( _MKSMALLINT(SIGABRT) ); |
616 | 827 |
#else |
710 | 828 |
RETURN ( _MKSMALLINT(0) ); |
616 | 829 |
#endif |
830 |
%} |
|
831 |
! |
|
832 |
||
833 |
sigALRM |
|
834 |
"return the signal number for SIGALRM - 0 if not supported |
|
835 |
(the numeric value is not the same across unix-systems)" |
|
836 |
||
837 |
%{ /* NOCONTEXT */ |
|
838 |
#ifdef SIGALRM |
|
710 | 839 |
RETURN ( _MKSMALLINT(SIGALRM) ); |
616 | 840 |
#else |
710 | 841 |
RETURN ( _MKSMALLINT(0) ); |
616 | 842 |
#endif |
843 |
%} |
|
844 |
! |
|
845 |
||
831 | 846 |
sigBREAK |
847 |
"return the signal number for SIGBREAK - 0 if not supported. |
|
848 |
This is an MSDOS specific signal" |
|
849 |
||
850 |
%{ /* NOCONTEXT */ |
|
851 |
#ifdef SIGBREAK |
|
852 |
RETURN ( _MKSMALLINT(SIGBREAK) ); |
|
853 |
#else |
|
854 |
RETURN ( _MKSMALLINT(0) ); |
|
855 |
#endif |
|
856 |
%} |
|
857 |
! |
|
858 |
||
616 | 859 |
sigBUS |
860 |
"return the signal number for SIGBUS - 0 if not supported |
|
861 |
(the numeric value is not the same across unix-systems)" |
|
862 |
||
863 |
%{ /* NOCONTEXT */ |
|
864 |
#ifdef SIGBUS |
|
710 | 865 |
RETURN ( _MKSMALLINT(SIGBUS) ); |
616 | 866 |
#else |
710 | 867 |
RETURN ( _MKSMALLINT(0) ); |
616 | 868 |
#endif |
869 |
%} |
|
870 |
! |
|
871 |
||
872 |
sigCHLD |
|
873 |
"return the signal number for SIGCHLD - 0 if not supported |
|
874 |
(the numeric value is not the same across unix-systems)" |
|
875 |
||
876 |
%{ /* NOCONTEXT */ |
|
877 |
#if defined(SIGCHLD) |
|
710 | 878 |
RETURN ( _MKSMALLINT(SIGCHLD) ); |
616 | 879 |
#else |
880 |
# if defined(SIGCLD) |
|
710 | 881 |
RETURN ( _MKSMALLINT(SIGCLD) ); |
616 | 882 |
# else |
710 | 883 |
RETURN ( _MKSMALLINT(0) ); |
616 | 884 |
# endif |
885 |
#endif |
|
886 |
%} |
|
887 |
! |
|
888 |
||
889 |
sigCONT |
|
890 |
"return the signal number for SIGCONT - 0 if not supported |
|
891 |
(the numeric value is not the same across unix-systems)" |
|
892 |
||
893 |
%{ /* NOCONTEXT */ |
|
894 |
#if defined(SIGCONT) |
|
710 | 895 |
RETURN ( _MKSMALLINT(SIGCONT) ); |
616 | 896 |
#else |
710 | 897 |
RETURN ( _MKSMALLINT(0) ); |
616 | 898 |
#endif |
899 |
%} |
|
900 |
! |
|
901 |
||
902 |
sigDANGER |
|
903 |
"return the signal number for SIGDANGER - 0 if not supported |
|
904 |
(seems to be an AIX special)" |
|
905 |
||
906 |
%{ /* NOCONTEXT */ |
|
710 | 907 |
#if defined(SIGDANGER) |
908 |
RETURN ( _MKSMALLINT(SIGDANGER) ); |
|
616 | 909 |
#else |
710 | 910 |
RETURN ( _MKSMALLINT(0) ); |
616 | 911 |
#endif |
912 |
%} |
|
913 |
! |
|
914 |
||
915 |
sigEMT |
|
916 |
"return the signal number for SIGEMT - 0 if not supported by OS |
|
917 |
(the numeric value is not the same across unix-systems)" |
|
918 |
||
919 |
%{ /* NOCONTEXT */ |
|
920 |
#ifdef SIGEMT |
|
710 | 921 |
RETURN ( _MKSMALLINT(SIGEMT) ); |
616 | 922 |
#else |
710 | 923 |
RETURN ( _MKSMALLINT(0) ); |
616 | 924 |
#endif |
925 |
%} |
|
926 |
! |
|
927 |
||
928 |
sigFP |
|
929 |
"return the signal number for SIGFP - 0 if not supported by OS |
|
930 |
(the numeric value is not the same across unix-systems)" |
|
931 |
||
932 |
%{ /* NOCONTEXT */ |
|
933 |
#ifdef SIGFPE |
|
710 | 934 |
RETURN ( _MKSMALLINT(SIGFPE) ); |
616 | 935 |
#else |
710 | 936 |
RETURN ( _MKSMALLINT(0) ); |
616 | 937 |
#endif |
938 |
%} |
|
939 |
! |
|
940 |
||
941 |
sigGRANT |
|
942 |
"return the signal number for SIGGRANT - 0 if not supported |
|
943 |
(seems to be an AIX special)" |
|
944 |
||
945 |
%{ /* NOCONTEXT */ |
|
946 |
#if defined(SIGGRANT) |
|
710 | 947 |
RETURN ( _MKSMALLINT(SIGGRANT) ); |
616 | 948 |
#else |
710 | 949 |
RETURN ( _MKSMALLINT(0) ); |
616 | 950 |
#endif |
951 |
%} |
|
952 |
! |
|
953 |
||
954 |
sigHUP |
|
955 |
"return the signal number for SIGHUP |
|
956 |
(the numeric value is not the same across unix-systems)" |
|
957 |
||
958 |
%{ /* NOCONTEXT */ |
|
959 |
#ifdef SIGHUP |
|
710 | 960 |
RETURN ( _MKSMALLINT(SIGHUP) ); |
616 | 961 |
#else |
710 | 962 |
RETURN ( _MKSMALLINT(0) ); |
616 | 963 |
#endif |
964 |
%} |
|
965 |
! |
|
966 |
||
967 |
sigILL |
|
968 |
"return the signal number for SIGILL - 0 if not supported by OS |
|
969 |
(the numeric value is not the same across unix-systems)" |
|
970 |
||
971 |
%{ /* NOCONTEXT */ |
|
972 |
#ifdef SIGILL |
|
710 | 973 |
RETURN ( _MKSMALLINT(SIGILL) ); |
616 | 974 |
#else |
710 | 975 |
RETURN ( _MKSMALLINT(0) ); |
616 | 976 |
#endif |
977 |
%} |
|
978 |
! |
|
979 |
||
980 |
sigINT |
|
981 |
"return the signal number for SIGINT |
|
982 |
(the numeric value is not the same across unix-systems)" |
|
983 |
||
984 |
%{ /* NOCONTEXT */ |
|
985 |
#ifdef SIGINT |
|
710 | 986 |
RETURN ( _MKSMALLINT(SIGINT) ); |
616 | 987 |
#else |
710 | 988 |
RETURN ( _MKSMALLINT(0) ); |
616 | 989 |
#endif |
990 |
%} |
|
991 |
! |
|
992 |
||
993 |
sigIO |
|
994 |
"return the signal number for SIGIO - 0 if not supported |
|
995 |
(the numeric value is not the same across unix-systems)" |
|
996 |
||
997 |
%{ /* NOCONTEXT */ |
|
998 |
#if defined(SIGIO) |
|
710 | 999 |
RETURN ( _MKSMALLINT(SIGIO) ); |
616 | 1000 |
#else |
710 | 1001 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1002 |
#endif |
1003 |
%} |
|
1004 |
! |
|
1005 |
||
1006 |
sigIOT |
|
1007 |
"return the signal number for SIGIOT - 0 if not supported by OS |
|
1008 |
(the numeric value is not the same across unix-systems)" |
|
1009 |
||
1010 |
%{ /* NOCONTEXT */ |
|
1011 |
#ifdef SIGIOT |
|
710 | 1012 |
RETURN ( _MKSMALLINT(SIGIOT) ); |
616 | 1013 |
#else |
710 | 1014 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1015 |
#endif |
1016 |
%} |
|
1017 |
! |
|
1018 |
||
1019 |
sigKILL |
|
1020 |
"return the signal number for SIGKILL |
|
1021 |
(the numeric value is not the same across unix-systems)" |
|
1022 |
||
1023 |
%{ /* NOCONTEXT */ |
|
1024 |
#ifdef SIGKILL |
|
710 | 1025 |
RETURN ( _MKSMALLINT(SIGKILL) ); |
616 | 1026 |
#else |
710 | 1027 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1028 |
#endif |
1029 |
%} |
|
1030 |
! |
|
1031 |
||
1032 |
sigLOST |
|
1033 |
"return the signal number for SIGLOST - 0 if not supported |
|
1034 |
(the numeric value is not the same across unix-systems)" |
|
1035 |
||
1036 |
%{ /* NOCONTEXT */ |
|
1037 |
#if defined(SIGLOST) |
|
710 | 1038 |
RETURN ( _MKSMALLINT(SIGLOST) ); |
616 | 1039 |
#else |
710 | 1040 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1041 |
#endif |
1042 |
%} |
|
1043 |
! |
|
1044 |
||
1045 |
sigMIGRATE |
|
1046 |
"return the signal number for SIGMIGRATE - 0 if not supported |
|
1047 |
(seems to be an AIX special)" |
|
1048 |
||
1049 |
%{ /* NOCONTEXT */ |
|
1050 |
#if defined(SIGMIGRATE) |
|
710 | 1051 |
RETURN ( _MKSMALLINT(SIGMIGRATE) ); |
616 | 1052 |
#else |
710 | 1053 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1054 |
#endif |
1055 |
%} |
|
1056 |
! |
|
1057 |
||
1058 |
sigMSG |
|
1059 |
"return the signal number for SIGMSG - 0 if not supported |
|
1060 |
(seems to be an AIX special)" |
|
1061 |
||
1062 |
%{ /* NOCONTEXT */ |
|
1063 |
#if defined(SIGMSG) |
|
710 | 1064 |
RETURN ( _MKSMALLINT(SIGMSG) ); |
616 | 1065 |
#else |
710 | 1066 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1067 |
#endif |
1068 |
%} |
|
1069 |
! |
|
1070 |
||
1071 |
sigPIPE |
|
1072 |
"return the signal number for SIGPIPE - 0 if not supported |
|
1073 |
(the numeric value is not the same across unix-systems)" |
|
1074 |
||
1075 |
%{ /* NOCONTEXT */ |
|
1076 |
#ifdef SIGPIPE |
|
710 | 1077 |
RETURN ( _MKSMALLINT(SIGPIPE) ); |
616 | 1078 |
#else |
710 | 1079 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1080 |
#endif |
1081 |
%} |
|
1082 |
! |
|
1083 |
||
1084 |
sigPOLL |
|
1085 |
"return the signal number for SIGPOLL - 0 if not supported |
|
1086 |
(the numeric value is not the same across unix-systems)" |
|
1087 |
||
1088 |
%{ /* NOCONTEXT */ |
|
1089 |
#if defined(SIGPOLL) |
|
710 | 1090 |
RETURN ( _MKSMALLINT(SIGPOLL) ); |
616 | 1091 |
#else |
710 | 1092 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1093 |
#endif |
1094 |
%} |
|
1095 |
! |
|
1096 |
||
1097 |
sigPRE |
|
1098 |
"return the signal number for SIGPRE - 0 if not supported |
|
1099 |
(seems to be an AIX special)" |
|
1100 |
||
1101 |
%{ /* NOCONTEXT */ |
|
1102 |
#if defined(SIGPRE) |
|
710 | 1103 |
RETURN ( _MKSMALLINT(SIGPRE) ); |
616 | 1104 |
#else |
710 | 1105 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1106 |
#endif |
1107 |
%} |
|
1108 |
! |
|
1109 |
||
1110 |
sigPROF |
|
1111 |
"return the signal number for SIGPROF - 0 if not supported |
|
1112 |
(the numeric value is not the same across unix-systems)" |
|
1113 |
||
1114 |
%{ /* NOCONTEXT */ |
|
1115 |
#if defined(SIGPROF) |
|
710 | 1116 |
RETURN ( _MKSMALLINT(SIGPROF) ); |
616 | 1117 |
#else |
710 | 1118 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1119 |
#endif |
1120 |
%} |
|
1121 |
! |
|
1122 |
||
1123 |
sigPWR |
|
1124 |
"return the signal number for SIGPWR - 0 if not supported |
|
1125 |
(not available on all systems)" |
|
1126 |
||
1127 |
%{ /* NOCONTEXT */ |
|
1128 |
#if defined(SIGPWR) |
|
710 | 1129 |
RETURN ( _MKSMALLINT(SIGPWR) ); |
616 | 1130 |
#else |
710 | 1131 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1132 |
#endif |
1133 |
%} |
|
1134 |
! |
|
1135 |
||
1136 |
sigQUIT |
|
1137 |
"return the signal number for SIGQUIT |
|
1138 |
(the numeric value is not the same across unix-systems)" |
|
1139 |
||
1140 |
%{ /* NOCONTEXT */ |
|
1141 |
#ifdef SIGQUIT |
|
710 | 1142 |
RETURN ( _MKSMALLINT(SIGQUIT) ); |
616 | 1143 |
#else |
710 | 1144 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1145 |
#endif |
1146 |
%} |
|
1147 |
! |
|
1148 |
||
1149 |
sigRETRACT |
|
1150 |
"return the signal number for SIGRETRACT - 0 if not supported |
|
1151 |
(seems to be an AIX special)" |
|
1152 |
||
1153 |
%{ /* NOCONTEXT */ |
|
1154 |
#if defined(SIGRETRACT) |
|
710 | 1155 |
RETURN ( _MKSMALLINT(SIGRETRACT) ); |
616 | 1156 |
#else |
710 | 1157 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1158 |
#endif |
1159 |
%} |
|
1160 |
! |
|
1161 |
||
1162 |
sigSAK |
|
1163 |
"return the signal number for SIGSAK - 0 if not supported |
|
1164 |
(seems to be an AIX special)" |
|
1165 |
||
1166 |
%{ /* NOCONTEXT */ |
|
1167 |
#if defined(SIGSAK) |
|
710 | 1168 |
RETURN ( _MKSMALLINT(SIGSAK) ); |
616 | 1169 |
#else |
710 | 1170 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1171 |
#endif |
1172 |
%} |
|
1173 |
! |
|
1174 |
||
1175 |
sigSEGV |
|
1176 |
"return the signal number for SIGSEGV - 0 if not supported |
|
1177 |
(the numeric value is not the same across unix-systems)" |
|
1178 |
||
1179 |
%{ /* NOCONTEXT */ |
|
1180 |
#ifdef SIGSEGV |
|
710 | 1181 |
RETURN ( _MKSMALLINT(SIGSEGV) ); |
616 | 1182 |
#else |
710 | 1183 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1184 |
#endif |
1185 |
%} |
|
1186 |
! |
|
1187 |
||
1188 |
sigSOUND |
|
1189 |
"return the signal number for SIGSOUND - 0 if not supported |
|
1190 |
(seems to be an AIX special)" |
|
1191 |
||
1192 |
%{ /* NOCONTEXT */ |
|
1193 |
#if defined(SIGSOUND) |
|
710 | 1194 |
RETURN ( _MKSMALLINT(SIGSOUND) ); |
616 | 1195 |
#else |
710 | 1196 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1197 |
#endif |
1198 |
%} |
|
1199 |
! |
|
1200 |
||
1201 |
sigSTOP |
|
1202 |
"return the signal number for SIGSTOP - 0 if not supported |
|
1203 |
(the numeric value is not the same across unix-systems)" |
|
1204 |
||
1205 |
%{ /* NOCONTEXT */ |
|
1206 |
#if defined(SIGSTOP) |
|
710 | 1207 |
RETURN ( _MKSMALLINT(SIGSTOP) ); |
616 | 1208 |
#else |
710 | 1209 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1210 |
#endif |
1211 |
%} |
|
1212 |
! |
|
1213 |
||
1214 |
sigSYS |
|
1215 |
"return the signal number for SIGSYS - 0 if not supported |
|
1216 |
(the numeric value is not the same across unix-systems)" |
|
1217 |
||
1218 |
%{ /* NOCONTEXT */ |
|
1219 |
#ifdef SIGSYS |
|
710 | 1220 |
RETURN ( _MKSMALLINT(SIGSYS) ); |
616 | 1221 |
#else |
710 | 1222 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1223 |
#endif |
1224 |
%} |
|
1225 |
! |
|
1226 |
||
1227 |
sigTERM |
|
1228 |
"return the signal number for SIGTERM - 0 if not supported |
|
1229 |
(the numeric value is not the same across unix-systems)" |
|
1230 |
||
1231 |
%{ /* NOCONTEXT */ |
|
1232 |
#ifdef SIGTERM |
|
710 | 1233 |
RETURN ( _MKSMALLINT(SIGTERM) ); |
616 | 1234 |
#else |
710 | 1235 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1236 |
#endif |
1237 |
%} |
|
1238 |
! |
|
1239 |
||
1240 |
sigTRAP |
|
1241 |
"return the signal number for SIGTRAP - 0 if not supported by OS |
|
1242 |
(the numeric value is not the same across unix-systems)" |
|
1243 |
||
1244 |
%{ /* NOCONTEXT */ |
|
1245 |
#ifdef SIGTRAP |
|
710 | 1246 |
RETURN ( _MKSMALLINT(SIGTRAP) ); |
616 | 1247 |
#else |
710 | 1248 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1249 |
#endif |
1250 |
%} |
|
1251 |
! |
|
1252 |
||
1253 |
sigTSTP |
|
1254 |
"return the signal number for SIGTSTP - 0 if not supported |
|
1255 |
(the numeric value is not the same across unix-systems)" |
|
1256 |
||
1257 |
%{ /* NOCONTEXT */ |
|
1258 |
#if defined(SIGTSTP) |
|
710 | 1259 |
RETURN ( _MKSMALLINT(SIGTSTP) ); |
616 | 1260 |
#else |
710 | 1261 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1262 |
#endif |
1263 |
%} |
|
1264 |
! |
|
1265 |
||
1266 |
sigTTIN |
|
1267 |
"return the signal number for SIGTTIN - 0 if not supported |
|
1268 |
(the numeric value is not the same across unix-systems)" |
|
1269 |
||
1270 |
%{ /* NOCONTEXT */ |
|
1271 |
#if defined(SIGTTIN) |
|
710 | 1272 |
RETURN ( _MKSMALLINT(SIGTTIN) ); |
616 | 1273 |
#else |
710 | 1274 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1275 |
#endif |
1276 |
%} |
|
1277 |
! |
|
1278 |
||
1279 |
sigTTOU |
|
1280 |
"return the signal number for SIGTTOU - 0 if not supported |
|
1281 |
(the numeric value is not the same across unix-systems)" |
|
1282 |
||
1283 |
%{ /* NOCONTEXT */ |
|
1284 |
#if defined(SIGTTOU) |
|
710 | 1285 |
RETURN ( _MKSMALLINT(SIGTTOU) ); |
616 | 1286 |
#else |
710 | 1287 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1288 |
#endif |
1289 |
%} |
|
1290 |
! |
|
1291 |
||
1292 |
sigURG |
|
1293 |
"return the signal number for SIGURG - 0 if not supported |
|
1294 |
(the numeric value is not the same across unix-systems)" |
|
1295 |
||
1296 |
%{ /* NOCONTEXT */ |
|
1297 |
#if defined(SIGURG) |
|
710 | 1298 |
RETURN ( _MKSMALLINT(SIGURG) ); |
616 | 1299 |
#else |
710 | 1300 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1301 |
#endif |
1302 |
%} |
|
1303 |
! |
|
1304 |
||
1305 |
sigUSR1 |
|
1306 |
"return the signal number for SIGUSR1 - 0 if not supported |
|
1307 |
(the numeric value is not the same across unix-systems)" |
|
1308 |
||
1309 |
%{ /* NOCONTEXT */ |
|
1310 |
#if defined(SIGUSR1) |
|
710 | 1311 |
RETURN ( _MKSMALLINT(SIGUSR1) ); |
616 | 1312 |
#else |
710 | 1313 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1314 |
#endif |
1315 |
%} |
|
1316 |
! |
|
1317 |
||
1318 |
sigUSR2 |
|
1319 |
"return the signal number for SIGUSR2 - 0 if not supported |
|
1320 |
(the numeric value is not the same across unix-systems)" |
|
1321 |
||
1322 |
%{ /* NOCONTEXT */ |
|
1323 |
#if defined(SIGUSR2) |
|
710 | 1324 |
RETURN ( _MKSMALLINT(SIGUSR2) ); |
616 | 1325 |
#else |
710 | 1326 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1327 |
#endif |
1328 |
%} |
|
1329 |
! |
|
1330 |
||
1331 |
sigVTALRM |
|
1332 |
"return the signal number for SIGVTALRM - 0 if not supported |
|
1333 |
(the numeric value is not the same across unix-systems)" |
|
1334 |
||
1335 |
%{ /* NOCONTEXT */ |
|
1336 |
#if defined(SIGVTALRM) |
|
710 | 1337 |
RETURN ( _MKSMALLINT(SIGVTALRM) ); |
616 | 1338 |
#else |
710 | 1339 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1340 |
#endif |
1341 |
%} |
|
1342 |
! |
|
1343 |
||
1344 |
sigWINCH |
|
1345 |
"return the signal number for SIGWINCH - 0 if not supported |
|
1346 |
(the numeric value is not the same across unix-systems)" |
|
1347 |
||
1348 |
%{ /* NOCONTEXT */ |
|
1349 |
#if defined(SIGWINCH) |
|
710 | 1350 |
RETURN ( _MKSMALLINT(SIGWINCH) ); |
616 | 1351 |
#else |
710 | 1352 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1353 |
#endif |
1354 |
%} |
|
1355 |
! |
|
1356 |
||
1357 |
sigXCPU |
|
1358 |
"return the signal number for SIGXCPU - 0 if not supported |
|
1359 |
(the numeric value is not the same across unix-systems)" |
|
1360 |
||
1361 |
%{ /* NOCONTEXT */ |
|
1362 |
#if defined(SIGXCPU) |
|
710 | 1363 |
RETURN ( _MKSMALLINT(SIGXCPU) ); |
616 | 1364 |
#else |
710 | 1365 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1366 |
#endif |
1367 |
%} |
|
1368 |
! |
|
1369 |
||
1370 |
sigXFSZ |
|
1371 |
"return the signal number for SIGXFSZ - 0 if not supported |
|
1372 |
(the numeric value is not the same across unix-systems)" |
|
1373 |
||
1374 |
%{ /* NOCONTEXT */ |
|
1375 |
#if defined(SIGXFSZ) |
|
710 | 1376 |
RETURN ( _MKSMALLINT(SIGXFSZ) ); |
616 | 1377 |
#else |
710 | 1378 |
RETURN ( _MKSMALLINT(0) ); |
616 | 1379 |
#endif |
1380 |
%} |
|
1381 |
! ! |
|
1382 |
||
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1383 |
!OperatingSystem class methodsFor:'Signal constants'! |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1384 |
|
616 | 1385 |
accessDeniedErrorSignal |
1386 |
"return the signal raised when a (file-) access is denied." |
|
1387 |
||
1388 |
^ AccessDeniedErrorSignal |
|
1389 |
! |
|
1390 |
||
540
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1391 |
errorSignal |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1392 |
"return the OS signals parent signal." |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1393 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1394 |
^ ErrorSignal |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1395 |
! |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1396 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1397 |
fileNotFoundErrorSignal |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1398 |
"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
|
1399 |
|
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1400 |
^ FileNotFoundErrorSignal |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1401 |
! ! |
c34cd0a2fd5f
OS signals added (more to come)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
1402 |
|
1 | 1403 |
!OperatingSystem class methodsFor:'error messages'! |
1404 |
||
85 | 1405 |
currentErrorNumber |
68 | 1406 |
"returns the OS's last error nr (i.e. the value of errno). |
1407 |
Notice, that the value of this flag is only valid immediately |
|
1408 |
after the error occurred - it gets updated with every other |
|
85 | 1409 |
request to the OS. |
1410 |
Use lastErrorNumber - currentErrorNumber is invalidated by |
|
1411 |
many, many internal calls." |
|
68 | 1412 |
|
1413 |
%{ /* NOCONTEXT */ |
|
1414 |
||
1415 |
RETURN ( _MKSMALLINT(errno) ); |
|
1416 |
%} |
|
1417 |
" |
|
85 | 1418 |
OperatingSystem currentErrorNumber |
1419 |
" |
|
1420 |
! |
|
1421 |
||
1 | 1422 |
errorTextForNumber:errNr |
1423 |
"return a message string from a unix errorNumber |
|
68 | 1424 |
(as returned by a system call). |
1425 |
Should be replaced by a resource lookup." |
|
1 | 1426 |
|
77 | 1427 |
%{ |
1428 |
/* claus: |
|
1429 |
* I made this some primitive code, since errnos are not |
|
1430 |
* standard across unixes |
|
1431 |
*/ |
|
1432 |
char *msg = "unknown error"; |
|
1433 |
char buffer[50]; |
|
1434 |
||
252 | 1435 |
if (__isSmallInteger(errNr)) { |
185 | 1436 |
switch (_intVal(errNr)) { |
1437 |
/* |
|
1438 |
* POSIX errnos - these should be defined |
|
1439 |
*/ |
|
443 | 1440 |
#ifdef EPERM |
185 | 1441 |
case EPERM: |
1442 |
msg = "Operation not permitted"; |
|
1443 |
break; |
|
443 | 1444 |
#endif |
1445 |
#ifdef ENOENT |
|
185 | 1446 |
case ENOENT: |
1447 |
msg = "No such file or directory"; |
|
1448 |
break; |
|
443 | 1449 |
#endif |
1450 |
#ifdef ESRCH |
|
185 | 1451 |
case ESRCH: |
1452 |
msg = "No such process"; |
|
1453 |
break; |
|
443 | 1454 |
#endif |
1455 |
#ifdef EINTR |
|
185 | 1456 |
case EINTR: |
1457 |
msg = "Interrupted system call"; |
|
1458 |
break; |
|
443 | 1459 |
#endif |
1460 |
#ifdef EIO |
|
185 | 1461 |
case EIO: |
1462 |
msg = "I/O error"; |
|
1463 |
break; |
|
443 | 1464 |
#endif |
1465 |
#ifdef ENXIO |
|
185 | 1466 |
case ENXIO: |
1467 |
msg = "No such device or address"; |
|
1468 |
break; |
|
443 | 1469 |
#endif |
1470 |
#ifdef E2BIG |
|
185 | 1471 |
case E2BIG: |
1472 |
msg = "Arg list too long"; |
|
1473 |
break; |
|
443 | 1474 |
#endif |
1475 |
#ifdef ENOEXEC |
|
185 | 1476 |
case ENOEXEC: |
1477 |
msg = "Exec format error"; |
|
1478 |
break; |
|
443 | 1479 |
#endif |
1480 |
#ifdef EBADF |
|
185 | 1481 |
case EBADF: |
1482 |
msg = "Bad file number"; |
|
1483 |
break; |
|
443 | 1484 |
#endif |
1485 |
#ifdef ECHILD |
|
185 | 1486 |
case ECHILD: |
1487 |
msg = "No child processes"; |
|
1488 |
break; |
|
443 | 1489 |
#endif |
77 | 1490 |
#if !defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN) |
185 | 1491 |
case EAGAIN: |
1492 |
msg = "Try again"; |
|
1493 |
break; |
|
77 | 1494 |
#endif |
443 | 1495 |
#ifdef ENOMEM |
185 | 1496 |
case ENOMEM: |
1497 |
msg = "Out of memory"; |
|
1498 |
break; |
|
443 | 1499 |
#endif |
1500 |
#ifdef EACCES |
|
185 | 1501 |
case EACCES: |
1502 |
msg = "Permission denied"; |
|
1503 |
break; |
|
443 | 1504 |
#endif |
1505 |
#ifdef EFAULT |
|
185 | 1506 |
case EFAULT: |
1507 |
msg = "Bad address"; |
|
1508 |
break; |
|
443 | 1509 |
#endif |
1510 |
#ifdef EBUSY |
|
185 | 1511 |
case EBUSY: |
1512 |
msg = "Device or resource busy"; |
|
1513 |
break; |
|
443 | 1514 |
#endif |
1515 |
#ifdef EEXIST |
|
185 | 1516 |
case EEXIST: |
1517 |
msg = "File exists"; |
|
1518 |
break; |
|
443 | 1519 |
#endif |
1520 |
#ifdef EXDEV |
|
185 | 1521 |
case EXDEV: |
1522 |
msg = "Cross-device link"; |
|
1523 |
break; |
|
443 | 1524 |
#endif |
1525 |
#ifdef ENODEV |
|
185 | 1526 |
case ENODEV: |
1527 |
msg = "No such device"; |
|
1528 |
break; |
|
443 | 1529 |
#endif |
1530 |
#ifdef ENOTDIR |
|
185 | 1531 |
case ENOTDIR: |
1532 |
msg = "Not a directory"; |
|
1533 |
break; |
|
443 | 1534 |
#endif |
1535 |
#ifdef EISDIR |
|
185 | 1536 |
case EISDIR: |
1537 |
msg = "Is a directory"; |
|
1538 |
break; |
|
443 | 1539 |
#endif |
1540 |
#ifdef EINVAL |
|
185 | 1541 |
case EINVAL: |
1542 |
msg = "Invalid argument"; |
|
1543 |
break; |
|
443 | 1544 |
#endif |
1545 |
#ifdef ENFILE |
|
185 | 1546 |
case ENFILE: |
1547 |
msg = "File table overflow"; |
|
1548 |
break; |
|
443 | 1549 |
#endif |
1550 |
#ifdef EMFILE |
|
185 | 1551 |
case EMFILE: |
1552 |
msg = "Too many open files"; |
|
1553 |
break; |
|
443 | 1554 |
#endif |
1555 |
#ifdef ENOTTY |
|
185 | 1556 |
case ENOTTY: |
1557 |
msg = "Not a typewriter"; |
|
1558 |
break; |
|
443 | 1559 |
#endif |
1560 |
#ifdef EFBIG |
|
185 | 1561 |
case EFBIG: |
1562 |
msg = "File too large"; |
|
1563 |
break; |
|
443 | 1564 |
#endif |
1565 |
#ifdef ENOSPC |
|
185 | 1566 |
case ENOSPC: |
1567 |
msg = "No space left on device"; |
|
1568 |
break; |
|
443 | 1569 |
#endif |
1570 |
#ifdef ESPIPE |
|
185 | 1571 |
case ESPIPE: |
1572 |
msg = "Illegal seek"; |
|
1573 |
break; |
|
443 | 1574 |
#endif |
1575 |
#ifdef EROFS |
|
185 | 1576 |
case EROFS: |
1577 |
msg = "Read-only file system"; |
|
1578 |
break; |
|
443 | 1579 |
#endif |
1580 |
#ifdef EMLINK |
|
185 | 1581 |
case EMLINK: |
1582 |
msg = "Too many links"; |
|
1583 |
break; |
|
443 | 1584 |
#endif |
1585 |
#ifdef EPIPE |
|
185 | 1586 |
case EPIPE: |
1587 |
msg = "Broken pipe"; |
|
1588 |
break; |
|
443 | 1589 |
#endif |
1590 |
#ifdef EDOM |
|
185 | 1591 |
case EDOM: |
1592 |
msg = "Math argument out of domain"; |
|
1593 |
break; |
|
443 | 1594 |
#endif |
1595 |
#ifdef ERANGE |
|
185 | 1596 |
case ERANGE: |
1597 |
msg = "Math result not representable"; |
|
1598 |
break; |
|
443 | 1599 |
#endif |
77 | 1600 |
#ifdef EDEADLK |
308 | 1601 |
# if EDEADLK != EWOULDBLOCK |
185 | 1602 |
case EDEADLK: |
1603 |
msg = "Resource deadlock would occur"; |
|
1604 |
break; |
|
308 | 1605 |
# endif |
77 | 1606 |
#endif |
1607 |
#ifdef ENAMETOOLONG |
|
185 | 1608 |
case ENAMETOOLONG: |
1609 |
msg = "File name too long"; |
|
1610 |
break; |
|
77 | 1611 |
#endif |
1612 |
#ifdef ENOLCK |
|
185 | 1613 |
case ENOLCK: |
1614 |
msg = "No record locks available"; |
|
1615 |
break; |
|
77 | 1616 |
#endif |
1617 |
#ifdef ENOSYS |
|
185 | 1618 |
case ENOSYS: |
1619 |
msg = "Function not implemented"; |
|
1620 |
break; |
|
77 | 1621 |
#endif |
359 | 1622 |
#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST) |
185 | 1623 |
case ENOTEMPTY: |
1624 |
msg = "Directory not empty"; |
|
1625 |
break; |
|
77 | 1626 |
#endif |
1627 |
#ifdef EILSEQ |
|
185 | 1628 |
case EILSEQ: |
1629 |
msg = "Illegal byte sequence"; |
|
1630 |
break; |
|
77 | 1631 |
#endif |
185 | 1632 |
/* |
1633 |
* XPG3 errnos - defined on most systems |
|
1634 |
*/ |
|
77 | 1635 |
#ifdef ENOTBLK |
185 | 1636 |
case ENOTBLK: |
1637 |
msg = "Block device required"; |
|
1638 |
break; |
|
77 | 1639 |
#endif |
1640 |
#ifdef ETXTBSY |
|
185 | 1641 |
case ETXTBSY: |
1642 |
msg = "Text file busy"; |
|
1643 |
break; |
|
77 | 1644 |
#endif |
185 | 1645 |
/* |
1646 |
* some others |
|
1647 |
*/ |
|
77 | 1648 |
#ifdef EWOULDBLOCK |
185 | 1649 |
case EWOULDBLOCK: |
1650 |
msg = "Operation would block"; |
|
1651 |
break; |
|
77 | 1652 |
#endif |
1653 |
#ifdef ENOMSG |
|
185 | 1654 |
case ENOMSG: |
1655 |
msg = "No message of desired type"; |
|
1656 |
break; |
|
77 | 1657 |
#endif |
1658 |
#ifdef ELOOP |
|
185 | 1659 |
case ELOOP: |
1660 |
msg = "Too many levels of symbolic links"; |
|
1661 |
break; |
|
77 | 1662 |
#endif |
1663 |
||
185 | 1664 |
/* |
1665 |
* some stream errors |
|
1666 |
*/ |
|
77 | 1667 |
#ifdef ETIME |
185 | 1668 |
case ETIME: |
1669 |
msg = "Timer expired"; |
|
1670 |
break; |
|
77 | 1671 |
#endif |
1672 |
#ifdef ENOSR |
|
185 | 1673 |
case ENOSR: |
1674 |
msg = "Out of streams resources"; |
|
1675 |
break; |
|
77 | 1676 |
#endif |
1677 |
#ifdef ENOSTR |
|
185 | 1678 |
case ENOSTR: |
1679 |
msg = "Device not a stream"; |
|
1680 |
break; |
|
77 | 1681 |
#endif |
1682 |
#ifdef ECOMM |
|
185 | 1683 |
case ECOMM: |
1684 |
msg = "Communication error on send"; |
|
1685 |
break; |
|
77 | 1686 |
#endif |
1687 |
#ifdef EPROTO |
|
185 | 1688 |
case EPROTO: |
1689 |
msg = "Protocol error"; |
|
1690 |
break; |
|
77 | 1691 |
#endif |
185 | 1692 |
/* |
1693 |
* nfs errors |
|
1694 |
*/ |
|
77 | 1695 |
#ifdef ESTALE |
185 | 1696 |
case ESTALE: |
1697 |
msg = "Stale NFS file handle"; |
|
1698 |
break; |
|
77 | 1699 |
#endif |
1700 |
#ifdef EREMOTE |
|
185 | 1701 |
case EREMOTE: |
1702 |
msg = "Too many levels of remote in path"; |
|
1703 |
break; |
|
77 | 1704 |
#endif |
185 | 1705 |
/* |
1706 |
* some networking errors |
|
1707 |
*/ |
|
77 | 1708 |
#ifdef EINPROGRESS |
185 | 1709 |
case EINPROGRESS: |
1710 |
msg = "Operation now in progress"; |
|
1711 |
break; |
|
77 | 1712 |
#endif |
1713 |
#ifdef EALREADY |
|
185 | 1714 |
case EALREADY: |
1715 |
msg = "Operation already in progress"; |
|
1716 |
break; |
|
77 | 1717 |
#endif |
1718 |
#ifdef ENOTSOCK |
|
185 | 1719 |
case ENOTSOCK: |
1720 |
msg = "Socket operation on non-socket"; |
|
1721 |
break; |
|
77 | 1722 |
#endif |
1723 |
#ifdef EDESTADDRREQ |
|
185 | 1724 |
case EDESTADDRREQ: |
1725 |
msg = "Destination address required"; |
|
1726 |
break; |
|
77 | 1727 |
#endif |
1728 |
#ifdef EMSGSIZE |
|
185 | 1729 |
case EMSGSIZE: |
1730 |
msg = "Message too long"; |
|
1731 |
break; |
|
77 | 1732 |
#endif |
1733 |
#ifdef EPROTOTYPE |
|
185 | 1734 |
case EPROTOTYPE: |
1735 |
msg = "Protocol wrong type for socket"; |
|
1736 |
break; |
|
77 | 1737 |
#endif |
1738 |
#ifdef ENOPROTOOPT |
|
185 | 1739 |
case ENOPROTOOPT: |
1740 |
msg = "Protocol not available"; |
|
1741 |
break; |
|
77 | 1742 |
#endif |
1743 |
#ifdef EPROTONOSUPPORT |
|
185 | 1744 |
case EPROTONOSUPPORT: |
1745 |
msg = "Protocol not supported"; |
|
1746 |
break; |
|
77 | 1747 |
#endif |
1748 |
#ifdef ESOCKTNOSUPPORT |
|
185 | 1749 |
case ESOCKTNOSUPPORT: |
1750 |
msg = "Socket type not supported"; |
|
1751 |
break; |
|
77 | 1752 |
#endif |
1753 |
#ifdef EOPNOTSUPP |
|
185 | 1754 |
case EOPNOTSUPP: |
1755 |
msg = "Operation not supported on socket"; |
|
1756 |
break; |
|
77 | 1757 |
#endif |
1758 |
#ifdef EPFNOSUPPORT |
|
185 | 1759 |
case EPFNOSUPPORT: |
1760 |
msg = "Protocol family not supported"; |
|
1761 |
break; |
|
77 | 1762 |
#endif |
1763 |
#ifdef EAFNOSUPPORT |
|
185 | 1764 |
case EAFNOSUPPORT: |
1765 |
msg = "Address family not supported by protocol family"; |
|
1766 |
break; |
|
77 | 1767 |
#endif |
1768 |
#ifdef EADDRINUSE |
|
185 | 1769 |
case EADDRINUSE: |
1770 |
msg = "Address already in use"; |
|
1771 |
break; |
|
77 | 1772 |
#endif |
1773 |
#ifdef EADDRNOTAVAIL |
|
185 | 1774 |
case EADDRNOTAVAIL: |
1775 |
msg = "Can\'t assign requested address"; |
|
1776 |
break; |
|
77 | 1777 |
#endif |
1778 |
#ifdef ETIMEDOUT |
|
185 | 1779 |
case ETIMEDOUT: |
1780 |
msg = "Connection timed out"; |
|
1781 |
break; |
|
77 | 1782 |
#endif |
1783 |
#ifdef ECONNREFUSED |
|
185 | 1784 |
case ECONNREFUSED: |
1785 |
msg = "Connection refused"; |
|
1786 |
break; |
|
77 | 1787 |
#endif |
362 | 1788 |
#ifdef ENETDOWN |
1789 |
case ENETDOWN: |
|
1790 |
msg = "Network is down"; |
|
1791 |
break; |
|
1792 |
#endif |
|
1793 |
#ifdef ENETUNREACH |
|
1794 |
case ENETUNREACH: |
|
1795 |
msg = "Network is unreachable"; |
|
1796 |
break; |
|
1797 |
#endif |
|
1798 |
#ifdef ENETRESET |
|
1799 |
case ENETRESET: |
|
1800 |
msg = "Network dropped conn due to reset"; |
|
1801 |
break; |
|
1802 |
#endif |
|
1803 |
#ifdef ECONNABORTED |
|
1804 |
case ECONNABORTED: |
|
1805 |
msg = "Software caused connection abort"; |
|
1806 |
break; |
|
1807 |
#endif |
|
1808 |
#ifdef ECONNRESET |
|
1809 |
case ECONNRESET: |
|
1810 |
msg = "Connection reset by peer"; |
|
1811 |
break; |
|
1812 |
#endif |
|
1813 |
#ifdef EISCONN |
|
1814 |
case EISCONN: |
|
1815 |
msg = "Socket is already connected"; |
|
1816 |
break; |
|
1817 |
#endif |
|
1818 |
#ifdef ENOTCONN |
|
1819 |
case ENOTCONN: |
|
1820 |
msg = "Socket is not connected"; |
|
1821 |
break; |
|
1822 |
#endif |
|
1823 |
#ifdef ESHUTDOWN |
|
1824 |
case ESHUTDOWN: |
|
1825 |
msg = "Can't send after socket shutdown"; |
|
1826 |
break; |
|
1827 |
#endif |
|
1828 |
#ifdef EHOSTDOWN |
|
1829 |
case EHOSTDOWN: |
|
1830 |
msg = "Host is down"; |
|
1831 |
break; |
|
1832 |
#endif |
|
1833 |
#ifdef EHOSTUNREACH |
|
1834 |
case EHOSTUNREACH: |
|
1835 |
msg = "No route to host"; |
|
1836 |
break; |
|
1837 |
#endif |
|
1838 |
||
185 | 1839 |
default: |
368 | 1840 |
{ |
809
5eef87c2907b
e convenient macro for register saving (sparc only)
Claus Gittinger <cg@exept.de>
parents:
805
diff
changeset
|
1841 |
__BEGIN_PROTECT_REGISTERS__ |
368 | 1842 |
sprintf(buffer, "ErrorNr: %d", _intVal(errNr)); |
809
5eef87c2907b
e convenient macro for register saving (sparc only)
Claus Gittinger <cg@exept.de>
parents:
805
diff
changeset
|
1843 |
__END_PROTECT_REGISTERS__ |
368 | 1844 |
} |
185 | 1845 |
msg = buffer; |
1846 |
break; |
|
1847 |
} |
|
77 | 1848 |
} |
830 | 1849 |
RETURN (__MKSTRING(msg COMMA_CON)); |
77 | 1850 |
%} |
616 | 1851 |
! |
1852 |
||
1853 |
lastErrorNumber |
|
1854 |
"return the last error number" |
|
1855 |
||
1856 |
^ LastErrorNumber |
|
1857 |
||
1858 |
" |
|
1859 |
OperatingSystem lastErrorNumber |
|
1860 |
" |
|
1861 |
! |
|
1862 |
||
1863 |
lastErrorString |
|
1864 |
"return a message string describing the last error" |
|
1865 |
||
1866 |
^ self errorTextForNumber:LastErrorNumber |
|
1867 |
||
1868 |
" |
|
1869 |
OperatingSystem lastErrorString |
|
1870 |
" |
|
1871 |
! |
|
1872 |
||
1873 |
lastExecStatus |
|
1874 |
"return the last execution status" |
|
1875 |
||
1876 |
^ LastExecStatus |
|
1877 |
||
1878 |
" |
|
1879 |
OperatingSystem lastExecStatus |
|
1880 |
" |
|
1 | 1881 |
! ! |
1882 |
||
616 | 1883 |
!OperatingSystem class methodsFor:'executing commands'! |
1884 |
||
1885 |
canExecuteCommand:aCommandString |
|
1886 |
"return true, if the OS can execute aCommand." |
|
1887 |
||
1888 |
|cmd| |
|
1889 |
||
1890 |
cmd := aCommandString asCollectionOfWords first. |
|
1891 |
^ (self pathOfCommand:cmd) notNil |
|
1892 |
||
1893 |
" |
|
1894 |
OperatingSystem canExecuteCommand:'fooBar' |
|
1895 |
OperatingSystem canExecuteCommand:'ls' |
|
1896 |
OperatingSystem canExecuteCommand:'cvs' |
|
1897 |
" |
|
1898 |
||
1899 |
"Created: 4.11.1995 / 19:13:54 / cg" |
|
68 | 1900 |
! |
1901 |
||
616 | 1902 |
exec:aPath withArguments:argArray |
1903 |
"execute the unix command specified by the argument, aPath, with |
|
1904 |
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
|
1905 |
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
|
1906 |
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
|
1907 |
to another program." |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
1908 |
|
792 | 1909 |
^ 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
|
1910 |
! |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
1911 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
1912 |
exec:aPath withArguments:argArray fileDescriptors:fdArray fork:doFork |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
1913 |
"Internal combined fork & exec; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
1914 |
If fork is false: |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1915 |
execute the unix command specified by the argument, aPath, with |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1916 |
arguments in argArray (no arguments, if nil). |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1917 |
If successful, this method does not return and smalltalk is gone. |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1918 |
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
|
1919 |
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
|
1920 |
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
|
1921 |
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
|
1922 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
1923 |
fdArray contains the filedescriptors, to be used for the child (if fork is true). |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1924 |
fdArray[1] = 15 -> use fd 15 as stdin. |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1925 |
If an element of the array is set to nil, the corresponding filedescriptor |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1926 |
will be closed for the child. |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
1927 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
1928 |
Notice: this used to be two separate ST-methods; however, in order to use |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1929 |
vfork on some machines, it had to be merged into one, to avoid write |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1930 |
accesses to ST/X memory from the vforked-child. The code below only does |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1931 |
read accesses." |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
1932 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
1933 |
%{ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
1934 |
#ifndef MSDOS_LIKE |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
1935 |
char **argv; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
1936 |
int nargs, i, id; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
1937 |
OBJ arg; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
1938 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
1939 |
if (__isString(aPath) && |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1940 |
((argArray == nil) || __isArray(argArray)) && |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1941 |
((fdArray == nil) || __isArray(fdArray)) |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
1942 |
) { |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1943 |
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
|
1944 |
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
|
1945 |
if (argv) { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1946 |
for (i=0; i < nargs; i++) { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1947 |
arg = _ArrayInstPtr(argArray)->a_element[i]; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1948 |
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
|
1949 |
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
|
1950 |
} else { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1951 |
argv[i] = ""; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1952 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1953 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1954 |
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
|
1955 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1956 |
if (doFork == true) { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1957 |
int nfd; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1958 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1959 |
nfd = fdArray == nil ? 0 : _arraySize(fdArray); |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
1960 |
#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
|
1961 |
id = vfork(); |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
1962 |
#else |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1963 |
id = fork(); |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1964 |
#endif |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1965 |
if (id == 0) { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1966 |
/* |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1967 |
** In child. |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1968 |
** first: dup filedescriptors |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1969 |
*/ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1970 |
for (i = 0; i < nfd; i++) { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1971 |
if (__isSmallInteger(_ArrayInstPtr(fdArray)->a_element[i]) && |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1972 |
__intVal(_ArrayInstPtr(fdArray)->a_element[i]) != i |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1973 |
) { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1974 |
dup2(__intVal(_ArrayInstPtr(fdArray)->a_element[i]), i); |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1975 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1976 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1977 |
/* |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1978 |
** second: close unused filedescriptors |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1979 |
*/ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1980 |
for (i = 0; i < nfd; i++) { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1981 |
if (_ArrayInstPtr(fdArray)->a_element[i] == nil) { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1982 |
close(i); |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1983 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1984 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1985 |
execv(_stringVal(aPath), argv); |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1986 |
/* should not be reached */ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1987 |
_exit(127); /* POSIX 2 compatible exit value */ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1988 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1989 |
/* |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1990 |
** In parent: succes or failure |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1991 |
*/ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1992 |
free(argv); |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1993 |
RETURN (__MKSMALLINT(id)); |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1994 |
} else { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1995 |
execv(_stringVal(aPath), argv); |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1996 |
/* |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1997 |
* should not be reached |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1998 |
* (well, it is, if you pass a wrong command-path) |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1999 |
*/ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2000 |
free(argv); |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2001 |
RETURN ( false ); |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2002 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2003 |
} |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2004 |
} |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2005 |
#endif |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2006 |
%}. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2007 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2008 |
path-argument not string |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2009 |
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
|
2010 |
or malloc failed |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2011 |
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
|
2012 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2013 |
^ self primitiveFailed |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2014 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2015 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2016 |
|id| |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2017 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2018 |
id := OperatingSystem fork. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2019 |
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
|
2020 |
"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
|
2021 |
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
|
2022 |
"not reached" |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2023 |
] |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2024 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2025 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2026 |
|id| |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2027 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2028 |
id := OperatingSystem fork. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2029 |
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
|
2030 |
"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
|
2031 |
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
|
2032 |
"not reached" |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2033 |
]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2034 |
id printNL. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2035 |
(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
|
2036 |
'killing ...' printNL. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2037 |
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
|
2038 |
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
|
2039 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2040 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2041 |
|
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2042 |
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
|
2043 |
"Internal combined fork & exec; |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2044 |
If fork is false: |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2045 |
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
|
2046 |
arguments in argArray (no arguments, if nil). |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2047 |
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
|
2048 |
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
|
2049 |
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
|
2050 |
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
|
2051 |
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
|
2052 |
|
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2053 |
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
|
2054 |
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
|
2055 |
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
|
2056 |
read accesses." |
616 | 2057 |
|
2058 |
%{ |
|
792 | 2059 |
#ifndef MSDOS_LIKE |
616 | 2060 |
char **argv; |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2061 |
int nargs, i, id; |
616 | 2062 |
OBJ arg; |
2063 |
||
2064 |
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
|
2065 |
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
|
2066 |
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
|
2067 |
if (argv) { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2068 |
for (i=0; i < nargs; i++) { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2069 |
arg = _ArrayInstPtr(argArray)->a_element[i]; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2070 |
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
|
2071 |
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
|
2072 |
} else { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2073 |
argv[i] = ""; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2074 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2075 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2076 |
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
|
2077 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2078 |
if (doFork == true) { |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2079 |
#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
|
2080 |
id = vfork(); |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2081 |
#else |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2082 |
id = fork(); |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2083 |
#endif |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2084 |
if (id == 0) { |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2085 |
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
|
2086 |
/* 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
|
2087 |
_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
|
2088 |
} |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2089 |
free(argv); |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2090 |
RETURN (__MKSMALLINT(id)); |
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2091 |
} else { |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2092 |
execv(_stringVal(aPath), argv); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2093 |
/* |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2094 |
* should not be reached |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2095 |
* (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
|
2096 |
*/ |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2097 |
free(argv); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
2098 |
RETURN ( false ); |
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2099 |
} |
616 | 2100 |
} |
2101 |
} |
|
792 | 2102 |
#endif |
616 | 2103 |
%}. |
2104 |
" |
|
792 | 2105 |
path-argument not string |
2106 |
or argArray not an array/nil |
|
2107 |
or malloc failed |
|
2108 |
or not supported by OS |
|
616 | 2109 |
" |
2110 |
^ self primitiveFailed |
|
2111 |
||
2112 |
" |
|
2113 |
|id| |
|
2114 |
||
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2115 |
id := OperatingSystem fork. |
616 | 2116 |
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
|
2117 |
"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
|
2118 |
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
|
2119 |
"not reached" |
616 | 2120 |
] |
2121 |
" |
|
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2122 |
" |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2123 |
|id| |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2124 |
|
771
1ad3f852e201
merged fork/exec into one, in order to use vfork
Claus Gittinger <cg@exept.de>
parents:
766
diff
changeset
|
2125 |
id := OperatingSystem fork. |
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2126 |
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
|
2127 |
"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
|
2128 |
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
|
2129 |
"not reached" |
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2130 |
]. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2131 |
id printNL. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2132 |
(Delay forSeconds:3.5) wait. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2133 |
'killing ...' printNL. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2134 |
OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id. |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2135 |
OperatingSystem sendSignal:(OperatingSystem sigKILL) to:id |
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
2136 |
" |
616 | 2137 |
! |
2138 |
||
2139 |
executeCommand:aCommandString |
|
2140 |
"execute the unix command specified by the argument, aCommandString. |
|
676 | 2141 |
The commandString is passed to a shell for execution - see the description of |
2142 |
'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
|
2143 |
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
|
2144 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2145 |
" 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
|
2146 |
^ 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
|
2147 |
until then:" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2148 |
|
616 | 2149 |
%{ |
2150 |
int status; |
|
2151 |
||
2152 |
if (__isString(aCommandString)) { |
|
2153 |
/* |
|
2154 |
* ST/X provides a modified (fixed) implementation of the |
|
2155 |
* system() libc-function, which is interruptable ... |
|
2156 |
*/ |
|
2157 |
# ifdef WANT_SYSTEM |
|
2158 |
status = mySystem((char *) _stringVal(aCommandString)); |
|
2159 |
# else |
|
2160 |
status = system((char *) _stringVal(aCommandString)); |
|
2161 |
# endif |
|
2162 |
OperatingSystem_LastExecStatus = _MKSMALLINT(status); |
|
2163 |
if (status == 0) { |
|
2164 |
RETURN ( true ); |
|
2165 |
} |
|
2166 |
OperatingSystem_LastErrorNumber = _MKSMALLINT(errno); |
|
2167 |
RETURN ( false ); |
|
2168 |
} |
|
2169 |
%}. |
|
792 | 2170 |
"/ |
2171 |
"/ invalid argument (non-string) |
|
2172 |
"/ |
|
2173 |
^ self primitiveFailed |
|
616 | 2174 |
|
2175 |
" |
|
805 | 2176 |
OperatingSystem executeCommand:'sleep 30'. |
616 | 2177 |
OperatingSystem executeCommand:'pwd'. |
2178 |
OperatingSystem executeCommand:'ls -l'. |
|
2179 |
OperatingSystem executeCommand:'invalidCommand'. |
|
2180 |
OperatingSystem executeCommand:'rm /tmp/foofoofoofoo'. |
|
2181 |
" |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2182 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2183 |
"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
|
2184 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2185 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2186 |
executeCommand:aCommandString onError:aBlock |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2187 |
"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
|
2188 |
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
|
2189 |
'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
|
2190 |
Return true if successful. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2191 |
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
|
2192 |
as argument." |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2193 |
|
1034 | 2194 |
|pid exitStatus sema| |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2195 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2196 |
sema := Semaphore new. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2197 |
|
1034 | 2198 |
[ |
2199 |
pid := self startProcess:aCommandString. |
|
2200 |
pid > 0 ifTrue:[ |
|
2201 |
Processor monitorPid:pid action:[ :stat | |
|
2202 |
stat stillAlive ifFalse:[ |
|
2203 |
exitStatus := stat. |
|
2204 |
sema signal |
|
2205 |
]. |
|
2206 |
]. |
|
2207 |
sema wait. |
|
2208 |
] ifFalse:[ |
|
2209 |
exitStatus := OSProcessStatus processCreationFailure. |
|
2210 |
]. |
|
2211 |
] valueUninterruptably. |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2212 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2213 |
exitStatus success ifFalse:[ |
1034 | 2214 |
^ aBlock value:exitStatus |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2215 |
]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2216 |
^ true. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2217 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2218 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2219 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2220 |
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
|
2221 |
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
|
2222 |
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
|
2223 |
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
|
2224 |
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
|
2225 |
" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2226 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2227 |
"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
|
2228 |
"Modified: 28.12.1995 / 15:25:48 / stefan" |
1034 | 2229 |
"Modified: 28.2.1996 / 21:41:23 / cg" |
616 | 2230 |
! |
2231 |
||
2232 |
fork |
|
2233 |
"fork a new (HEAVY-weight) unix process. |
|
2234 |
Dont confuse this with Block>>fork, which creates |
|
2235 |
lightweight smalltalk processes. This method will return |
|
676 | 2236 |
0 to the child process, and a non-zero number (which is the childs |
2237 |
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
|
2238 |
|
676 | 2239 |
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
|
2240 |
#startProcess: and #executCommand: for higher level interfaces." |
68 | 2241 |
|
2242 |
%{ /* NOCONTEXT */ |
|
792 | 2243 |
#ifndef MSDOS_LIKE |
616 | 2244 |
|
2245 |
int pid; |
|
2246 |
||
2247 |
pid = fork(); |
|
2248 |
RETURN ( _MKSMALLINT(pid) ); |
|
792 | 2249 |
#endif |
2250 |
%}. |
|
2251 |
"/ |
|
2252 |
"/ not supported by OS |
|
2253 |
"/ |
|
2254 |
^ self primitiveFailed |
|
2255 |
||
616 | 2256 |
" |
2257 |
|id| |
|
2258 |
||
2259 |
id := OperatingSystem fork. |
|
2260 |
id == 0 ifTrue:[ |
|
2261 |
OperatingSystem exit |
|
2262 |
] |
|
2263 |
" |
|
68 | 2264 |
! |
2265 |
||
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2266 |
getStatusOfProcess:aProcessId |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2267 |
"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
|
2268 |
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
|
2269 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2270 |
%{ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2271 |
#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
|
2272 |
int status; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2273 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2274 |
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
|
2275 |
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
|
2276 |
{ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2277 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2278 |
# 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
|
2279 |
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
|
2280 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2281 |
do { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2282 |
__BEGIN_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2283 |
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
|
2284 |
__END_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2285 |
if (child < 0 && errno != EINTR) { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2286 |
printf("5: errno=%d\n", errno); |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2287 |
status = -1; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2288 |
break; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2289 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2290 |
} 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
|
2291 |
# else |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2292 |
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
|
2293 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2294 |
/* 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
|
2295 |
do { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2296 |
__BEGIN_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2297 |
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
|
2298 |
__END_INTERRUPTABLE__ |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2299 |
} 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
|
2300 |
if (child != pid) { |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2301 |
printf("6: errno=%d\n", errno); |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2302 |
status = -1; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2303 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2304 |
# 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
|
2305 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2306 |
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
|
2307 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2308 |
#endif |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2309 |
%}. |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2310 |
self primitiveFailed |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2311 |
|
1034 | 2312 |
! |
2313 |
||
2314 |
pathOfCommand:aCommand |
|
2315 |
"find where aCommand's executable file is" |
|
2316 |
||
2317 |
|path f| |
|
2318 |
||
2319 |
path := self getEnvironment:'PATH'. |
|
2320 |
path notNil ifTrue:[ |
|
2321 |
(path asCollectionOfSubstringsSeparatedBy:$:) do:[:path | |
|
2322 |
(f := (path asFilename construct:aCommand)) isExecutable ifTrue:[ |
|
2323 |
^ f pathName |
|
2324 |
] |
|
2325 |
]. |
|
2326 |
]. |
|
2327 |
^ nil |
|
2328 |
||
2329 |
" |
|
2330 |
OperatingSystem pathOfCommand:'fooBar' |
|
2331 |
OperatingSystem pathOfCommand:'ls' |
|
2332 |
OperatingSystem pathOfCommand:'cvs' |
|
2333 |
" |
|
2334 |
! |
|
2335 |
||
2336 |
startProcess:aCommandString |
|
2337 |
"start executing the unix command as specified by the argument, aCommandString |
|
2338 |
as a separate process; do not wait for the command to finish. |
|
2339 |
The commandString is passed to a shell for execution - see the description of |
|
2340 |
'sh -c' in your UNIX manual. |
|
2341 |
Return the processId if successful, nil otherwise. |
|
2342 |
Use #waitForProcess: for synchronization and exec status return, |
|
2343 |
or #killProcess: to stop it." |
|
2344 |
||
2345 |
^ self |
|
2346 |
exec:'/bin/sh' |
|
2347 |
withArguments:(Array with:'sh' with:'-c' with:aCommandString) |
|
2348 |
fork:true. |
|
2349 |
||
2350 |
" |
|
2351 |
|pid| |
|
2352 |
||
2353 |
pid := OperatingSystem startProcess:'sleep 2; echo 1; sleep 2; echo 2'. |
|
2354 |
(Delay forSeconds:3) wait. |
|
2355 |
OperatingSystem killProcess:pid. |
|
2356 |
" |
|
616 | 2357 |
! ! |
2358 |
||
2359 |
!OperatingSystem class methodsFor:'file access'! |
|
2360 |
||
2361 |
accessMaskFor:aSymbol |
|
2362 |
"return the access bits mask for numbers as returned by |
|
2363 |
OperatingSystem>>accessModeOf: |
|
2364 |
and expected by OperatingSystem>>changeAccessModeOf:to:. |
|
2365 |
Since these numbers are OS dependent, always use the mask |
|
2366 |
(never hardcode 8rxxx into your code)." |
|
68 | 2367 |
|
2368 |
%{ /* NOCONTEXT */ |
|
616 | 2369 |
# ifndef S_IRUSR |
2370 |
/* posix systems should define these ... */ |
|
2371 |
# define S_IRUSR 0400 |
|
2372 |
# define S_IWUSR 0200 |
|
2373 |
# define S_IXUSR 0100 |
|
2374 |
# define S_IRGRP 0040 |
|
2375 |
# define S_IWGRP 0020 |
|
2376 |
# define S_IXGRP 0010 |
|
2377 |
# define S_IROTH 0004 |
|
2378 |
# define S_IWOTH 0002 |
|
2379 |
# define S_IXOTH 0001 |
|
2380 |
||
2381 |
# endif |
|
2382 |
||
2383 |
if (aSymbol == @symbol(readUser)) { |
|
710 | 2384 |
RETURN ( _MKSMALLINT(S_IRUSR) ); |
616 | 2385 |
} |
2386 |
if (aSymbol == @symbol(writeUser)) { |
|
710 | 2387 |
RETURN ( _MKSMALLINT(S_IWUSR) ); |
616 | 2388 |
} |
2389 |
if (aSymbol == @symbol(executeUser)) { |
|
710 | 2390 |
RETURN ( _MKSMALLINT(S_IXUSR) ); |
616 | 2391 |
} |
2392 |
if (aSymbol == @symbol(readGroup)) { |
|
710 | 2393 |
RETURN ( _MKSMALLINT(S_IRGRP) ); |
616 | 2394 |
} |
2395 |
if (aSymbol == @symbol(writeGroup)) { |
|
710 | 2396 |
RETURN ( _MKSMALLINT(S_IWGRP) ); |
616 | 2397 |
} |
2398 |
if (aSymbol == @symbol(executeGroup)) { |
|
710 | 2399 |
RETURN ( _MKSMALLINT(S_IXGRP) ); |
616 | 2400 |
} |
2401 |
if (aSymbol == @symbol(readOthers)) { |
|
710 | 2402 |
RETURN ( _MKSMALLINT(S_IROTH) ); |
616 | 2403 |
} |
2404 |
if (aSymbol == @symbol(writeOthers)) { |
|
710 | 2405 |
RETURN ( _MKSMALLINT(S_IWOTH) ); |
616 | 2406 |
} |
2407 |
if (aSymbol == @symbol(executeOthers)) { |
|
710 | 2408 |
RETURN ( _MKSMALLINT(S_IXOTH) ); |
616 | 2409 |
} |
2410 |
%}. |
|
792 | 2411 |
^ self primitiveFailed |
616 | 2412 |
|
2413 |
" |
|
2414 |
OperatingSystem accessMaskFor:#readUser |
|
2415 |
" |
|
68 | 2416 |
! |
2417 |
||
616 | 2418 |
accessModeOf:aPathName |
2419 |
"return a number representing access rights rwxrwxrwx for owner, |
|
2420 |
group and others. Return nil if such a file does not exist. |
|
2421 |
Notice that the returned number is OS dependent - use the |
|
2422 |
modeMasks as returned by OperatingSystem>>accessMaskFor:" |
|
2423 |
||
2424 |
" |
|
2425 |
this could have been implemented as: |
|
2426 |
(self infoOf:aPathName) at:#mode |
|
2427 |
but for huge directory searches the code below is faster |
|
2428 |
" |
|
345 | 2429 |
|
2430 |
%{ /* NOCONTEXT */ |
|
616 | 2431 |
|
2432 |
struct stat buf; |
|
2433 |
int ret; |
|
2434 |
||
2435 |
if (__isString(aPathName)) { |
|
2436 |
__BEGIN_INTERRUPTABLE__ |
|
2437 |
do { |
|
2438 |
ret = stat((char *) _stringVal(aPathName), &buf); |
|
2439 |
} while ((ret < 0) && (errno == EINTR)); |
|
2440 |
__END_INTERRUPTABLE__ |
|
2441 |
||
2442 |
if (ret < 0) { |
|
2443 |
OperatingSystem_LastErrorNumber = _MKSMALLINT(errno); |
|
2444 |
RETURN ( nil ); |
|
2445 |
} |
|
2446 |
RETURN ( _MKSMALLINT(buf.st_mode & 0777) ); |
|
2447 |
} |
|
2448 |
%}. |
|
792 | 2449 |
^ self primitiveFailed |
616 | 2450 |
|
2451 |
" |
|
2452 |
(OperatingSystem accessModeOf:'/') printStringRadix:8 |
|
2453 |
" |
|
345 | 2454 |
! |
2455 |
||
616 | 2456 |
baseNameOf:aPathString |
2457 |
"return the baseName of the argument, aPathString |
|
2458 |
- thats the file/directory name without leading parent-dirs |
|
2459 |
(i.e. OperatingSystem baseNameOf:'/usr/lib/st/file' -> 'file' |
|
2460 |
and OperatingSystem baseNameOf:'/usr/lib' -> lib). |
|
2461 |
This method does not check if the path is valid |
|
2462 |
(i.e. if these directories really exist & is readable)." |
|
2463 |
||
2464 |
|prev index sep| |
|
2465 |
||
2466 |
sep := self fileSeparator. |
|
2467 |
((aPathString size == 1) and:[(aPathString at:1) == sep]) ifTrue:[ |
|
2468 |
^ aPathString |
|
2469 |
]. |
|
2470 |
prev := 1. |
|
2471 |
[true] whileTrue:[ |
|
2472 |
index := aPathString indexOf:sep startingAt:prev. |
|
2473 |
index == 0 ifTrue:[ |
|
2474 |
^ aPathString copyFrom:prev |
|
2475 |
]. |
|
2476 |
prev := index + 1 |
|
2477 |
] |
|
2478 |
||
2479 |
" |
|
2480 |
OperatingSystem baseNameOf:'/fee/foo/bar' |
|
2481 |
OperatingSystem baseNameOf:'foo/bar' |
|
2482 |
OperatingSystem baseNameOf:'../../foo/bar' |
|
2483 |
OperatingSystem baseNameOf:'hello' |
|
2484 |
" |
|
2485 |
! |
|
2486 |
||
2487 |
caseSensitiveFilenames |
|
2488 |
"return true, if the OS has caseSensitive file naming. |
|
2489 |
On MSDOS, this will return false. Since this is for Unix, we |
|
2490 |
return true." |
|
2491 |
||
2492 |
^ true |
|
2493 |
! |
|
2494 |
||
2495 |
changeAccessModeOf:aPathName to:modeBits |
|
2496 |
"change the access rights of aPathName to the OS dependent modeBits. |
|
2497 |
You should construct this mask using accessMaskFor, to be OS |
|
2498 |
independent. Return true if changed, |
|
2499 |
false if such a file does not exist or change was not allowd." |
|
68 | 2500 |
|
2501 |
%{ /* NOCONTEXT */ |
|
616 | 2502 |
int ret; |
2503 |
||
2504 |
if (__isString(aPathName) && __isSmallInteger(modeBits)) { |
|
2505 |
__BEGIN_INTERRUPTABLE__ |
|
2506 |
do { |
|
2507 |
ret = chmod((char *)_stringVal(aPathName), _intVal(modeBits)); |
|
2508 |
} while (ret < 0 && errno == EINTR); |
|
2509 |
__END_INTERRUPTABLE__ |
|
2510 |
if (ret < 0) { |
|
2511 |
OperatingSystem_LastErrorNumber = _MKSMALLINT(errno); |
|
2512 |
RETURN ( false ); |
|
2513 |
} |
|
2514 |
RETURN ( true ); |
|
2515 |
} |
|
2516 |
%}. |
|
792 | 2517 |
^ self primitiveFailed |
616 | 2518 |
! |
2519 |
||
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2520 |
closeFd:anInteger |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2521 |
"low level close of a filedescriptor" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2522 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2523 |
%{ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2524 |
#if !defined(transputer) && !defined(MSDOS_LIKE) |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2525 |
if (__isSmallInteger(anInteger)) { |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2526 |
close(__intVal(anInteger)); |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2527 |
RETURN(self); |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2528 |
} |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2529 |
#endif |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2530 |
%}. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2531 |
^ self primitiveFailed. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2532 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
2533 |
|
616 | 2534 |
compressPath:pathName |
2535 |
"return the pathName compressed - that is, remove all ..-entries |
|
2536 |
and . entries. This does not always (in case of symbolic links) |
|
2537 |
return the true pathName and is therefore used as a fallback |
|
2538 |
if realPath and popen failed." |
|
2539 |
||
2540 |
|names| |
|
2541 |
||
2542 |
names := pathName |
|
2543 |
asCollectionOfSubstringsSeparatedBy:self fileSeparator. |
|
2544 |
names := names asOrderedCollection. |
|
2545 |
" |
|
2546 |
cut off initial double-slashes |
|
2547 |
" |
|
2548 |
[names startsWith:#('' '')] whileTrue:[ |
|
2549 |
names removeFirst. |
|
2550 |
]. |
|
2551 |
" |
|
2552 |
cut off double-slashes at end |
|
2553 |
" |
|
2554 |
[names endsWith:#('')] whileTrue:[ |
|
2555 |
names removeLast. |
|
2556 |
]. |
|
2557 |
" |
|
2558 |
cut off current-dir at beginning |
|
2559 |
" |
|
2560 |
[(names size >= 2) and:[names startsWith:#('.')]] whileTrue:[ |
|
2561 |
names removeFirst. |
|
2562 |
]. |
|
2563 |
||
2564 |
" |
|
2565 |
cut off parent-dirs at end |
|
2566 |
" |
|
2567 |
[(names size > 2) |
|
2568 |
and:[(names endsWith:#('..')) |
|
2569 |
and:[((names at:(names size - 1)) startsWith:'.') not ]]] whileTrue:[ |
|
2570 |
names removeLast; removeLast |
|
2571 |
]. |
|
2572 |
||
2573 |
^ names asStringWith:self fileSeparator |
|
2574 |
from:1 |
|
2575 |
to:names size |
|
2576 |
compressTabs:false final:nil |
|
2577 |
||
2578 |
" |
|
2579 |
OperatingSystem compressPath:'./..' |
|
2580 |
OperatingSystem compressPath:'/foo/bar/baz/..' |
|
2581 |
OperatingSystem compressPath:'foo/bar/baz/..' |
|
2582 |
OperatingSystem compressPath:'foo/bar/baz/../' |
|
2583 |
OperatingSystem compressPath:'foo/bar/baz/..///' |
|
2584 |
OperatingSystem compressPath:'///foo/bar/baz/..///' |
|
2585 |
" |
|
68 | 2586 |
! |
2587 |
||
616 | 2588 |
createDirectory:newPathName |
2589 |
"create a new directory with name 'newPathName'. |
|
2590 |
Return true if successful, false if failed." |
|
2591 |
||
2592 |
"since createDirectory is not used too often, |
|
2593 |
you'll forgive me using mkdir ..." |
|
2594 |
||
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
|
2595 |
^ self executeCommand:('mkdir 2>/dev/null ', newPathName) |
616 | 2596 |
|
2597 |
"OperatingSystem createDirectory:'foo'" |
|
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
|
2598 |
|
90a518c71a7f
recursiveRemoveDirectory does not print garbage to stderr any longer; computeDateAndTimeFrom: now returns the utcOffset
Stefan Vogel <sv@exept.de>
parents:
792
diff
changeset
|
2599 |
"Modified: 20.12.1995 / 11:24:13 / stefan" |
616 | 2600 |
! |
2601 |
||
2602 |
directoryNameOf:aPathString |
|
2603 |
"return the directoryName of the argument, aPath |
|
2604 |
- thats the name of the directory where aPath is |
|
2605 |
(i.e. OperatingSystem directoryNameOf:'/usr/lib/st/file' -> '/usr/lib/st' |
|
2606 |
and OperatingSystem directoryNameOf:'/usr/lib' -> /usr'). |
|
2607 |
This method does not check if the path is valid |
|
2608 |
(i.e. if these directories really exist & are readable)." |
|
2609 |
||
2610 |
|last index sep sepString| |
|
2611 |
||
2612 |
sep := self fileSeparator. |
|
2613 |
sepString := sep asString. |
|
2614 |
(aPathString = sepString) ifTrue:[ |
|
2615 |
" |
|
2616 |
the trivial '/' case |
|
2617 |
" |
|
2618 |
^ aPathString |
|
2619 |
]. |
|
2620 |
(aPathString startsWith:sepString) ifFalse:[ |
|
2621 |
(aPathString endsWith:sepString) ifTrue:[ |
|
2622 |
^ aPathString copyTo:(aPathString size - 1) |
|
2623 |
]. |
|
2624 |
]. |
|
2625 |
last := 1. |
|
2626 |
[true] whileTrue:[ |
|
2627 |
index := aPathString indexOf:sep startingAt:(last + 1). |
|
2628 |
index == 0 ifTrue:[ |
|
2629 |
(last == 1) ifTrue:[ |
|
2630 |
(aPathString startsWith:sepString) ifTrue:[ |
|
2631 |
^ sepString |
|
2632 |
]. |
|
2633 |
^ '.' |
|
2634 |
]. |
|
2635 |
" |
|
2636 |
(aPathString startsWith:sepString) ifFalse:[ |
|
2637 |
(aPathString startsWith:('..' , sepString)) ifFalse:[ |
|
2638 |
^ './' , (aPathString copyTo:(last - 1)) |
|
2639 |
] |
|
2640 |
]. |
|
2641 |
" |
|
2642 |
^ aPathString copyTo:(last - 1) |
|
2643 |
]. |
|
2644 |
last := index. |
|
2645 |
] |
|
2646 |
||
2647 |
" |
|
2648 |
OperatingSystem directoryNameOf:'/fee/foo/bar' |
|
2649 |
OperatingSystem directoryNameOf:'foo/bar' |
|
2650 |
OperatingSystem directoryNameOf:'../../foo/bar' |
|
2651 |
OperatingSystem directoryNameOf:'bar' |
|
2652 |
OperatingSystem directoryNameOf:'/bar' |
|
2653 |
" |
|
2654 |
! |
|
2655 |
||
2656 |
fileSeparator |
|
2657 |
"return the character used to separate names in a path. |
|
2658 |
This character differs for MSDOS and other systems, |
|
2659 |
(but those are currently not supported - so this is some |
|
2660 |
preparation for the future)" |
|
2661 |
||
2662 |
^ $/ |
|
2663 |
! |
|
2664 |
||
2665 |
getCharacter |
|
2666 |
"read a character from keyboard - |
|
2667 |
this is a blocking low-level read, provided for debugger |
|
2668 |
and fatal conditions. Use Stdin or (even better) the event |
|
2669 |
mechanisms provided." |
|
68 | 2670 |
|
2671 |
%{ /* NOCONTEXT */ |
|
616 | 2672 |
|
2673 |
RETURN ( _MKSMALLINT(getchar()) ); |
|
68 | 2674 |
%} |
2675 |
! |
|
2676 |
||
616 | 2677 |
idOf:aPathName |
2678 |
"return the fileNumber (i.e. inode number) of a file" |
|
2679 |
||
2680 |
" |
|
2681 |
this could have been implemented as: |
|
2682 |
(self infoOf:aPathName) at:#id |
|
2683 |
but for huge directory searches the code below is faster |
|
2684 |
" |
|
68 | 2685 |
|
2686 |
%{ /* NOCONTEXT */ |
|
616 | 2687 |
|
2688 |
struct stat buf; |
|
2689 |
int ret; |
|
2690 |
||
2691 |
if (__isString(aPathName)) { |
|
2692 |
__BEGIN_INTERRUPTABLE__ |
|
2693 |
do { |
|
2694 |
ret = stat((char *) _stringVal(aPathName), &buf); |
|
2695 |
} while (ret < 0 && errno == EINTR); |
|
2696 |
__END_INTERRUPTABLE__ |
|
2697 |
if (ret >= 0) { |
|
2698 |
RETURN (_MKSMALLINT(buf.st_ino)); |
|
2699 |
} |
|
2700 |
OperatingSystem_LastErrorNumber = _MKSMALLINT(errno); |
|
2701 |
RETURN (nil); |
|
2702 |
} |
|
68 | 2703 |
%} |
616 | 2704 |
. |
792 | 2705 |
^ self primitiveFailed |
616 | 2706 |
|
2707 |
"OperatingSystem idOf:'/'" |
|
68 | 2708 |
! |
2709 |
||
616 | 2710 |
infoOf:aPathName |
2711 |
"return a dictionary filled with info for the file 'aPathName'; |
|
2712 |
info is: (type->t mode->n uid->u gid->g size->s id->ino). |
|
2713 |
return nil if such a file does not exist. A dictionary is returned, |
|
2714 |
since we might need to add more info in the future without affecting |
|
2715 |
existing applications." |
|
2716 |
||
2717 |
|info type mode uid gid size id |
|
2718 |
atimeLow atimeHi mtimeLow mtimeHi ctimeLow ctimeHi| |
|
2719 |
||
2720 |
%{ |
|
2721 |
struct stat buf; |
|
2722 |
int ret; |
|
2723 |
||
2724 |
if (__isString(aPathName)) { |
|
2725 |
__BEGIN_INTERRUPTABLE__ |
|
2726 |
do { |
|
2727 |
ret = stat((char *) _stringVal(aPathName), &buf); |
|
2728 |
} while ((ret < 0) && (errno == EINTR)); |
|
2729 |
__END_INTERRUPTABLE__ |
|
2730 |
||
2731 |
if (ret < 0) { |
|
2732 |
OperatingSystem_LastErrorNumber = _MKSMALLINT(errno); |
|
2733 |
RETURN ( nil ); |
|
2734 |
} |
|
2735 |
switch (buf.st_mode & S_IFMT) { |
|
2736 |
case S_IFDIR: |
|
2737 |
type = @symbol(directory); |
|
2738 |
break; |
|
2739 |
case S_IFREG: |
|
2740 |
type = @symbol(regular); |
|
2741 |
break; |
|
2742 |
#ifdef S_IFCHR |
|
2743 |
case S_IFCHR: |
|
2744 |
type = @symbol(characterSpecial); |
|
2745 |
break; |
|
2746 |
#endif |
|
2747 |
#ifdef S_IFBLK |
|
2748 |
case S_IFBLK: |
|
2749 |
type = @symbol(blockSpecial); |
|
2750 |
break; |
|
2751 |
#endif |
|
2752 |
#ifdef S_IFLNK |
|
2753 |
case S_IFLNK: |
|
2754 |
type = @symbol(symbolicLink); |
|
2755 |
break; |
|
2756 |
#endif |
|
2757 |
#ifdef S_IFSOCK |
|
2758 |
case S_IFSOCK: |
|
2759 |
type = @symbol(socket); |
|
2760 |
break; |
|
2761 |
#endif |
|
2762 |
#ifdef S_IFIFO |
|
2763 |
case S_IFIFO: |
|
2764 |
type = @symbol(fifo); |
|
2765 |
break; |
|
2766 |
#endif |
|
2767 |
default: |
|
2768 |
type = @symbol(unknown); |
|
2769 |
break; |
|
2770 |
} |
|
2771 |
mode = _MKSMALLINT(buf.st_mode & 0777); |
|
2772 |
uid = _MKSMALLINT(buf.st_uid); |
|
2773 |
gid = _MKSMALLINT(buf.st_gid); |
|
2774 |
size = _MKSMALLINT(buf.st_size); |
|
2775 |
id = _MKSMALLINT(buf.st_ino); |
|
2776 |
atimeLow = _MKSMALLINT(buf.st_atime & 0xFFFF); |
|
2777 |
atimeHi = _MKSMALLINT((buf.st_atime >> 16) & 0xFFFF); |
|
2778 |
mtimeLow = _MKSMALLINT(buf.st_mtime & 0xFFFF); |
|
2779 |
mtimeHi = _MKSMALLINT((buf.st_mtime >> 16) & 0xFFFF); |
|
2780 |
ctimeLow = _MKSMALLINT(buf.st_ctime & 0xFFFF); |
|
2781 |
ctimeHi = _MKSMALLINT((buf.st_ctime >> 16) & 0xFFFF); |
|
2782 |
} |
|
2783 |
%}. |
|
2784 |
mode notNil ifTrue:[ |
|
2785 |
info := IdentityDictionary new. |
|
2786 |
info at:#type put:type. |
|
2787 |
info at:#mode put:mode. |
|
2788 |
info at:#uid put:uid. |
|
2789 |
info at:#gid put:gid. |
|
2790 |
info at:#size put:size. |
|
2791 |
info at:#id put:id. |
|
2792 |
info at:#accessed put:(AbsoluteTime fromOSTimeLow:atimeLow and:atimeHi). |
|
2793 |
info at:#modified put:(AbsoluteTime fromOSTimeLow:mtimeLow and:mtimeHi). |
|
2794 |
info at:#statusChanged put:(AbsoluteTime fromOSTimeLow:ctimeLow and:ctimeHi). |
|
2795 |
^ info |
|
2796 |
]. |
|
792 | 2797 |
^ self primitiveFailed |
616 | 2798 |
|
2799 |
" |
|
2800 |
OperatingSystem infoOf:'/' |
|
2801 |
(OperatingSystem infoOf:'/') at:#uid |
|
2802 |
(OperatingSystem infoOf:'/') at:#accessed |
|
2803 |
" |
|
68 | 2804 |
! |
2805 |
||
616 | 2806 |
isDirectory:aPathName |
2807 |
"return true, if 'aPathName' is a valid directory path name. |
|
2808 |
(i.e. exists and is a directory)" |
|
68 | 2809 |
|
2810 |
%{ /* NOCONTEXT */ |
|
616 | 2811 |
|
2812 |
struct stat buf; |
|
2813 |
int ret; |
|
2814 |
||
2815 |
if (__isString(aPathName)) { |
|
2816 |
__BEGIN_INTERRUPTABLE__ |
|
2817 |
do { |
|
2818 |
ret = stat((char *) _stringVal(aPathName), &buf); |
|
2819 |
} while ((ret < 0) && (errno == EINTR)); |
|
2820 |
__END_INTERRUPTABLE__ |
|
2821 |
if (ret < 0) { |
|
2822 |
OperatingSystem_LastErrorNumber = _MKSMALLINT(errno); |
|
2823 |
RETURN ( false ); |
|
2824 |
} |
|
2825 |
RETURN ( ((buf.st_mode & S_IFMT) == S_IFDIR) ? true : false); |
|
2826 |
} |
|
2827 |
%}. |
|
792 | 2828 |
^ self primitiveFailed |
616 | 2829 |
|
2830 |
"an alternative implementation would be: |
|
2831 |
^ (self infoOf:aPathName) at:#type == #directory |
|
2832 |
" |
|
68 | 2833 |
! |
2834 |
||
616 | 2835 |
isExecutable:aPathName |
2836 |
"return true, if the given file is executable" |
|
68 | 2837 |
|
2838 |
%{ /* NOCONTEXT */ |
|
616 | 2839 |
int ret; |
2840 |
||
2841 |
if (__isString(aPathName)) { |
|
2842 |
__BEGIN_INTERRUPTABLE__ |
|
2843 |
do { |
|
2844 |
ret = access(_stringVal(aPathName), X_OK); |
|
2845 |
} while ((ret < 0) && (errno == EINTR)); |
|
2846 |
__END_INTERRUPTABLE__ |
|
2847 |
if (ret < 0) { |
|
2848 |
OperatingSystem_LastErrorNumber = _MKSMALLINT(errno); |
|
2849 |
} |
|
710 | 2850 |
RETURN ( ((ret == 0) ? true : false) ); |
616 | 2851 |
} |
2852 |
%}. |
|
792 | 2853 |
^ self primitiveFailed |
68 | 2854 |
! |
2855 |
||
616 | 2856 |
isReadable:aPathName |
2857 |
"return true, if the file/dir 'aPathName' is readable." |
|
68 | 2858 |
|
2859 |
%{ /* NOCONTEXT */ |
|
616 | 2860 |
int ret; |
2861 |
||
2862 |
if (__isString(aPathName)) { |
|
2863 |
__BEGIN_INTERRUPTABLE__ |
|
2864 |
do { |
|
2865 |
ret = access(_stringVal(aPathName), R_OK); |
|
2866 |
} while ((ret < 0) && (errno == EINTR)); |
|
2867 |
__END_INTERRUPTABLE__ |
|
2868 |
if (ret < 0) { |
|
2869 |
OperatingSystem_LastErrorNumber = _MKSMALLINT(errno); |
|
2870 |
} |
|
710 | 2871 |
RETURN ( ((ret == 0) ? true : false) ); |
616 | 2872 |
} |
2873 |
%}. |
|
792 | 2874 |
^ self primitiveFailed |
68 | 2875 |
! |
2876 |
||
616 | 2877 |
isSymbolicLink:aPathName |
2878 |
"return true, if the given file is a symbolic link" |
|
2879 |
||
2880 |
^ (self linkInfoOf:aPathName) notNil |
|
2881 |
||
2882 |
" |
|
2883 |
OperatingSystem isSymbolicLink:'Make.proto' |
|
2884 |
OperatingSystem isSymbolicLink:'Makefile' |
|
2885 |
" |
|
2886 |
! |
|
2887 |
||
2888 |
isValidPath:aPathName |
|
2889 |
"return true, if 'aPathName' is a valid path name |
|
2890 |
(i.e. the file or directory exists)" |
|
68 | 2891 |
|
2892 |
%{ /* NOCONTEXT */ |
|
616 | 2893 |
|
2894 |
struct stat buf; |
|
2895 |
int ret; |
|
2896 |
||
2897 |
if (__isString(aPathName) || __isSymbol(aPathName) ) { |
|
2898 |
__BEGIN_INTERRUPTABLE__ |
|
2899 |
do { |
|
2900 |
ret = stat((char *) _stringVal(aPathName), &buf); |
|
2901 |
} while ((ret < 0) && (errno == EINTR)); |
|
2902 |
__END_INTERRUPTABLE__ |
|
2903 |
if (ret < 0) { |
|
2904 |
OperatingSystem_LastErrorNumber = _MKSMALLINT(errno); |
|
2905 |
RETURN (false); |
|
2906 |
} |
|
2907 |
RETURN ( ret ? false : true ); |
|
2908 |
} |
|
792 | 2909 |
%}. |
2910 |
^ self primitiveFailed |
|
68 | 2911 |
! |
2912 |
||
616 | 2913 |
isWritable:aPathName |
2914 |
"return true, if the given file is writable" |
|
68 | 2915 |
|
2916 |
%{ /* NOCONTEXT */ |
|
616 | 2917 |
int ret; |
2918 |
||
2919 |
if (__isString(aPathName)) { |
|
2920 |
__BEGIN_INTERRUPTABLE__ |
|
2921 |
do { |
|
2922 |
ret = access(_stringVal(aPathName), W_OK); |
|
2923 |
} while ((ret < 0) && (errno == EINTR)); |
|
2924 |
__END_INTERRUPTABLE__ |
|
2925 |
if (ret < 0) { |
|
2926 |
OperatingSystem_LastErrorNumber = _MKSMALLINT(errno); |
|
2927 |
} |
|
710 | 2928 |
RETURN ( ((ret == 0) ? true : false) ); |
616 | 2929 |
} |
2930 |
%}. |
|
792 | 2931 |
^ self primitiveFailed |
68 | 2932 |
! |
2933 |
||
616 | 2934 |
linkFile:oldPath to:newPath |
2935 |
"link the file 'oldPath' to 'newPath'. The link will be a hard link. |
|
2936 |
Return true if successful, false if not." |
|
68 | 2937 |
|
2938 |
%{ /* NOCONTEXT */ |
|
792 | 2939 |
#ifndef MSDOS_LIKE |
616 | 2940 |
int ret; |
2941 |
||
2942 |
if (__isString(oldPath) && __isString(newPath)) { |
|
2943 |
__BEGIN_INTERRUPTABLE__ |
|
2944 |
do { |
|
2945 |
ret = link((char *) _stringVal(oldPath), (char *) _stringVal(newPath)); |
|
2946 |
} while (ret < 0 && errno == EINTR); |
|
2947 |
__END_INTERRUPTABLE__ |
|
2948 |
RETURN ( (ret >= 0) ? true : false ); |
|
2949 |
} |
|
792 | 2950 |
#endif |
616 | 2951 |
%}. |
792 | 2952 |
^ self primitiveFailed |
616 | 2953 |
|
2954 |
"OperatingSystem linkFile:'foo' to:'bar'" |
|
68 | 2955 |
! |
2956 |
||
616 | 2957 |
linkInfoOf:aPathName |
2958 |
"return a dictionary filled with info for the file 'aPathName', |
|
2959 |
IFF aPathName is a symbolic link. If not, return nil. |
|
2960 |
The contents of the dictionary gives info about the link itself, |
|
2961 |
on contrast to #infoOf:, which returns the info of the pointed to file |
|
2962 |
in case of a symbolic link." |
|
2963 |
||
2964 |
|info type mode uid gid size id atimeLow atimeHi mtimeLow mtimeHi ctimeLow ctimeHi |
|
2965 |
path| |
|
2966 |
||
2967 |
%{ /* STACK: 1200 */ |
|
792 | 2968 |
#ifdef S_IFLNK |
616 | 2969 |
struct stat buf; |
2970 |
int ret; |
|
2971 |
char pathBuffer[1024]; |
|
2972 |
||
2973 |
if (__isString(aPathName)) { |
|
2974 |
__BEGIN_INTERRUPTABLE__ |
|
2975 |
do { |
|
2976 |
ret = lstat((char *) _stringVal(aPathName), &buf); |
|
2977 |
} while ((ret < 0) && (errno == EINTR)); |
|
2978 |
__END_INTERRUPTABLE__ |
|
2979 |
||
2980 |
if (ret < 0) { |
|
2981 |
OperatingSystem_LastErrorNumber = _MKSMALLINT(errno); |
|
2982 |
RETURN ( nil ); |
|
2983 |
} |
|
2984 |
switch (buf.st_mode & S_IFMT) { |
|
2985 |
default: |
|
2986 |
RETURN ( nil ); /* not a symbolic link */ |
|
2987 |
||
2988 |
case S_IFLNK: |
|
2989 |
type = @symbol(symbolicLink); |
|
2990 |
break; |
|
2991 |
} |
|
2992 |
||
2993 |
mode = _MKSMALLINT(buf.st_mode & 0777); |
|
2994 |
uid = _MKSMALLINT(buf.st_uid); |
|
2995 |
gid = _MKSMALLINT(buf.st_gid); |
|
2996 |
size = _MKSMALLINT(buf.st_size); |
|
2997 |
id = _MKSMALLINT(buf.st_ino); |
|
2998 |
atimeLow = _MKSMALLINT(buf.st_atime & 0xFFFF); |
|
2999 |
atimeHi = _MKSMALLINT((buf.st_atime >> 16) & 0xFFFF); |
|
3000 |
mtimeLow = _MKSMALLINT(buf.st_mtime & 0xFFFF); |
|
3001 |
mtimeHi = _MKSMALLINT((buf.st_mtime >> 16) & 0xFFFF); |
|
3002 |
ctimeLow = _MKSMALLINT(buf.st_ctime & 0xFFFF); |
|
3003 |
ctimeHi = _MKSMALLINT((buf.st_ctime >> 16) & 0xFFFF); |
|
3004 |
if ((ret = readlink((char *) _stringVal(aPathName), pathBuffer, sizeof(pathBuffer))) < 0) { |
|
3005 |
OperatingSystem_LastErrorNumber = _MKSMALLINT(errno); |
|
3006 |
RETURN ( nil ); |
|
3007 |
} |
|
3008 |
pathBuffer[ret] = '\0'; /* readlink does not 0-terminate */ |
|
830 | 3009 |
path = __MKSTRING(pathBuffer COMMA_CON); |
616 | 3010 |
} |
792 | 3011 |
#else |
3012 |
RETURN ( nil ); |
|
3013 |
#endif |
|
616 | 3014 |
%}. |
3015 |
mode notNil ifTrue:[ |
|
3016 |
info := IdentityDictionary new. |
|
3017 |
info at:#type put:type. |
|
3018 |
info at:#mode put:mode. |
|
3019 |
info at:#uid put:uid. |
|
3020 |
info at:#gid put:gid. |
|
3021 |
info at:#size put:size. |
|
3022 |
info at:#id put:id. |
|
3023 |
info at:#path put:path. |
|
3024 |
info at:#accessed put:(AbsoluteTime fromOSTimeLow:atimeLow and:atimeHi). |
|
3025 |
info at:#modified put:(AbsoluteTime fromOSTimeLow:mtimeLow and:mtimeHi). |
|
3026 |
info at:#statusChanged put:(AbsoluteTime fromOSTimeLow:ctimeLow and:ctimeHi). |
|
3027 |
^ info |
|
3028 |
]. |
|
792 | 3029 |
^ self primitiveFailed |
616 | 3030 |
|
3031 |
" |
|
3032 |
OperatingSystem infoOf:'Make.proto' |
|
3033 |
OperatingSystem linkInfoOf:'Make.proto' |
|
3034 |
" |
|
3035 |
! |
|
3036 |
||
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3037 |
makePipe |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3038 |
"make a pipe, return array with two filedescriptors on success, |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3039 |
nil on failure" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3040 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3041 |
|fd1 fd2| |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3042 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3043 |
%{ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3044 |
int fds[2]; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3045 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3046 |
if (pipe(fds) < 0) |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3047 |
RETURN(nil); |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3048 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3049 |
fd1 = __MKSMALLINT(fds[0]); |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3050 |
fd2 = __MKSMALLINT(fds[1]); |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3051 |
%}. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3052 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3053 |
^ Array with:fd1 with:fd2. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3054 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3055 |
|
616 | 3056 |
parentDirectoryName |
3057 |
"return the name used to refer to parent directories. |
|
3058 |
In MSDOS, Unix and other systems this is '..', but maybe different |
|
3059 |
for other systems. |
|
3060 |
(but those are currently not supported - so this is some |
|
3061 |
preparation for the future)" |
|
3062 |
||
3063 |
^ '..' |
|
68 | 3064 |
! |
3065 |
||
616 | 3066 |
pathNameOf:pathName |
3067 |
"return the pathName of the argument, aPathString, |
|
3068 |
- thats the full pathname of the directory, starting at '/'. |
|
3069 |
This method needs the path to be valid |
|
3070 |
(i.e. all directories must exist, be readable and executable). |
|
3071 |
Notice: if symbolic links are involved, the result may look different |
|
3072 |
from what you expect." |
|
3073 |
||
3074 |
|p path command| |
|
3075 |
||
3076 |
"some systems have a convenient function for this ..." |
|
3077 |
path := self primPathNameOf:pathName. |
|
3078 |
||
3079 |
path isNil ifTrue:[ |
|
3080 |
(self isValidPath:pathName) ifFalse:[^ pathName]. |
|
3081 |
||
3082 |
(SlowFork==true or:[ForkFailed]) ifFalse:[ |
|
3083 |
PipeStream openErrorSignal handle:[:ex | |
|
3084 |
ForkFailed := true. |
|
3085 |
'OS: cannot fork/popen' errorPrintNL. |
|
3086 |
ex return. |
|
3087 |
] do:[ |
|
3088 |
"have to fall back ..." |
|
3089 |
command := 'cd ' , pathName , '; pwd'. |
|
3090 |
p := PipeStream readingFrom:command. |
|
3091 |
]. |
|
3092 |
||
3093 |
(p isNil or:[p atEnd]) ifTrue:[ |
|
3094 |
('OS: PipeStream for <' , command , '> failed') errorPrintNL. |
|
3095 |
] ifFalse:[ |
|
3096 |
path := p nextLine. |
|
3097 |
p close. |
|
3098 |
]. |
|
3099 |
]. |
|
3100 |
path isNil ifTrue:[ |
|
3101 |
path := pathName |
|
3102 |
]. |
|
3103 |
(SlowFork==true or:[ForkFailed]) ifTrue:[ |
|
3104 |
path := self compressPath:path |
|
3105 |
] |
|
3106 |
]. |
|
3107 |
^ path. |
|
3108 |
||
3109 |
" |
|
3110 |
OperatingSystem pathNameOf:'.' |
|
3111 |
OperatingSystem pathNameOf:'../smalltalk/../smalltalk' |
|
3112 |
OperatingSystem pathNameOf:'../../..' |
|
3113 |
OperatingSystem pathNameOf:'..' |
|
3114 |
" |
|
359 | 3115 |
! |
3116 |
||
616 | 3117 |
primPathNameOf:pathName |
3118 |
"return the pathName of the argument, aPathString, |
|
3119 |
- thats the full pathname of the directory, starting at '/'. |
|
3120 |
This method here returns nil, if the OS does not provide a |
|
3121 |
realPath library function. |
|
3122 |
Notice: if symbolic links are involved, the result may look different |
|
3123 |
from what you expect." |
|
3124 |
||
3125 |
|path| |
|
3126 |
||
3127 |
"some systems have a convenient function for this ..." |
|
3128 |
%{ /* STACK: 16000 */ |
|
3129 |
#ifdef HAS_REALPATH |
|
3130 |
char nameBuffer[MAXPATHLEN + 1]; |
|
3131 |
||
3132 |
if (__isString(pathName)) { |
|
3133 |
if (realpath(_stringVal(pathName), nameBuffer)) { |
|
830 | 3134 |
RETURN ( __MKSTRING(nameBuffer COMMA_CON) ); |
616 | 3135 |
} |
3136 |
} |
|
3137 |
#endif |
|
3138 |
%}. |
|
3139 |
^ nil |
|
359 | 3140 |
! |
3141 |
||
616 | 3142 |
recursiveCreateDirectory:dirName |
3143 |
"create a directory - with all parent dirs if needed. |
|
3144 |
Return true if successful, false otherwise. If false |
|
3145 |
is returned, a partial created tree may be left, |
|
3146 |
which is not cleaned-up here." |
|
3147 |
||
3148 |
self createDirectory:dirName. |
|
3149 |
(self isDirectory:dirName) ifFalse:[ |
|
3150 |
(self recursiveCreateDirectory:(self directoryNameOf:dirName)) ifFalse:[^ false]. |
|
3151 |
^ self createDirectory:dirName |
|
3152 |
]. |
|
3153 |
^ true |
|
3154 |
||
3155 |
"OperatingSystem recursiveCreateDirectory:'foo/bar/baz'" |
|
359 | 3156 |
! |
3157 |
||
616 | 3158 |
recursiveRemoveDirectory:fullPathName |
3159 |
"remove the directory named 'fullPathName' and all contained files/directories. |
|
3160 |
Return true if successful." |
|
3161 |
||
3162 |
^ self executeCommand:('rm -rf ' , fullPathName) |
|
3163 |
! |
|
3164 |
||
3165 |
removeDirectory:fullPathName |
|
3166 |
"remove the directory named 'fullPathName'. |
|
3167 |
Return true if successful, false if directory is not empty or no permission" |
|
359 | 3168 |
|
3169 |
%{ /* NOCONTEXT */ |
|
616 | 3170 |
int ret; |
3171 |
||
3172 |
if (__isString(fullPathName)) { |
|
3173 |
__BEGIN_INTERRUPTABLE__ |
|
3174 |
do { |
|
3175 |
ret = rmdir((char *) _stringVal(fullPathName)); |
|
3176 |
} while (ret < 0 && errno == EINTR); |
|
3177 |
__END_INTERRUPTABLE__ |
|
3178 |
RETURN ( (ret >= 0) ? true : false ); |
|
3179 |
} |
|
3180 |
%}. |
|
792 | 3181 |
^ self primitiveFailed |
359 | 3182 |
! |
3183 |
||
616 | 3184 |
removeFile:fullPathName |
3185 |
"remove the file named 'fullPathName'; return true if successful" |
|
359 | 3186 |
|
3187 |
%{ /* NOCONTEXT */ |
|
616 | 3188 |
int ret; |
3189 |
||
3190 |
if (__isString(fullPathName)) { |
|
3191 |
__BEGIN_INTERRUPTABLE__ |
|
3192 |
do { |
|
3193 |
ret = unlink((char *) _stringVal(fullPathName)); |
|
3194 |
} while (ret < 0 && errno == EINTR); |
|
3195 |
__END_INTERRUPTABLE__ |
|
3196 |
RETURN ( (ret >= 0) ? true : false ); |
|
3197 |
} |
|
3198 |
%}. |
|
792 | 3199 |
^ self primitiveFailed |
359 | 3200 |
! |
3201 |
||
616 | 3202 |
renameFile:oldPath to:newPath |
3203 |
"rename the file 'oldPath' to 'newPath'. |
|
670
4d6d0c031711
startProcess: / killProcess: added
Claus Gittinger <cg@exept.de>
parents:
640
diff
changeset
|
3204 |
Return true if successful, false if not" |
359 | 3205 |
|
3206 |
%{ /* NOCONTEXT */ |
|
616 | 3207 |
int ret; |
3208 |
||
3209 |
if (__isString(oldPath) && __isString(newPath)) { |
|
3210 |
#if defined(HAS_RENAME) |
|
3211 |
__BEGIN_INTERRUPTABLE__ |
|
3212 |
do { |
|
3213 |
ret = rename((char *) _stringVal(oldPath), (char *) _stringVal(newPath)); |
|
3214 |
} while (ret < 0 && errno == EINTR); |
|
3215 |
__END_INTERRUPTABLE__ |
|
3216 |
RETURN ( (ret >= 0) ? true : false ); |
|
359 | 3217 |
#else |
792 | 3218 |
# ifndef MSDOS_LIKE |
616 | 3219 |
if (link((char *) _stringVal(oldPath), (char *) _stringVal(newPath)) >= 0) { |
3220 |
if (unlink((char *) _stringVal(oldPath)) >= 0) { |
|
3221 |
RETURN ( true ); |
|
3222 |
} |
|
3223 |
unlink((char *) _stringVal(newPath)); |
|
3224 |
} |
|
792 | 3225 |
# endif |
616 | 3226 |
#endif |
3227 |
RETURN ( false ); |
|
3228 |
} |
|
792 | 3229 |
%}. |
3230 |
^ self primitiveFailed |
|
616 | 3231 |
|
3232 |
"OperatingSystem renameFile:'foo' to:'bar'" |
|
3233 |
! |
|
3234 |
||
3235 |
timeOfLastAccess:aPathName |
|
3236 |
"return the time, when the file was last accessed. |
|
3237 |
For nonexistent files, nil is returned." |
|
3238 |
||
3239 |
"could be implemented as: |
|
3240 |
(self infoOf:aPathName) at:#accessed |
|
3241 |
" |
|
3242 |
|timeLow timeHi| |
|
3243 |
%{ |
|
3244 |
struct stat buf; |
|
3245 |
time_t mtime; |
|
3246 |
int ret; |
|
3247 |
||
3248 |
if (__isString(aPathName)) { |
|
3249 |
__BEGIN_INTERRUPTABLE__ |
|
3250 |
do { |
|
3251 |
ret = stat((char *) _stringVal(aPathName), &buf); |
|
3252 |
} while (ret < 0 && errno == EINTR); |
|
3253 |
__END_INTERRUPTABLE__ |
|
3254 |
if (ret < 0) { |
|
3255 |
OperatingSystem_LastErrorNumber = _MKSMALLINT(errno); |
|
3256 |
RETURN (nil); |
|
3257 |
} |
|
3258 |
timeLow = _MKSMALLINT(buf.st_atime & 0xFFFF); |
|
3259 |
timeHi = _MKSMALLINT((buf.st_atime >> 16) & 0xFFFF); |
|
3260 |
} |
|
792 | 3261 |
%}. |
616 | 3262 |
timeLow notNil ifTrue:[^ AbsoluteTime fromOSTimeLow:timeLow and:timeHi]. |
792 | 3263 |
^ self primitiveFailed |
616 | 3264 |
|
3265 |
" |
|
3266 |
OperatingSystem timeOfLastAccess:'/' |
|
3267 |
" |
|
359 | 3268 |
! |
3269 |
||
616 | 3270 |
timeOfLastChange:aPathName |
3271 |
"return the time, when the file was last changed. |
|
3272 |
For nonexistent files, nil is returned." |
|
3273 |
||
3274 |
"could be implemented as: |
|
3275 |
(self infoOf:aPathName) at:#modified |
|
3276 |
" |
|
3277 |
||
3278 |
|timeLow timeHi| |
|
3279 |
%{ |
|
3280 |
struct stat buf; |
|
3281 |
int ret; |
|
3282 |
time_t mtime; |
|
3283 |
||
3284 |
if (__isString(aPathName)) { |
|
3285 |
__BEGIN_INTERRUPTABLE__ |
|
3286 |
do { |
|
3287 |
ret = stat((char *) _stringVal(aPathName), &buf); |
|
3288 |
} while (ret < 0 && errno == EINTR); |
|
3289 |
__END_INTERRUPTABLE__ |
|
3290 |
if (ret < 0) { |
|
3291 |
OperatingSystem_LastErrorNumber = _MKSMALLINT(errno); |
|
3292 |
RETURN ( nil ); |
|
3293 |
} |
|
3294 |
timeLow = _MKSMALLINT(buf.st_mtime & 0xFFFF); |
|
3295 |
timeHi = _MKSMALLINT((buf.st_mtime >> 16) & 0xFFFF); |
|
3296 |
} |
|
792 | 3297 |
%}. |
616 | 3298 |
timeLow notNil ifTrue:[^ AbsoluteTime fromOSTimeLow:timeLow and:timeHi]. |
792 | 3299 |
^ self primitiveFailed |
616 | 3300 |
|
3301 |
" |
|
3302 |
OperatingSystem timeOfLastChange:'/' |
|
3303 |
" |
|
3304 |
! |
|
3305 |
||
932
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3306 |
truncateFile:aPathName to:newSize |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3307 |
"change a files size return true on success, false on failure. |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3308 |
This may not be supported on all architectures." |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3309 |
|
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3310 |
%{ /* NOCONTEXT */ |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3311 |
#ifdef HAS_FTRUNCATE |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3312 |
int ret; |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3313 |
|
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3314 |
if (__isString(aPathName) |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3315 |
&& __isSmallInteger(newSize)) { |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3316 |
__BEGIN_INTERRUPTABLE__ |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3317 |
do { |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3318 |
ret = truncate((char *) _stringVal(aPathName), __intVal(newSize)); |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3319 |
} while (ret < 0 && errno == EINTR); |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3320 |
__END_INTERRUPTABLE__ |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3321 |
if (ret < 0) { |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3322 |
OperatingSystem_LastErrorNumber = _MKSMALLINT(errno); |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3323 |
RETURN ( false ); |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3324 |
} |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3325 |
RETURN (true); |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3326 |
} |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3327 |
#endif |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3328 |
%}. |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3329 |
^ self primitiveFailed |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3330 |
! |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
3331 |
|
616 | 3332 |
typeOf:aPathName |
3333 |
"return the type of a file as a symbol" |
|
3334 |
||
3335 |
" |
|
3336 |
this could have been implemented as: |
|
3337 |
(self infoOf:aPathName) at:#type |
|
3338 |
but for huge directory searches the code below is faster |
|
3339 |
" |
|
359 | 3340 |
|
3341 |
%{ /* NOCONTEXT */ |
|
616 | 3342 |
|
3343 |
struct stat buf; |
|
3344 |
int ret; |
|
3345 |
||
3346 |
if (__isString(aPathName)) { |
|
3347 |
__BEGIN_INTERRUPTABLE__ |
|
3348 |
do { |
|
3349 |
ret = stat((char *) _stringVal(aPathName), &buf); |
|
3350 |
} while (ret < 0 && errno == EINTR); |
|
3351 |
__END_INTERRUPTABLE__ |
|
3352 |
if (ret < 0) { |
|
3353 |
OperatingSystem_LastErrorNumber = _MKSMALLINT(errno); |
|
3354 |
RETURN ( nil ); |
|
3355 |
} |
|
3356 |
switch (buf.st_mode & S_IFMT) { |
|
3357 |
case S_IFDIR: |
|
3358 |
RETURN ( @symbol(directory) ); |
|
3359 |
case S_IFREG: |
|
3360 |
RETURN ( @symbol(regular) ); |
|
3361 |
#ifdef S_IFCHR |
|
3362 |
case S_IFCHR: |
|
3363 |
RETURN ( @symbol(characterSpecial) ); |
|
3364 |
#endif |
|
3365 |
#ifdef S_IFBLK |
|
3366 |
case S_IFBLK: |
|
3367 |
RETURN ( @symbol(blockSpecial) ); |
|
3368 |
#endif |
|
3369 |
#ifdef S_IFLNK |
|
3370 |
case S_IFLNK: |
|
3371 |
RETURN ( @symbol(symbolicLink) ); |
|
3372 |
#endif |
|
3373 |
#ifdef S_IFSOCK |
|
3374 |
case S_IFSOCK: |
|
3375 |
RETURN ( @symbol(socket) ); |
|
3376 |
#endif |
|
3377 |
#ifdef S_IFIFO |
|
3378 |
case S_IFIFO: |
|
3379 |
RETURN ( @symbol(fifo) ); |
|
3380 |
#endif |
|
3381 |
default: |
|
3382 |
RETURN ( @symbol(unknown) ); |
|
3383 |
} |
|
3384 |
} |
|
3385 |
%}. |
|
792 | 3386 |
^ self primitiveFailed |
616 | 3387 |
|
3388 |
" |
|
3389 |
OperatingSystem typeOf:'/' |
|
3390 |
OperatingSystem typeOf:'.' |
|
3391 |
OperatingSystem typeOf:'Make.proto' |
|
3392 |
" |
|
68 | 3393 |
! ! |
3394 |
||
63 | 3395 |
!OperatingSystem class methodsFor:'interrupts & signals'! |
3396 |
||
10 | 3397 |
blockInterrupts |
95 | 3398 |
"disable interrupt processing - if disabled, incoming |
3399 |
interrupts will be registered and handled as soon as |
|
3400 |
interrupts are reenabled by OperatingSystemclass>>unblockInterrupts. |
|
3401 |
Returns the previous blocking status i.e. true if interrupts |
|
3402 |
where already blocked. You need this information for proper |
|
3403 |
unblocking, in case of nested block/unblock calls." |
|
3404 |
||
3405 |
%{ /* NOCONTEXT */ |
|
710 | 3406 |
RETURN ( __BLOCKINTERRUPTS() ); |
10 | 3407 |
%} |
3408 |
! |
|
3409 |
||
616 | 3410 |
defaultSignal:signalNumber |
3411 |
"revert to the default action on arrival of a (Unix-)signal. |
|
3412 |
Dont confuse Unix signals with smalltalk signals. |
|
3413 |
WARNING: for some signals, it is no good idea to revert to default; |
|
3414 |
for example, the default for SIGINT (i.e. ^C) is to exit; while the |
|
3415 |
default for SIGQUIT (^ \) is to dump core. |
|
3416 |
Also, NOTICE that signal numbers are not portable between unix |
|
3417 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
3418 |
a signal." |
|
3419 |
||
3420 |
%{ /* NOCONTEXT */ |
|
3421 |
||
3422 |
if (__isSmallInteger(signalNumber)) { |
|
831 | 3423 |
#ifdef SIG_DFL |
616 | 3424 |
signal(_intVal(signalNumber), SIG_DFL); |
3425 |
RETURN (self); |
|
831 | 3426 |
#endif |
616 | 3427 |
} |
3428 |
%}. |
|
3429 |
" |
|
3430 |
this error is triggered on non-integer argument |
|
3431 |
" |
|
792 | 3432 |
^ self primitiveFailed |
616 | 3433 |
|
3434 |
"you better save a snapshot image before trying this ..." |
|
3435 |
" |
|
3436 |
'if you hit ^C now, Smalltalk will exit immediately' printNewline. |
|
3437 |
OperatingSystem defaultSignal:(OperatingSystem sigINT). |
|
3438 |
1 to:1000000 do:[:i| ]. |
|
3439 |
OperatingSystem enableSignal:(OperatingSystem sigINT). |
|
3440 |
'normal ^C handling again.' printNewline |
|
3441 |
" |
|
3442 |
! |
|
3443 |
||
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
3444 |
disableChildSignalInterrupts |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
3445 |
"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
|
3446 |
(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
|
3447 |
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
|
3448 |
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
|
3449 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
3450 |
^ 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
|
3451 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
3452 |
"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
|
3453 |
! |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
3454 |
|
616 | 3455 |
disableIOInterruptsOn:fd |
3456 |
"turn off IO interrupts for a filedescriptor" |
|
3457 |
||
3458 |
%{ /* NOCONTEXT */ |
|
3459 |
||
3460 |
int ret, flags, f; |
|
3461 |
||
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3462 |
#if (defined(F_GETFL) && defined(F_SETFL) && defined(FASYNC)) || defined(SYSV4) |
616 | 3463 |
if (__isSmallInteger(fd)) { |
3464 |
f = _intVal(fd); |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3465 |
# if defined(SYSV4) |
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
756
diff
changeset
|
3466 |
ret = ioctl(f, I_SETSIG, 0); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3467 |
# else /*! SYSV4*/ |
616 | 3468 |
flags = fcntl(f, F_GETFL, 0); |
3469 |
/* |
|
3470 |
* if already clear, there is no need for this syscall ... |
|
3471 |
*/ |
|
3472 |
if (flags & FASYNC) { |
|
3473 |
ret = fcntl(f, F_SETFL, flags & ~FASYNC); |
|
3474 |
if (ret >= 0) ret = flags; |
|
3475 |
} else { |
|
3476 |
ret = flags; |
|
3477 |
} |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3478 |
# endif /* !SYSV4 */ |
616 | 3479 |
RETURN ( _MKSMALLINT(ret) ); |
3480 |
} |
|
3481 |
#endif |
|
3482 |
%}. |
|
3483 |
" |
|
3484 |
this error is triggered on non-integer argument |
|
3485 |
or if the OS does not support IO interrupts. |
|
3486 |
" |
|
792 | 3487 |
^ self primitiveFailed |
10 | 3488 |
! |
3489 |
||
63 | 3490 |
disableSignal:signalNumber |
95 | 3491 |
"disable (Unix-) signal processing for signalNumber. |
3492 |
Dont confuse Unix signals with smalltalk signals. |
|
63 | 3493 |
WARNING: for some signals, it is no good idea to disable |
95 | 3494 |
them; for example, disabling the SIGINT signal turns off ^C |
63 | 3495 |
handling. |
68 | 3496 |
Also, NOTICE that signal numbers are not portable between unix |
3497 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
3498 |
a signal. |
|
63 | 3499 |
Use only for fully debugged stand alone applications." |
3500 |
||
3501 |
%{ /* NOCONTEXT */ |
|
3502 |
||
252 | 3503 |
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
|
3504 |
int sigNo = __intVal(signalNumber); |
831 | 3505 |
|
3506 |
if (sigNo == 0) { |
|
3507 |
RETURN (self); |
|
3508 |
} |
|
3509 |
#ifdef SIG_IGN |
|
3510 |
signal(sigNo, SIG_IGN); |
|
185 | 3511 |
RETURN (self); |
831 | 3512 |
#endif |
63 | 3513 |
} |
68 | 3514 |
%}. |
3515 |
" |
|
3516 |
this error is triggered on non-integer argument |
|
3517 |
" |
|
792 | 3518 |
^ self primitiveFailed |
68 | 3519 |
|
3520 |
" |
|
3521 |
'now, ^C is totally ignored ...' printNewline. |
|
3522 |
OperatingSystem disableSignal:(OperatingSystem sigINT). |
|
3523 |
1 to:1000000 do:[:i| ]. |
|
3524 |
OperatingSystem enableSignal:(OperatingSystem sigINT). |
|
3525 |
'^C handled again.' printNewline |
|
3526 |
" |
|
3527 |
! |
|
3528 |
||
616 | 3529 |
disableTimer |
831 | 3530 |
"disable timer interrupts. |
3531 |
WARNING: |
|
3532 |
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
|
3533 |
disabled, because no scheduling or timeouts are possible." |
616 | 3534 |
|
3535 |
%{ /* NOCONTEXT */ |
|
3536 |
||
3537 |
#if defined(ITIMER_REAL) |
|
3538 |
struct itimerval dt; |
|
3539 |
||
3540 |
dt.it_interval.tv_sec = 0; |
|
3541 |
dt.it_interval.tv_usec = 0; |
|
3542 |
dt.it_value.tv_sec = 0; |
|
3543 |
dt.it_value.tv_usec = 0; |
|
3544 |
setitimer(ITIMER_REAL, &dt, 0); |
|
3545 |
RETURN (true); |
|
831 | 3546 |
#endif /* ITIMER_REAL */ |
616 | 3547 |
%} |
3548 |
. |
|
3549 |
^ false |
|
3550 |
! |
|
3551 |
||
3552 |
disableUserInterrupts |
|
3553 |
"disable userInterrupt processing; |
|
3554 |
when disabled, no ^C processing takes place. |
|
831 | 3555 |
WARNING: |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3556 |
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
|
3557 |
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
|
3558 |
We recommend setting up a handler for the signal instead of disabling it." |
831 | 3559 |
|
3560 |
self disableSignal:(self sigBREAK). |
|
3561 |
self disableSignal:(self sigINT). |
|
616 | 3562 |
! |
3563 |
||
3564 |
enableAbortInterrupts |
|
3565 |
"enable abort signalhandling, and make it a regular signalInterrupt. |
|
3566 |
(the default will dump core and exit - which is not a good idea for |
|
3567 |
end-user applications ...). |
|
3568 |
This is especially useful, if linked-in C-libraries call abort() ..." |
|
3569 |
||
831 | 3570 |
self enableSignal:(self sigABRT) |
616 | 3571 |
! |
3572 |
||
3573 |
enableChildSignalInterrupts |
|
3574 |
"enable childSignal interrupts |
|
3575 |
(SIGCHLD, if the architecture supports it). |
|
831 | 3576 |
After enabling, these signals will send the message |
616 | 3577 |
'childSignalInterrupt' to the ChildSignalInterruptHandler object." |
3578 |
||
831 | 3579 |
self enableSignal:(self sigCHLD) |
616 | 3580 |
! |
3581 |
||
3582 |
enableFpExceptionInterrupts |
|
3583 |
"enable floating point exception interrupts (if the |
|
3584 |
architecture supports it). |
|
831 | 3585 |
After enabling, fpu-exceptions will send the message |
616 | 3586 |
'fpuExceptionInterrupt' to the FPUExceptionInterruptHandler object." |
3587 |
||
831 | 3588 |
self enableSignal:(self sigFP) |
616 | 3589 |
! |
3590 |
||
3591 |
enableHardSignalInterrupts |
|
3592 |
"enable hard signal exception interrupts (trap, buserror & segm. violation). |
|
831 | 3593 |
After enabling, these exceptions will send the message |
616 | 3594 |
'signalInterrupt' to the SignalInterruptHandler object." |
68 | 3595 |
|
855
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
3596 |
"/ 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
|
3597 |
"/ 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
|
3598 |
|
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
3599 |
"/ ... 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
|
3600 |
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
|
3601 |
|
640
be94dfc60eaa
Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents:
630
diff
changeset
|
3602 |
self enableSignal:(self sigBUS). |
be94dfc60eaa
Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents:
630
diff
changeset
|
3603 |
self enableSignal:(self sigSEGV) |
616 | 3604 |
! |
3605 |
||
3606 |
enableIOInterruptsOn:fd |
|
3607 |
"turn on IO interrupts for a filedescriptor" |
|
3608 |
||
3609 |
%{ /* NOCONTEXT */ |
|
3610 |
||
3611 |
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
|
3612 |
#ifndef __signalIoInterrupt |
616 | 3613 |
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
|
3614 |
#endif |
616 | 3615 |
static int firstCall = 1; |
3616 |
||
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3617 |
#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
|
3618 |
/* |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3619 |
* SIGIO/SIGPOLL - data available for I/O |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3620 |
* (used to wake up waiting processes) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3621 |
*/ |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3622 |
#ifdef SIGIO |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3623 |
# define THESIGNAL SIGIO |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3624 |
#else |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3625 |
# ifdef SIGPOLL |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3626 |
# define THESIGNAL SIGPOLL |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3627 |
# else |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3628 |
# ifdef SIGURG |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3629 |
# define THESIGNAL SIGURG |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3630 |
# endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3631 |
# endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3632 |
#endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3633 |
|
616 | 3634 |
if (__isSmallInteger(fd)) { |
3635 |
if (firstCall) { |
|
762
cea705669628
ok, stefan was right: HAS_SIGACTION works
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
3636 |
#ifdef HAS_SIGACTION |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3637 |
struct sigaction act; |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3638 |
|
763
7d5e32ed435e
dummy SA_xxx defs for systems which dont have them (HP & ultrix)
Claus Gittinger <cg@exept.de>
parents:
762
diff
changeset
|
3639 |
act.sa_flags = SA_RESTART | 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
|
3640 |
sigemptyset(&act.sa_mask); |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3641 |
act.sa_handler = __signalIoInterrupt; |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3642 |
sigaction(THESIGNAL, &act, 0); |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3643 |
#else |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
3644 |
# ifdef HAS_SIGVEC |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
3645 |
struct sigvec vec; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
3646 |
|
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
3647 |
vec.sv_flags = 0; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
3648 |
sigemptyset(&vec.sv_mask); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
3649 |
vec.sv_handler = __signalIoInterrupt; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
3650 |
sigvec(THESIGNAL, &vec, NULL); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
3651 |
# else |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3652 |
signal(THESIGNAL, __signalIoInterrupt); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
3653 |
# endif |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3654 |
#endif |
616 | 3655 |
firstCall = 0; |
3656 |
} |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3657 |
#undef THESIGNAL |
616 | 3658 |
|
3659 |
f = _intVal(fd); |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3660 |
# if defined(SYSV4) |
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
756
diff
changeset
|
3661 |
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
|
3662 |
# else /*! SYSV4*/ |
616 | 3663 |
flags = fcntl(f, F_GETFL, 0); |
3664 |
/* |
|
3665 |
* if already set, there is no need for this syscall ... |
|
3666 |
*/ |
|
3667 |
if (flags & FASYNC) { |
|
3668 |
ret = flags; |
|
3669 |
} else { |
|
3670 |
ret = fcntl(f, F_SETFL, flags | FASYNC); |
|
3671 |
if (ret >= 0) ret = flags; |
|
3672 |
} |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3673 |
# endif /*!SYSV4*/ |
616 | 3674 |
RETURN ( _MKSMALLINT(ret) ); |
68 | 3675 |
} |
616 | 3676 |
#endif |
68 | 3677 |
%}. |
3678 |
" |
|
3679 |
this error is triggered on non-integer argument |
|
616 | 3680 |
or if the system does not support SIGIO |
68 | 3681 |
" |
792 | 3682 |
^ self primitiveFailed |
616 | 3683 |
! |
3684 |
||
3685 |
enableQuitInterrupts |
|
3686 |
"enable quitInterrupt (usually ^\) handling, and make it a userInterrupt. |
|
3687 |
(the default will dump core and exit - which is not a good idea for |
|
3688 |
end-user applications ...)" |
|
3689 |
||
831 | 3690 |
self enableSignal:(self sigQUIT) |
68 | 3691 |
! |
3692 |
||
3693 |
enableSignal:signalNumber |
|
95 | 3694 |
"enable (Unix-)signal processing for signalNumber. |
3695 |
Dont confuse Unix signals with smalltalk signals. |
|
68 | 3696 |
The signal will be delivered to one of the standard handlers |
3697 |
(SIGINT, SIGQUIT, etc) or to a general handler, which |
|
3698 |
sends #signalInterrupt:. |
|
3699 |
||
3700 |
NOTICE that signal numbers are not portable between unix |
|
3701 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
3702 |
a signal." |
|
3703 |
||
3704 |
%{ /* NOCONTEXT */ |
|
3705 |
||
3706 |
#ifdef NSIG |
|
3707 |
# define SIG_LIMIT NSIG |
|
3708 |
#else |
|
3709 |
# ifdef SIGUSR2 |
|
3710 |
# define SIG_LIMIT SIGUSR2 |
|
3711 |
# else |
|
3712 |
# ifdef SIGUSR |
|
3713 |
# define SIG_LIMIT SIGUSR |
|
3714 |
# endif |
|
3715 |
# endif |
|
3716 |
#endif |
|
3717 |
||
3718 |
#if defined(SIGPOLL) && !defined(SIGIO) |
|
3719 |
# define SIGIO SIGPOLL |
|
3720 |
#endif |
|
3721 |
||
3722 |
#ifdef SIGCHLD |
|
3723 |
# define CHILD_SIGNAL SIGCHLD |
|
3724 |
#else |
|
3725 |
# ifdef SIGCLD |
|
3726 |
# define CHILD_SIGNAL SIGCLD |
|
3727 |
# endif |
|
3728 |
#endif |
|
3729 |
||
3730 |
int sigNr; |
|
443 | 3731 |
#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
|
3732 |
# ifndef __signalUserInterrupt |
831 | 3733 |
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
|
3734 |
# endif |
443 | 3735 |
#endif |
3736 |
#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
|
3737 |
# ifndef __signalFpExceptionInterrupt |
831 | 3738 |
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
|
3739 |
# endif |
443 | 3740 |
#endif |
3741 |
#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
|
3742 |
# ifndef __signalIoInterrupt |
831 | 3743 |
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
|
3744 |
# endif |
443 | 3745 |
#endif |
68 | 3746 |
#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
|
3747 |
# ifndef __signalChildInterrupt |
831 | 3748 |
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
|
3749 |
# endif |
68 | 3750 |
#endif |
443 | 3751 |
#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
|
3752 |
# ifndef __signalPIPEInterrupt |
831 | 3753 |
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
|
3754 |
# endif |
443 | 3755 |
#endif |
3756 |
#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
|
3757 |
# ifndef __signalBUSInterrupt |
831 | 3758 |
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
|
3759 |
# endif |
443 | 3760 |
#endif |
3761 |
#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
|
3762 |
# ifndef __signalSEGVInterrupt |
831 | 3763 |
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
|
3764 |
# endif |
443 | 3765 |
#endif |
3766 |
#ifdef SIGALRM |
|
831 | 3767 |
# 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
|
3768 |
# ifndef __signalTimerInterrupt |
831 | 3769 |
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
|
3770 |
# endif |
831 | 3771 |
# endif |
3772 |
#endif |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3773 |
#ifndef __signalInterrupt |
831 | 3774 |
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
|
3775 |
#endif |
831 | 3776 |
void (*handler)(SIGHANDLER_ARG); |
68 | 3777 |
|
252 | 3778 |
if (__isSmallInteger(signalNumber) |
831 | 3779 |
&& ((sigNr = _intVal(signalNumber)) >= 0) |
3780 |
#ifdef SIG_LIMIT |
|
3781 |
&& (sigNr <= SIG_LIMIT) |
|
3782 |
#endif |
|
3783 |
) { |
|
185 | 3784 |
/* |
3785 |
* standard signals are forced into standard handlers |
|
3786 |
* - all others go into general signalInterrupt |
|
3787 |
*/ |
|
68 | 3788 |
#if defined(SIGPOLL) && defined(SIGIO) |
185 | 3789 |
if (sigNr == SIGPOLL) |
3790 |
sigNr = SIGIO; |
|
68 | 3791 |
#endif |
185 | 3792 |
switch (sigNr) { |
831 | 3793 |
case 0: |
3794 |
/* enabling a non-supported signal */ |
|
3795 |
RETURN (self); |
|
3796 |
||
3797 |
#ifdef SIGBREAK |
|
3798 |
case SIGBREAK: |
|
3799 |
#endif |
|
443 | 3800 |
#ifdef SIGINT |
185 | 3801 |
case SIGINT: |
443 | 3802 |
#endif |
3803 |
#ifdef SIGQUIT |
|
185 | 3804 |
case SIGQUIT: |
443 | 3805 |
#endif |
831 | 3806 |
#if defined(SIGINT) || defined(SIGQUIT) || defined(SIGBREAK) |
329 | 3807 |
handler = __signalUserInterrupt; |
185 | 3808 |
break; |
443 | 3809 |
#endif |
3810 |
||
3811 |
#ifdef SIGFPE |
|
185 | 3812 |
case SIGFPE: |
329 | 3813 |
handler = __signalFpExceptionInterrupt; |
185 | 3814 |
break; |
443 | 3815 |
#endif |
3816 |
||
3817 |
#ifdef SIGPIPE |
|
185 | 3818 |
case SIGPIPE: |
329 | 3819 |
handler = __signalPIPEInterrupt; |
185 | 3820 |
break; |
443 | 3821 |
#endif |
68 | 3822 |
#ifdef SIGBUS |
185 | 3823 |
case SIGBUS: |
329 | 3824 |
handler = __signalBUSInterrupt; |
185 | 3825 |
break; |
68 | 3826 |
#endif |
443 | 3827 |
#ifdef SIGSEGV |
185 | 3828 |
case SIGSEGV: |
329 | 3829 |
handler = __signalSEGVInterrupt; |
185 | 3830 |
break; |
443 | 3831 |
#endif |
68 | 3832 |
#ifdef SIGIO |
185 | 3833 |
case SIGIO: |
329 | 3834 |
handler = __signalIoInterrupt; |
185 | 3835 |
break; |
68 | 3836 |
#endif |
3837 |
||
3838 |
#ifdef CHILD_SIGNAL |
|
185 | 3839 |
case CHILD_SIGNAL: |
329 | 3840 |
handler = __signalChildInterrupt; |
185 | 3841 |
break; |
68 | 3842 |
#endif |
443 | 3843 |
#ifdef SIGALRM |
831 | 3844 |
# ifndef WIN32 |
185 | 3845 |
case SIGALRM: |
329 | 3846 |
handler = __signalTimerInterrupt; |
185 | 3847 |
break; |
831 | 3848 |
# endif |
443 | 3849 |
#endif |
185 | 3850 |
|
3851 |
default: |
|
329 | 3852 |
handler = __signalInterrupt; |
185 | 3853 |
break; |
3854 |
} |
|
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
3855 |
|
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
3856 |
{ |
762
cea705669628
ok, stefan was right: HAS_SIGACTION works
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
3857 |
#ifdef HAS_SIGACTION |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
3858 |
struct sigaction act; |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
3859 |
|
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
3860 |
act.sa_flags = SA_RESTART | SA_SIGINFO; /* <- if you add more, remember dummys at the top */ |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
3861 |
sigemptyset(&act.sa_mask); |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
3862 |
act.sa_handler = handler; |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
3863 |
sigaction(sigNr, &act, 0); |
213 | 3864 |
#else |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
3865 |
# ifdef HAS_SIGVEC |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
3866 |
struct sigvec vec; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
3867 |
|
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
3868 |
vec.sv_flags = 0; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
3869 |
sigemptyset(&vec.sv_mask); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
3870 |
vec.sv_handler = handler; |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
3871 |
sigvec(sigNr, &vec, NULL); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
3872 |
# else |
831 | 3873 |
(void) signal(sigNr, handler); |
766
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
3874 |
# endif |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
3875 |
#endif |
9d6cc2cc834e
igvec (SIGVEC) stuff added (for ultrix)
Claus Gittinger <cg@exept.de>
parents:
765
diff
changeset
|
3876 |
} |
213 | 3877 |
|
185 | 3878 |
/* |
3879 |
* maybe, we should return the old enable-status |
|
3880 |
* as boolean here ... |
|
3881 |
*/ |
|
3882 |
RETURN (self); |
|
68 | 3883 |
} |
3884 |
%}. |
|
3885 |
||
3886 |
" |
|
3887 |
this error is triggered on non-integer argument, or |
|
3888 |
if the signal number is not in the valid range (1..NSIG) |
|
3889 |
" |
|
792 | 3890 |
^ self primitiveFailed |
63 | 3891 |
! |
3892 |
||
831 | 3893 |
enableTimer:milliSeconds |
616 | 3894 |
"trigger a timerInterrupt, to be signalled after some (real) time." |
3895 |
||
3896 |
%{ /* NOCONTEXT */ |
|
831 | 3897 |
int millis; |
3898 |
||
3899 |
millis = __intVal(milliSeconds); |
|
616 | 3900 |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3901 |
#if defined(ITIMER_REAL) |
831 | 3902 |
{ |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3903 |
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
|
3904 |
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
|
3905 |
#ifndef __signalTimerInterrupt |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3906 |
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
|
3907 |
#endif |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3908 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3909 |
if (firstCall) { |
831 | 3910 |
# ifdef HAS_SIGACTION |
3911 |
struct sigaction act; |
|
3912 |
||
3913 |
act.sa_flags = SA_RESTART | SA_SIGINFO; /* <- if you add more, remember dummys at the top */ |
|
3914 |
sigemptyset(&act.sa_mask); |
|
3915 |
act.sa_handler = __signalTimerInterrupt; |
|
3916 |
sigaction(SIGALRM, &act, 0); |
|
3917 |
# else |
|
3918 |
# 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
|
3919 |
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
|
3920 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3921 |
vec.sv_flags = 0; |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3922 |
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
|
3923 |
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
|
3924 |
sigvec(SIGALRM, &vec, NULL); |
831 | 3925 |
# else |
3926 |
signal(SIGALRM, __signalTimerInterrupt); |
|
3927 |
# endif |
|
3928 |
# endif |
|
3929 |
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
|
3930 |
} |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3931 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3932 |
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
|
3933 |
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
|
3934 |
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
|
3935 |
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
|
3936 |
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
|
3937 |
RETURN (true); |
831 | 3938 |
} |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
3939 |
#else |
831 | 3940 |
# ifdef WIN32 |
3941 |
{ |
|
3942 |
/* |
|
3943 |
* two mechanisms - which one to use ? |
|
3944 |
*/ |
|
3945 |
# define USE_TimerProc |
|
3946 |
# ifdef USE_TimerProc |
|
3947 |
||
3948 |
extern VOID CALLBACK __win32TimerProc(HWND, UINT, UINT, DWORD); |
|
3949 |
SetTimer(NULL, 0, millis, __win32TimerProc); |
|
3950 |
||
3951 |
# else /* USE_TimeProc */ |
|
3952 |
||
3953 |
extern void CALLBACK __win32TimeProc(UINT, UINT, DWORD, DWORD, DWORD, DWORD); |
|
3954 |
timeSetEvent(millis, 5, __win32TimeProc, 0, TIME_ONESHOT); |
|
3955 |
# endif |
|
640
be94dfc60eaa
Anforderung von SA_SIGINFO in sigaction.
Stefan Vogel <sv@exept.de>
parents:
630
diff
changeset
|
3956 |
} |
831 | 3957 |
# endif /* WIN32 */ |
3958 |
#endif /* ITIMER_REAL */ |
|
3959 |
%}. |
|
616 | 3960 |
^ false |
3961 |
! |
|
3962 |
||
1 | 3963 |
enableUserInterrupts |
3964 |
"enable userInterrupt (^C) handling; |
|
95 | 3965 |
when enabled, ^C in the terminal window will send the message |
3966 |
'userInterrupt' to the UserInterruptHandler object." |
|
1 | 3967 |
|
831 | 3968 |
self enableSignal:(self sigINT). |
3969 |
self enableSignal:(self sigBREAK). |
|
63 | 3970 |
! |
3971 |
||
616 | 3972 |
interruptPending |
3973 |
"return true, if an interrupt is pending. The returned value is |
|
3974 |
invalid if interrupts are not currently blocked, since otherwise |
|
3975 |
the interrupt is usually already handled before arriving here, |
|
3976 |
or may be served while returning from here." |
|
3977 |
||
3978 |
%{ /* NOCONTEXT */ |
|
3979 |
extern OBJ __INTERRUPTPENDING(); |
|
3980 |
||
3981 |
RETURN ( __INTERRUPTPENDING() ); |
|
3982 |
%} |
|
1 | 3983 |
! |
3984 |
||
704 | 3985 |
killProcess:processId |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3986 |
"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
|
3987 |
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
|
3988 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3989 |
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
|
3990 |
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
|
3991 |
OperatingSystem>>getStatusOfProcess:aProcessId." |
704 | 3992 |
|
3993 |
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
|
3994 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
3995 |
"Modified: 28.12.1995 / 15:06:18 / stefan" |
704 | 3996 |
! |
3997 |
||
616 | 3998 |
nameForSignal:aSignalNumber |
3999 |
"for a given Unix signalnumber, return a descriptive string" |
|
4000 |
||
4001 |
aSignalNumber == self sigHUP ifTrue:[^ 'hangup']. |
|
4002 |
aSignalNumber == self sigINT ifTrue:[^ 'interrupt']. |
|
4003 |
aSignalNumber == self sigKILL ifTrue:[^ 'kill']. |
|
4004 |
aSignalNumber == self sigQUIT ifTrue:[^ 'quit']. |
|
4005 |
aSignalNumber == self sigILL ifTrue:[^ 'illegal instruction']. |
|
4006 |
aSignalNumber == self sigTRAP ifTrue:[^ 'trap']. |
|
4007 |
aSignalNumber == self sigABRT ifTrue:[^ 'abort']. |
|
4008 |
aSignalNumber == self sigIOT ifTrue:[^ 'iot trap']. |
|
4009 |
aSignalNumber == self sigEMT ifTrue:[^ 'emt trap']. |
|
4010 |
aSignalNumber == self sigFP ifTrue:[^ 'fp exception']. |
|
4011 |
aSignalNumber == self sigBUS ifTrue:[^ 'bus error']. |
|
4012 |
aSignalNumber == self sigSEGV ifTrue:[^ 'segmentation violation']. |
|
4013 |
aSignalNumber == self sigSYS ifTrue:[^ 'bad system call']. |
|
4014 |
aSignalNumber == self sigPIPE ifTrue:[^ 'broken pipe']. |
|
4015 |
aSignalNumber == self sigALRM ifTrue:[^ 'alarm timer']. |
|
4016 |
aSignalNumber == self sigTERM ifTrue:[^ 'termination']. |
|
4017 |
aSignalNumber == self sigSTOP ifTrue:[^ 'stop']. |
|
4018 |
aSignalNumber == self sigTSTP ifTrue:[^ 'tty stop']. |
|
4019 |
aSignalNumber == self sigCONT ifTrue:[^ 'continue']. |
|
4020 |
aSignalNumber == self sigCHLD ifTrue:[^ 'child death']. |
|
4021 |
aSignalNumber == self sigTTIN ifTrue:[^ 'background tty input']. |
|
4022 |
aSignalNumber == self sigTTOU ifTrue:[^ 'background tty output']. |
|
4023 |
aSignalNumber == self sigIO ifTrue:[^ 'io available']. |
|
4024 |
aSignalNumber == self sigXCPU ifTrue:[^ 'cpu time expired']. |
|
4025 |
aSignalNumber == self sigXFSZ ifTrue:[^ 'file size limit']. |
|
4026 |
aSignalNumber == self sigVTALRM ifTrue:[^ 'virtual alarm timer']. |
|
4027 |
aSignalNumber == self sigPROF ifTrue:[^ 'profiling timer']. |
|
4028 |
aSignalNumber == self sigWINCH ifTrue:[^ 'winsize changed']. |
|
4029 |
aSignalNumber == self sigLOST ifTrue:[^ 'resource lost']. |
|
4030 |
aSignalNumber == self sigUSR1 ifTrue:[^ 'user signal 1']. |
|
4031 |
aSignalNumber == self sigUSR2 ifTrue:[^ 'user signal 2']. |
|
4032 |
aSignalNumber == self sigMSG ifTrue:[^ 'HFT message']. |
|
4033 |
aSignalNumber == self sigPWR ifTrue:[^ 'power-fail']. |
|
4034 |
aSignalNumber == self sigPRE ifTrue:[^ 'programming exception']. |
|
4035 |
aSignalNumber == self sigGRANT ifTrue:[^ 'HFT access wanted']. |
|
4036 |
aSignalNumber == self sigRETRACT ifTrue:[^ 'HFT access relinquish']. |
|
4037 |
aSignalNumber == self sigSOUND ifTrue:[^ 'HFT sound complete']. |
|
4038 |
aSignalNumber == self sigDANGER ifTrue:[^ 'low on paging space']. |
|
4039 |
||
4040 |
"notice: many systems map SIGPOLL and/or SIGUSR onto SIGIO |
|
4041 |
therefore, keep SIGIO always above the two below" |
|
4042 |
aSignalNumber == self sigPOLL ifTrue:[^ 'io available']. |
|
4043 |
aSignalNumber == self sigURG ifTrue:[^ 'urgent']. |
|
4044 |
||
4045 |
^ 'unknown signal' |
|
4046 |
||
68 | 4047 |
" |
616 | 4048 |
OperatingSystem nameForSignal:9 |
4049 |
OperatingSystem nameForSignal:(OperatingSystem sigPOLL) |
|
68 | 4050 |
" |
616 | 4051 |
! |
4052 |
||
4053 |
operatingSystemSignal:signalNumber |
|
4054 |
"return the signal to be raised when an |
|
4055 |
operatingSystem-signal occurs, or nil" |
|
4056 |
||
4057 |
OSSignals notNil ifTrue:[ |
|
4058 |
^ OSSignals at:signalNumber ifAbsent:[nil] |
|
4059 |
]. |
|
4060 |
^ nil |
|
10 | 4061 |
! |
4062 |
||
616 | 4063 |
operatingSystemSignal:signalNumber install:aSignal |
4064 |
"install a signal to be raised when an operatingSystem-signal occurs" |
|
4065 |
||
4066 |
OSSignals isNil ifTrue:[ |
|
4067 |
OSSignals := Array new:32 |
|
4068 |
]. |
|
4069 |
OSSignals at:signalNumber put:aSignal |
|
4070 |
! |
|
4071 |
||
4072 |
sendSignal:signalNumber to:processId |
|
4073 |
"send a unix signal to some process (maybe myself). |
|
4074 |
Returns false if any error occurred, true otherwise. |
|
4075 |
||
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4076 |
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
|
4077 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4078 |
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
|
4079 |
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
|
4080 |
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
|
4081 |
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
|
4082 |
|
616 | 4083 |
%{ |
792 | 4084 |
#ifndef MSDOS_LIKE |
616 | 4085 |
if (__bothSmallInteger(signalNumber, processId)) { |
4086 |
if (kill(__intVal(processId), __intVal(signalNumber)) < 0) { |
|
4087 |
OperatingSystem_LastErrorNumber = _MKSMALLINT(errno); |
|
4088 |
RETURN ( false ); |
|
216 | 4089 |
} |
616 | 4090 |
RETURN ( true ); |
10 | 4091 |
} |
792 | 4092 |
#endif |
68 | 4093 |
%}. |
792 | 4094 |
"/ |
4095 |
"/ either invalid argument (non-integers) |
|
4096 |
"/ or not supported by OS |
|
4097 |
"/ |
|
4098 |
^ self primitiveFailed |
|
1 | 4099 |
! |
4100 |
||
4101 |
startSpyTimer |
|
63 | 4102 |
"trigger a spyInterrupt, to be signalled after some short (virtual) time. |
359 | 4103 |
This is used by the old MessageTally for profiling. |
63 | 4104 |
Should be changed to use real profiling timer if available. |
68 | 4105 |
On systems, where no virtual timer is available, use the real timer |
359 | 4106 |
(which is of course less correct). |
4107 |
OBSOLETE: the new messageTally runs as a high prio process, not using |
|
4108 |
spy interrupts." |
|
1 | 4109 |
|
4110 |
%{ /* NOCONTEXT */ |
|
4111 |
||
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4112 |
#ifndef __spyInterrupt |
329 | 4113 |
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
|
4114 |
#endif |
10 | 4115 |
#if defined(ITIMER_VIRTUAL) |
1 | 4116 |
struct itimerval dt; |
4117 |
||
13 | 4118 |
# ifdef SIGVTALRM |
329 | 4119 |
signal(SIGVTALRM, __spyInterrupt); |
13 | 4120 |
# else |
329 | 4121 |
signal(SIGALRM, __spyInterrupt); |
13 | 4122 |
# endif |
4123 |
||
348 | 4124 |
dt.it_interval.tv_sec = 0; |
4125 |
dt.it_interval.tv_usec = 0; |
|
4126 |
dt.it_value.tv_sec = 0; |
|
4127 |
dt.it_value.tv_usec = 1000; /* 1000 Hz */ |
|
4128 |
setitimer(ITIMER_VIRTUAL, &dt, 0); |
|
4129 |
||
13 | 4130 |
RETURN (true); |
1 | 4131 |
#endif |
4132 |
%} |
|
13 | 4133 |
. |
4134 |
^ false |
|
1 | 4135 |
! |
4136 |
||
4137 |
stopSpyTimer |
|
359 | 4138 |
"stop spy timing - disable spy timer. |
4139 |
OBSOLETE: the new messageTally runs as a high prio process, not using |
|
4140 |
spy interrupts." |
|
1 | 4141 |
|
4142 |
%{ /* NOCONTEXT */ |
|
4143 |
||
10 | 4144 |
#if defined(ITIMER_VIRTUAL) |
1 | 4145 |
struct itimerval dt; |
4146 |
||
4147 |
dt.it_interval.tv_sec = 0; |
|
4148 |
dt.it_interval.tv_usec = 0; |
|
4149 |
dt.it_value.tv_sec = 0; |
|
4150 |
dt.it_value.tv_usec = 0; |
|
4151 |
setitimer(ITIMER_VIRTUAL, &dt, 0); |
|
13 | 4152 |
RETURN (true); |
10 | 4153 |
#endif |
4154 |
%} |
|
13 | 4155 |
. |
4156 |
^ false |
|
10 | 4157 |
! |
4158 |
||
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
4159 |
terminateProcess:processId |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
4160 |
"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
|
4161 |
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
|
4162 |
|
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4163 |
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
|
4164 |
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
|
4165 |
OperatingSystem>>getStatusOfProcess:aProcessId." |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
4166 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
4167 |
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
|
4168 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
4169 |
"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
|
4170 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
4171 |
|
616 | 4172 |
unblockInterrupts |
4173 |
"enable interrupt processing - if any interrupts are pending, |
|
4174 |
these will be handled immediately. |
|
4175 |
When unblocking interrupts, take care of nested block/unblock |
|
4176 |
calls - you must only unblock after a blockcall if they where |
|
4177 |
really not blocked before. See OperatingSystemclass>>blockInterrupts." |
|
4178 |
%{ |
|
4179 |
__UNBLOCKINTERRUPTS(); |
|
1040
60e4c4bbbca2
return nil from unblockInterrupts (thats what the inlined code returns)
Claus Gittinger <cg@exept.de>
parents:
1034
diff
changeset
|
4180 |
RETURN (nil); |
616 | 4181 |
%} |
4182 |
! ! |
|
4183 |
||
4184 |
!OperatingSystem class methodsFor:'misc'! |
|
4185 |
||
4186 |
exit |
|
710 | 4187 |
"shutdown smalltalk immediately - this method does not return. |
4188 |
Return 'good'-status (0) to the parent unix process." |
|
616 | 4189 |
|
4190 |
%{ /* NOCONTEXT */ |
|
4191 |
__mainExit(0); |
|
4192 |
%} |
|
4193 |
"OperatingSystem exit - dont evaluate this" |
|
4194 |
! |
|
4195 |
||
4196 |
exit:exitCode |
|
4197 |
"shutdown smalltalk immediately - |
|
4198 |
returning an exit-code to the parent unix process." |
|
4199 |
||
4200 |
%{ /* NOCONTEXT */ |
|
4201 |
int code = 1; |
|
4202 |
||
4203 |
if (__isSmallInteger(exitCode)) { |
|
4204 |
code = _intVal(exitCode); |
|
4205 |
} |
|
4206 |
__mainExit(code); |
|
4207 |
%} |
|
4208 |
"OperatingSystem exit:1 - dont evaluate this" |
|
4209 |
! |
|
4210 |
||
4211 |
exitWithCoreDump |
|
4212 |
"shutdown smalltalk immediately - dumping core. |
|
4213 |
This always returns 'bad'-status to the parent unix process. |
|
4214 |
Notice, that no cleanup is performed at all - you may have to |
|
4215 |
manually remove any tempfiles. |
|
4216 |
Use this only for debugging ST/X itself" |
|
4217 |
||
4218 |
%{ /* NOCONTEXT */ |
|
4219 |
abort(); |
|
4220 |
%} |
|
831 | 4221 |
" |
4222 |
OperatingSystem exitWithCoreDump - dont evaluate this |
|
4223 |
" |
|
616 | 4224 |
! |
4225 |
||
4226 |
slowFork:aBoolean |
|
4227 |
SlowFork := aBoolean |
|
4228 |
! ! |
|
4229 |
||
4230 |
!OperatingSystem class methodsFor:'os queries'! |
|
4231 |
||
4232 |
getCPUDefine |
|
831 | 4233 |
"return a string which was used to identify this CPU type when STX was |
616 | 4234 |
compiled, and which should be passed down when compiling methods. |
831 | 4235 |
For example, on linux, this may be '-Di386'; on a vax, this would be '-Dvax'. |
4236 |
This is normally not of interest to 'normal' users; however, it is passed |
|
4237 |
down to the c-compiler when methods are incrementally compiled to machine code." |
|
616 | 4238 |
|
4239 |
%{ /* NOCONTEXT */ |
|
831 | 4240 |
# ifndef CPU_DEFINE |
4241 |
# define CPU_DEFINE "-DunknownCPU" |
|
4242 |
# endif |
|
4243 |
||
616 | 4244 |
RETURN ( __MKSTRING(CPU_DEFINE COMMA_CON)); |
4245 |
%} |
|
4246 |
" |
|
4247 |
OperatingSystem getCPUDefine |
|
4248 |
" |
|
4249 |
! |
|
4250 |
||
4251 |
getCPUType |
|
4252 |
"return a string giving the type of machine we're running on. |
|
831 | 4253 |
Here, the machine for which ST/X was compiled is returned |
4254 |
(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
|
4255 |
This may normally not be of any interest to you ..." |
616 | 4256 |
|
4257 |
|cpu| |
|
4258 |
||
4259 |
%{ /* NOCONTEXT */ |
|
4260 |
||
4261 |
# ifdef vax |
|
4262 |
# define CPU_STRING "vax" |
|
4263 |
# endif |
|
4264 |
# ifdef mips |
|
4265 |
# define CPU_STRING "mips" |
|
4266 |
# endif |
|
4267 |
# ifdef i386 |
|
4268 |
# define CPU_STRING "i386" |
|
4269 |
# endif |
|
4270 |
# ifdef ns32k |
|
4271 |
# define CPU_STRING "ns32k" |
|
4272 |
# endif |
|
4273 |
# ifdef mc68k |
|
4274 |
# define CPU_STRING "mc68k" |
|
4275 |
# endif |
|
4276 |
# ifdef mc88k |
|
4277 |
# define CPU_STRING "mc88k" |
|
4278 |
# endif |
|
4279 |
# ifdef sparc |
|
4280 |
# define CPU_STRING "sparc" |
|
4281 |
# endif |
|
4282 |
# ifdef hppa |
|
4283 |
# define CPU_STRING "hppa" |
|
4284 |
# endif |
|
4285 |
# ifdef rs6000 |
|
4286 |
# define CPU_STRING "rs6000" |
|
4287 |
# endif |
|
831 | 4288 |
# ifdef powerPC |
4289 |
# define CPU_STRING "powerPC" |
|
4290 |
# endif |
|
616 | 4291 |
# ifdef alpha |
4292 |
# define CPU_STRING "alpha" |
|
4293 |
# endif |
|
4294 |
# ifdef transputer |
|
4295 |
# define CPU_STRING "transputer" |
|
4296 |
# endif |
|
4297 |
# ifdef ibm370 |
|
4298 |
# define CPU_STRING "ibm370" |
|
4299 |
# endif |
|
4300 |
||
4301 |
# ifndef CPU_STRING |
|
4302 |
# define CPU_STRING "unknown" |
|
4303 |
# endif |
|
4304 |
||
830 | 4305 |
cpu = __MKSTRING(CPU_STRING COMMA_CON); |
616 | 4306 |
# undef CPU_STRING |
831 | 4307 |
%}. |
616 | 4308 |
^ cpu |
4309 |
||
4310 |
" |
|
4311 |
OperatingSystem getCPUType |
|
4312 |
" |
|
4313 |
||
4314 |
"examples: are we running on a ss-10/solaris ?" |
|
4315 |
" |
|
4316 |
(OperatingSystem getCPUType = 'sparc') |
|
4317 |
and:[OperatingSystem getOSType = 'solaris'] |
|
4318 |
" |
|
4319 |
||
4320 |
"or on a pc/solaris ?" |
|
4321 |
" |
|
4322 |
(OperatingSystem getCPUType = 'i386') |
|
4323 |
and:[OperatingSystem getOSType = 'solaris'] |
|
4324 |
" |
|
4325 |
! |
|
4326 |
||
4327 |
getCommandOutputFrom:aCommand |
|
4328 |
"execute a simple command (such as hostname) and |
|
4329 |
return the commands output as a string" |
|
4330 |
||
4331 |
|p result| |
|
4332 |
||
4333 |
ForkFailed ifFalse:[ |
|
4334 |
PipeStream openErrorSignal handle:[:ex | |
|
4335 |
ForkFailed := true. |
|
4336 |
'OS: cannot fork/popen' errorPrintNL. |
|
4337 |
ex return. |
|
4338 |
] do:[ |
|
4339 |
p := PipeStream readingFrom:aCommand. |
|
4340 |
p notNil ifTrue:[ |
|
4341 |
result := p nextLine. |
|
4342 |
p close |
|
4343 |
] |
|
4344 |
] |
|
4345 |
]. |
|
4346 |
^ result |
|
4347 |
! |
|
4348 |
||
4349 |
getDomainName |
|
4350 |
"return the domain this host is in. |
|
4351 |
Notice: |
|
4352 |
not all systems support this; on some, 'unknown' is returned." |
|
4353 |
||
4354 |
|name| |
|
4355 |
||
4356 |
DomainName notNil ifTrue:[ |
|
4357 |
^ DomainName |
|
4358 |
]. |
|
4359 |
||
4360 |
%{ /* STACK: 2048 */ |
|
4361 |
#if defined(HAS_GETDOMAINNAME) |
|
4362 |
char buffer[128]; |
|
4363 |
||
4364 |
if (getdomainname(buffer, sizeof(buffer)) == 0) { |
|
830 | 4365 |
name = __MKSTRING(buffer COMMA_CON); |
616 | 4366 |
} |
4367 |
#else |
|
4368 |
# if defined(HAS_UNAME) && defined(HAS_UTS_DOMAINNAME) |
|
4369 |
struct utsname ubuff; |
|
4370 |
||
4371 |
if (uname(&ubuff) >= 0) { |
|
830 | 4372 |
name = __MKSTRING(ubuff.domainname COMMA_CON); |
616 | 4373 |
} |
4374 |
# endif |
|
4375 |
#endif |
|
4376 |
%}. |
|
4377 |
name isNil ifTrue:[ |
|
4378 |
name := self getEnvironment:'DOMAIN'. |
|
4379 |
name isNil ifTrue:[ |
|
4380 |
name := self getCommandOutputFrom:'domainname' |
|
4381 |
] |
|
4382 |
]. |
|
4383 |
name isNil ifTrue:[ |
|
4384 |
'OS: cannot find out domainname' errorPrintNL. |
|
4385 |
name := 'unknown'. |
|
4386 |
]. |
|
4387 |
DomainName := name. |
|
4388 |
^ name |
|
4389 |
||
4390 |
" |
|
4391 |
OperatingSystem getDomainName |
|
4392 |
" |
|
4393 |
! |
|
4394 |
||
4395 |
getEnvironment:aStringOrSymbol |
|
4396 |
"get an environment string" |
|
10 | 4397 |
|
4398 |
%{ /* NOCONTEXT */ |
|
4399 |
||
616 | 4400 |
char *env; |
4401 |
||
4402 |
if (__isString(aStringOrSymbol) || __isSymbol(aStringOrSymbol)) { |
|
4403 |
env = (char *)getenv(_stringVal(aStringOrSymbol)); |
|
4404 |
if (env) { |
|
830 | 4405 |
RETURN ( __MKSTRING(env COMMA_CON) ); |
616 | 4406 |
} |
4407 |
} |
|
4408 |
%} |
|
4409 |
. |
|
4410 |
^ nil |
|
4411 |
||
4412 |
" |
|
4413 |
OperatingSystem getEnvironment:'LANG' |
|
4414 |
OperatingSystem getEnvironment:'LOGIN' |
|
4415 |
OperatingSystem getEnvironment:'HOME' |
|
4416 |
OperatingSystem getEnvironment:'NNTPSERVER' |
|
4417 |
OperatingSystem getEnvironment:'MAIL' |
|
4418 |
OperatingSystem getEnvironment:'PATH' |
|
4419 |
" |
|
4420 |
! |
|
4421 |
||
4422 |
getHostName |
|
4423 |
"return the hostname we are running on - if there is |
|
4424 |
a HOST environment variable, we are much faster here ... |
|
4425 |
Notice: |
|
4426 |
not all systems support this; on some, 'unknown' is returned." |
|
4427 |
||
4428 |
|name| |
|
4429 |
||
4430 |
HostName notNil ifTrue:[ |
|
4431 |
^ HostName |
|
4432 |
]. |
|
4433 |
||
4434 |
%{ /* STACK: 2048 */ |
|
4435 |
#if defined(HAS_GETHOSTNAME) |
|
4436 |
char buffer[128]; |
|
4437 |
||
4438 |
if (gethostname(buffer, sizeof(buffer)) == 0) { |
|
830 | 4439 |
name = __MKSTRING(buffer COMMA_CON); |
616 | 4440 |
} |
4441 |
#else |
|
4442 |
# if defined(HAS_UNAME) |
|
4443 |
struct utsname ubuff; |
|
4444 |
||
4445 |
if (uname(&ubuff) >= 0) { |
|
830 | 4446 |
name = __MKSTRING(ubuff.nodename COMMA_CON); |
616 | 4447 |
} |
831 | 4448 |
# else |
4449 |
# ifdef WIN32 |
|
4450 |
char buffer[128]; |
|
4451 |
int buffSize = sizeof(buffer); |
|
4452 |
||
4453 |
if (GetComputerName(buffer, &buffSize) == TRUE) { |
|
4454 |
name = _MKSTRING(buffer COMMA_CON); |
|
4455 |
} |
|
4456 |
# endif |
|
1 | 4457 |
# endif |
616 | 4458 |
#endif |
4459 |
%}. |
|
4460 |
name isNil ifTrue:[ |
|
4461 |
name := self getEnvironment:'HOST'. |
|
4462 |
name isNil ifTrue:[ |
|
4463 |
name := self getCommandOutputFrom:'hostname' |
|
4464 |
] |
|
4465 |
]. |
|
4466 |
name isNil ifTrue:[ |
|
4467 |
'OS: cannot find out hostname' errorPrintNL. |
|
4468 |
name := 'unknown'. |
|
4469 |
]. |
|
4470 |
HostName := name. |
|
4471 |
^ name |
|
4472 |
||
4473 |
" |
|
4474 |
OperatingSystem getHostName |
|
4475 |
" |
|
4476 |
! |
|
4477 |
||
1034 | 4478 |
getLocaleInfo |
4479 |
"return a dictionary filled with values from the locale information; |
|
4480 |
Not all fields may be present, depending on the OS's setup and capabilities. |
|
4481 |
Possible fields are: |
|
4482 |
decimalPoint <String> |
|
4483 |
||
4484 |
thousandsSep <String> |
|
4485 |
||
4486 |
internationalCurrencySymbol <String> |
|
4487 |
||
4488 |
currencySymbol <String> |
|
4489 |
||
4490 |
monetaryDecimalPoint <String> |
|
4491 |
||
4492 |
monetaryThousandsSeparator <String> |
|
4493 |
||
4494 |
positiveSign <String> |
|
4495 |
||
4496 |
negativeSign <String> |
|
4497 |
||
4498 |
internationalFractionalDigits <Integer> |
|
4499 |
||
4500 |
fractionalDigits <Integer> |
|
4501 |
||
4502 |
positiveSignPrecedesCurrencySymbol <Boolean> |
|
4503 |
||
4504 |
negativeSignPrecedesCurrencySymbol <Boolean> |
|
4505 |
||
4506 |
positiveSignSeparatedBySpaceFromCurrencySymbol <Boolean> |
|
4507 |
||
4508 |
negativeSignSeparatedBySpaceFromCurrencySymbol <Boolean> |
|
4509 |
||
4510 |
positiveSignPosition <Symbol> |
|
4511 |
one of: #parenthesesAround, |
|
4512 |
#signPrecedes, |
|
4513 |
#signSuceeds, |
|
4514 |
#signPrecedesCurrencySymbol, |
|
4515 |
#signSuceedsCurrencySymbol |
|
4516 |
||
4517 |
negativeSignPosition <like above> |
|
4518 |
||
4519 |
it is up to the application to deal with undefined values. |
|
4520 |
||
4521 |
Notice, that (for now), the system does not use this information; |
|
4522 |
it should be used by applications as required. |
|
4523 |
" |
|
4524 |
||
4525 |
|info val| |
|
4526 |
||
4527 |
LocaleInfo notNil ifTrue:[ |
|
4528 |
"/ return the internal info; useful on systems which do not |
|
4529 |
"/ support this. |
|
4530 |
^ LocaleInfo |
|
4531 |
]. |
|
4532 |
||
4533 |
info := IdentityDictionary new. |
|
4534 |
%{ |
|
4535 |
char *decimalPoint; /* something like "." (US) or "," (german) */ |
|
4536 |
char *thousandsSep; /* something like "," (US) or "." (german) */ |
|
4537 |
char *intCurrencySymbol; /* international currency symbol; something like "USD " "DM " */ |
|
4538 |
char *currencySymbol; /* local currency symbol; something like "USD " "DM " */ |
|
4539 |
char *monDecimalPoint; /* money: decimal point */ |
|
4540 |
char *monThousandsSep; /* money: thousands sep */ |
|
4541 |
char *positiveSign; |
|
4542 |
char *negativeSign; |
|
4543 |
int intFractDigits; /* money: international digits after decPoint */ |
|
4544 |
int fractDigits; /* money: local digits after decPoint */ |
|
4545 |
int csPosPrecedes; /* money: 1 if currency symbol precedes a positive value; 0 if it sceeds */ |
|
4546 |
int csNegPrecedes; /* money: 1 if currency symbol precedes a negative value; 0 if it sceeds */ |
|
4547 |
int csPosSepBySpace; /* money: 1 if currency symbol should be separated by a space from a positive value; 0 if no space */ |
|
4548 |
int csNegSepBySpace; /* money: 1 if currency symbol should be separated by a space from a negative value; 0 if no space */ |
|
4549 |
int csPosSignPosition; /* money: 0: ()'s around the value & currency symbol */ |
|
4550 |
int csNegSignPosition; /* 1: sign precedes the value & currency symbol */ |
|
4551 |
/* 2: sign succeeds the value & currency symbol */ |
|
4552 |
/* 3: sign immediately precedes the currency symbol */ |
|
4553 |
/* 4: sign immediately suceeds the currency symbol */ |
|
4554 |
||
4555 |
#if defined(HAS_LOCALECONV) |
|
4556 |
struct lconv *conf; |
|
4557 |
||
4558 |
conf = localeconv(); |
|
4559 |
if (conf) { |
|
4560 |
decimalPoint = conf->decimal_point; |
|
4561 |
thousandsSep = conf->thousands_sep; |
|
4562 |
intCurrencySymbol = conf->int_curr_symbol; |
|
4563 |
currencySymbol = conf->currency_symbol; |
|
4564 |
monDecimalPoint = conf->mon_decimal_point; |
|
4565 |
monThousandsSep = conf->mon_thousands_sep; |
|
4566 |
positiveSign = conf->positive_sign; |
|
4567 |
negativeSign = conf->negative_sign; |
|
4568 |
intFractDigits = conf->int_frac_digits; |
|
4569 |
fractDigits = conf->frac_digits; |
|
4570 |
csPosPrecedes = conf->p_cs_precedes; |
|
4571 |
csNegPrecedes = conf->n_cs_precedes; |
|
4572 |
csPosSepBySpace = conf->p_sep_by_space; |
|
4573 |
csNegSepBySpace = conf->n_sep_by_space; |
|
4574 |
csPosSignPosition = conf->p_sign_posn; |
|
4575 |
csNegSignPosition = conf->n_sign_posn; |
|
4576 |
} |
|
4577 |
#else |
|
4578 |
decimalPoint = (char *)0; |
|
4579 |
thousandsSep = (char *)0; |
|
4580 |
intCurrencySymbol = (char *)0; |
|
4581 |
currencySymbol = (char *)0; |
|
4582 |
monDecimalPoint = (char *)0; |
|
4583 |
monThousandsSep = (char *)0; |
|
4584 |
positiveSign = (char *)0; |
|
4585 |
negativeSign =(char *)0; |
|
4586 |
intFractDigits = -1; |
|
4587 |
fractDigits = -1; |
|
4588 |
csPosPrecedes = -1; |
|
4589 |
csNegPrecedes = -1; |
|
4590 |
csPosSepBySpace = -1; |
|
4591 |
csNegSepBySpace = -1; |
|
4592 |
csPosSignPosition = -1; |
|
4593 |
csNegSignPosition = -1; |
|
4594 |
#endif |
|
4595 |
if (decimalPoint) { |
|
4596 |
val = __MKSTRING(decimalPoint); |
|
4597 |
__AT_PUT_(info, @symbol(decimalPoint), val); |
|
4598 |
} |
|
4599 |
if (thousandsSep) { |
|
4600 |
val = __MKSTRING(thousandsSep); |
|
4601 |
__AT_PUT_(info, @symbol(thousandsSeparator), val); |
|
4602 |
} |
|
4603 |
if (intCurrencySymbol) { |
|
4604 |
val = __MKSTRING(intCurrencySymbol); |
|
4605 |
__AT_PUT_(info, @symbol(internationCurrencySymbol), val); |
|
4606 |
} |
|
4607 |
if (currencySymbol) { |
|
4608 |
val = __MKSTRING(currencySymbol); |
|
4609 |
__AT_PUT_(info, @symbol(currencySymbol), val); |
|
4610 |
} |
|
4611 |
if (monDecimalPoint) { |
|
4612 |
val = __MKSTRING(monDecimalPoint); |
|
4613 |
__AT_PUT_(info, @symbol(monetaryDecimalPoint), val); |
|
4614 |
} |
|
4615 |
if (monThousandsSep) { |
|
4616 |
val = __MKSTRING(monThousandsSep); |
|
4617 |
__AT_PUT_(info, @symbol(monetaryThousandsSeparator), val); |
|
4618 |
} |
|
4619 |
if (positiveSign) { |
|
4620 |
val = __MKSTRING(positiveSign); |
|
4621 |
__AT_PUT_(info, @symbol(positiveSign), val); |
|
4622 |
} |
|
4623 |
if (negativeSign) { |
|
4624 |
val = __MKSTRING(negativeSign); |
|
4625 |
__AT_PUT_(info, @symbol(negativeSign), val); |
|
4626 |
} |
|
4627 |
if (intFractDigits >= 0) { |
|
4628 |
__AT_PUT_(info, @symbol(internationalFractionalDigits), __MKSMALLINT(intFractDigits)); |
|
4629 |
} |
|
4630 |
if (fractDigits >= 0) { |
|
4631 |
__AT_PUT_(info, @symbol(fractionalDigits), __MKSMALLINT(fractDigits)); |
|
4632 |
} |
|
4633 |
if (csPosPrecedes >= 0) { |
|
4634 |
if (csPosPrecedes == 0) { |
|
4635 |
val = false; |
|
4636 |
} else { |
|
4637 |
val = true; |
|
4638 |
} |
|
4639 |
__AT_PUT_(info, @symbol(positiveSignPrecedesCurrencySymbol), val ); |
|
4640 |
} |
|
4641 |
if (csNegPrecedes >= 0) { |
|
4642 |
if (csNegPrecedes == 0) { |
|
4643 |
val = false; |
|
4644 |
} else { |
|
4645 |
val = true; |
|
4646 |
} |
|
4647 |
__AT_PUT_(info, @symbol(negativeSignPrecedesCurrencySymbol), val ); |
|
4648 |
} |
|
4649 |
if (csPosSepBySpace >= 0) { |
|
4650 |
if (csPosSepBySpace == 0) { |
|
4651 |
val = false; |
|
4652 |
} else { |
|
4653 |
val = true; |
|
4654 |
} |
|
4655 |
__AT_PUT_(info, @symbol(positiveSignSeparatedBySpaceFromCurrencySymbol), val); |
|
4656 |
} |
|
4657 |
if (csNegSepBySpace >= 0) { |
|
4658 |
if (csNegSepBySpace == 0) { |
|
4659 |
val = false; |
|
4660 |
} else { |
|
4661 |
val = true; |
|
4662 |
} |
|
4663 |
__AT_PUT_(info, @symbol(negativeSignSeparatedBySpaceFromCurrencySymbol), val); |
|
4664 |
} |
|
4665 |
switch (csPosSignPosition) { |
|
4666 |
case 0: |
|
4667 |
val = @symbol(parenthesesAround); |
|
4668 |
break; |
|
4669 |
||
4670 |
case 1: |
|
4671 |
val = @symbol(signPrecedes); |
|
4672 |
break; |
|
4673 |
||
4674 |
case 2: |
|
4675 |
val = @symbol(signSuceeds); |
|
4676 |
break; |
|
4677 |
||
4678 |
case 3: |
|
4679 |
val = @symbol(signPrecedesCurrencySymbol); |
|
4680 |
break; |
|
4681 |
||
4682 |
case 4: |
|
4683 |
val = @symbol(signSuceedsCurrencySymbol); |
|
4684 |
break; |
|
4685 |
||
4686 |
default: |
|
4687 |
val = nil; |
|
4688 |
} |
|
4689 |
if (val != nil) { |
|
4690 |
__AT_PUT_(info, @symbol(positiveSignPosition), val); |
|
4691 |
} |
|
4692 |
||
4693 |
switch (csNegSignPosition) { |
|
4694 |
case 0: |
|
4695 |
val = @symbol(parenthesesAround); |
|
4696 |
break; |
|
4697 |
||
4698 |
case 1: |
|
4699 |
val = @symbol(signPrecedes); |
|
4700 |
break; |
|
4701 |
||
4702 |
case 2: |
|
4703 |
val = @symbol(signSuceeds); |
|
4704 |
break; |
|
4705 |
||
4706 |
case 3: |
|
4707 |
val = @symbol(signPrecedesCurrencySymbol); |
|
4708 |
break; |
|
4709 |
||
4710 |
case 4: |
|
4711 |
val = @symbol(signSuceedsCurrencySymbol); |
|
4712 |
break; |
|
4713 |
||
4714 |
default: |
|
4715 |
val = nil; |
|
4716 |
} |
|
4717 |
if (val != nil) { |
|
4718 |
__AT_PUT_(info, @symbol(negativeSignPosition), val); |
|
4719 |
} |
|
4720 |
%}. |
|
4721 |
^ info |
|
4722 |
||
4723 |
" |
|
4724 |
OperatingSystem getLocaleInfo |
|
4725 |
" |
|
4726 |
||
4727 |
"Created: 23.12.1995 / 14:19:20 / cg" |
|
4728 |
! |
|
4729 |
||
616 | 4730 |
getOSDefine |
4731 |
"return a string which was used to identify this machine when stx was |
|
4732 |
compiled, and which should be passed down when compiling methods. |
|
4733 |
For example, on linux, this is '-DLINUX'." |
|
4734 |
||
4735 |
%{ /* NOCONTEXT */ |
|
831 | 4736 |
#ifdef WIN32 |
4737 |
# ifndef OS_DEFINE |
|
4738 |
# define OS_DEFINE "-DWIN32" |
|
4739 |
# endif |
|
4740 |
#endif |
|
4741 |
||
616 | 4742 |
#ifndef OS_DEFINE |
4743 |
# define OS_DEFINE "-DunknownOS" |
|
4744 |
#endif |
|
831 | 4745 |
|
616 | 4746 |
RETURN ( __MKSTRING(OS_DEFINE COMMA_CON)); |
4747 |
%} |
|
4748 |
" |
|
4749 |
OperatingSystem getOSDefine |
|
4750 |
" |
|
4751 |
! |
|
4752 |
||
4753 |
getOSType |
|
4754 |
"return a string giving the type of OS we're running on. |
|
4755 |
This can be used to adapt programs to certain environment |
|
4756 |
differences (for example: mail-lock strategy ...)" |
|
4757 |
||
4758 |
|os| |
|
4759 |
||
4760 |
%{ /* NOCONTEXT */ |
|
4761 |
||
4762 |
# ifdef MSDOS |
|
4763 |
# define OS_STRING "msdos" |
|
4764 |
# endif |
|
4765 |
||
831 | 4766 |
# ifdef WIN32 |
4767 |
char *OS_STRING = "win32"; |
|
4768 |
||
4769 |
# endif |
|
4770 |
||
616 | 4771 |
# ifdef MSWINDOWS |
4772 |
# define OS_STRING "mswindows" |
|
4773 |
# endif |
|
4774 |
||
4775 |
# ifdef NT |
|
4776 |
# define OS_STRING "nt" |
|
4777 |
# endif |
|
4778 |
||
4779 |
# ifdef VMS |
|
4780 |
# define OS_STRING "vms" |
|
4781 |
# endif |
|
4782 |
||
4783 |
# ifdef MVS |
|
4784 |
# define OS_STRING "mvs" |
|
4785 |
# endif |
|
4786 |
||
4787 |
# ifdef OS2 |
|
4788 |
# define OS_STRING "os2" |
|
4789 |
# endif |
|
4790 |
||
4791 |
# ifdef sinix |
|
4792 |
# define OS_STRING "sinix" |
|
4793 |
# endif |
|
4794 |
||
4795 |
# ifdef ultrix |
|
4796 |
# define OS_STRING "ultrix" |
|
4797 |
# endif |
|
4798 |
||
4799 |
# ifdef sco |
|
4800 |
# define OS_STRING "sco" |
|
4801 |
# endif |
|
4802 |
||
4803 |
# ifdef hpux |
|
4804 |
# define OS_STRING "hpux" |
|
4805 |
# endif |
|
4806 |
||
4807 |
# ifdef LINUX |
|
4808 |
# define OS_STRING "linux" |
|
4809 |
# endif |
|
4810 |
||
4811 |
# ifdef sunos |
|
4812 |
# define OS_STRING "sunos" |
|
4813 |
# endif |
|
4814 |
||
4815 |
# ifdef solaris |
|
4816 |
# define OS_STRING "solaris" |
|
4817 |
# endif |
|
4818 |
||
4819 |
# ifdef IRIS |
|
4820 |
# define OS_STRING "irix" |
|
4821 |
# endif |
|
4822 |
||
4823 |
# ifdef aix |
|
4824 |
# define OS_STRING "aix" |
|
4825 |
# endif |
|
4826 |
||
4827 |
# ifdef realIX |
|
4828 |
# define OS_STRING "realIX" |
|
4829 |
# endif |
|
4830 |
||
4831 |
/* |
|
4832 |
* no concrete info; become somewhat vague ... |
|
4833 |
*/ |
|
4834 |
# ifndef OS_STRING |
|
4835 |
# ifdef MACH |
|
4836 |
# define OS_STRING "mach" |
|
4837 |
# endif |
|
4838 |
# endif |
|
4839 |
||
4840 |
# ifndef OS_STRING |
|
4841 |
# ifdef BSD |
|
4842 |
# define OS_STRING "bsd" |
|
4843 |
# endif |
|
4844 |
||
4845 |
# ifdef SYSV |
|
4846 |
# ifdef SYSV3 |
|
4847 |
# define OS_STRING "sys5_3" |
|
4848 |
# else |
|
4849 |
# ifdef SYSV4 |
|
4850 |
# define OS_STRING "sys5_4" |
|
4851 |
# else |
|
4852 |
# define OS_STRING "sys5" |
|
4853 |
# endif |
|
4854 |
# endif |
|
4855 |
# endif |
|
4856 |
# endif |
|
4857 |
||
4858 |
/* |
|
4859 |
* become very vague ... |
|
4860 |
*/ |
|
4861 |
# ifndef OS_STRING |
|
4862 |
# ifdef POSIX |
|
4863 |
# define OS_STRING "posix" |
|
4864 |
# endif |
|
4865 |
# endif |
|
4866 |
# ifndef OS_STRING |
|
4867 |
# ifdef UNIX |
|
4868 |
# define OS_STRING "unix" |
|
4869 |
# endif |
|
4870 |
# endif |
|
4871 |
||
4872 |
# ifndef OS_STRING |
|
4873 |
# define OS_STRING "unknown" |
|
4874 |
# endif |
|
4875 |
||
830 | 4876 |
os = __MKSTRING(OS_STRING COMMA_CON); |
616 | 4877 |
# undef OS_STRING |
831 | 4878 |
%}. |
616 | 4879 |
^ os |
4880 |
||
4881 |
"OperatingSystem getOSType" |
|
4882 |
! |
|
4883 |
||
4884 |
getProcessId |
|
4885 |
"return the (unix-)processId" |
|
4886 |
||
4887 |
%{ /* NOCONTEXT */ |
|
4888 |
||
4889 |
int pid = 0; |
|
4890 |
#ifdef UNIX_LIKE |
|
4891 |
pid = getpid(); |
|
4892 |
#endif |
|
4893 |
RETURN ( _MKSMALLINT(pid) ); |
|
4894 |
%} |
|
4895 |
" |
|
4896 |
OperatingSystem getProcessId |
|
4897 |
" |
|
4898 |
! |
|
4899 |
||
4900 |
getSystemID |
|
4901 |
"if supported by the OS, return the systemID; |
|
4902 |
a unique per machine identification. |
|
4903 |
WARNING: |
|
4904 |
not all systems support this; on some, 'unknown' is returned." |
|
4905 |
||
4906 |
%{ /* NO_CONTEXT */ |
|
4907 |
#if defined(IRIX5) && !defined(HAS_GETHOSTID) |
|
4908 |
char idBuffer[MAXSYSIDSIZE]; |
|
4909 |
int retVal; |
|
4910 |
OBJ arr; |
|
4911 |
||
4912 |
if ((retVal = syssgi(SGI_SYSID, idBuffer)) == 0) { |
|
4913 |
arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(MAXSYSIDSIZE); |
|
4914 |
bcopy(idBuffer, __ByteArrayInstPtr(arr)->ba_element, MAXSYSIDSIZE); |
|
4915 |
RETURN (arr); |
|
4916 |
} |
|
4917 |
#endif |
|
4918 |
#if defined(HAS_GETHOSTID) |
|
4919 |
int runningId; |
|
4920 |
OBJ arr; |
|
4921 |
||
4922 |
runningId = gethostid(); |
|
4923 |
arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(4); |
|
4924 |
*(int *)(__ByteArrayInstPtr(arr)->ba_element) = runningId; |
|
4925 |
RETURN (arr); |
|
4926 |
#endif |
|
4927 |
%}. |
|
4928 |
^ 'unknown' |
|
4929 |
||
4930 |
" |
|
4931 |
OperatingSystem getSystemID |
|
4932 |
" |
|
4933 |
! |
|
4934 |
||
4935 |
getSystemInfo |
|
831 | 4936 |
"return info on the system weare running on. |
4937 |
If the system supports the uname system call, that info is returned; |
|
616 | 4938 |
otherwise, some simulated info is returned. |
831 | 4939 |
|
616 | 4940 |
WARNING: |
831 | 4941 |
Do not depend on the amount and contents of the returned information, some |
4942 |
systems may return more/less than others. Also, the contents depends on the |
|
4943 |
OS, for example, linux returns 'ix86', while WIN32 returns 'x86'. |
|
4944 |
||
4945 |
This method is mainly provided to augment error reports with some system |
|
4946 |
information. |
|
4947 |
(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
|
4948 |
may be based upon this info) |
616 | 4949 |
|
4950 |
The returned info may (or may not) contain: |
|
831 | 4951 |
#system -> some operating system identification (irix, Linux, nt, win32s ...) |
4952 |
#version -> OS version (some os version identification) |
|
4953 |
#release -> OS release (3.5, 1.2.1 ...) |
|
4954 |
#node -> some host identification (hostname) |
|
4955 |
#domain -> domain name (hosts domain) |
|
4956 |
#machine -> type of machine (i586, mips ...) |
|
616 | 4957 |
" |
4958 |
||
4959 |
|sys node rel ver mach dom mtyp brel info| |
|
4960 |
||
4961 |
%{ /* STACK: 2048 */ |
|
4962 |
#if defined(HAS_UNAME) |
|
4963 |
struct utsname ubuff; |
|
4964 |
||
4965 |
if (uname(&ubuff) >= 0) { |
|
830 | 4966 |
sys = __MKSTRING(ubuff.sysname COMMA_CON); |
4967 |
node = __MKSTRING(ubuff.nodename COMMA_CON); |
|
4968 |
rel = __MKSTRING(ubuff.release COMMA_CON); |
|
4969 |
ver = __MKSTRING(ubuff.version COMMA_CON); |
|
4970 |
mach = __MKSTRING(ubuff.machine COMMA_CON); |
|
616 | 4971 |
# ifdef HAS_UTS_DOMAINNAME |
830 | 4972 |
dom = __MKSTRING(ubuff.domainname COMMA_CON); |
616 | 4973 |
# endif |
4974 |
} |
|
831 | 4975 |
#else /* no uname */ |
4976 |
# ifdef WIN32 |
|
4977 |
||
4978 |
char vsnBuffer[32]; |
|
4979 |
char *s; |
|
4980 |
int winVer; |
|
4981 |
DWORD vsn; |
|
4982 |
SYSTEM_INFO sysInfo; |
|
4983 |
||
4984 |
vsn = GetVersion(); |
|
4985 |
||
4986 |
if (HIWORD(vsn) & 0x8000) { |
|
4987 |
s = "win32s"; |
|
4988 |
} else { |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4989 |
s = "nt"; |
831 | 4990 |
} |
4991 |
sys = __MKSTRING(s COMMA_CON); |
|
4992 |
winVer = LOWORD(vsn); |
|
4993 |
sprintf(vsnBuffer, "%d.%d", LOBYTE(winVer), HIBYTE(winVer)); |
|
4994 |
rel = __MKSTRING(vsnBuffer COMMA_CON); |
|
4995 |
||
4996 |
GetSystemInfo(&sysInfo); |
|
4997 |
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
|
4998 |
sprintf(vsnBuffer, "%d", sysInfo.dwProcessorType); |
831 | 4999 |
mach = __MKSTRING(vsnBuffer COMMA_CON); |
5000 |
} |
|
5001 |
||
5002 |
# endif /* WIN32 */ |
|
5003 |
#endif /* no uname */ |
|
616 | 5004 |
%}. |
5005 |
sys isNil ifTrue:[ |
|
5006 |
sys := self getSystemType. |
|
5007 |
]. |
|
5008 |
node isNil ifTrue:[ |
|
5009 |
node := self getHostName |
|
5010 |
]. |
|
5011 |
dom isNil ifTrue:[ |
|
5012 |
dom := self getDomainName |
|
5013 |
]. |
|
831 | 5014 |
mach isNil ifTrue:[ |
5015 |
mach := self getCPUType |
|
5016 |
]. |
|
616 | 5017 |
|
5018 |
info := IdentityDictionary new. |
|
5019 |
info at:#system put:sys. |
|
5020 |
info at:#node put:node. |
|
5021 |
rel notNil ifTrue:[info at:#release put:rel]. |
|
5022 |
ver notNil ifTrue:[info at:#version put:ver]. |
|
5023 |
mach notNil ifTrue:[info at:#machine put:mach]. |
|
5024 |
dom notNil ifTrue:[info at:#domain put:dom]. |
|
5025 |
^ info |
|
5026 |
||
5027 |
" |
|
5028 |
OperatingSystem getSystemInfo |
|
5029 |
" |
|
5030 |
! |
|
5031 |
||
5032 |
getSystemType |
|
5033 |
"return a string giving the type of system we're running on. |
|
5034 |
This is almost the same as getOSType, but the returned string |
|
5035 |
is slightly different for some systems (i.e. iris vs. irix). |
|
5036 |
Dont depend on this - use getOSType. I dont really see a point |
|
831 | 5037 |
here ... |
5038 |
(except for slight differences between next/mach and other machs)" |
|
616 | 5039 |
|
5040 |
|sys| |
|
5041 |
||
5042 |
%{ |
|
5043 |
# ifdef NEXT |
|
5044 |
# define SYS_STRING "next" |
|
5045 |
# endif |
|
5046 |
||
5047 |
# ifdef IRIS |
|
5048 |
# define SYS_STRING "iris" |
|
5049 |
# endif |
|
5050 |
||
831 | 5051 |
# ifdef WIN32 |
5052 |
# define SYS_STRING "win32" |
|
5053 |
# endif |
|
5054 |
||
616 | 5055 |
# ifdef SYS_STRING |
830 | 5056 |
sys = __MKSTRING(SYS_STRING COMMA_CON); |
616 | 5057 |
# undef SYS_STRING |
5058 |
# endif |
|
831 | 5059 |
%}. |
616 | 5060 |
sys isNil ifTrue:[ |
5061 |
^ self getOSType |
|
5062 |
]. |
|
5063 |
^ sys |
|
5064 |
||
5065 |
" |
|
5066 |
OperatingSystem getSystemType |
|
5067 |
" |
|
5068 |
! |
|
5069 |
||
5070 |
isBSDlike |
|
5071 |
"return true, if the OS we're running on is a 'real' unix." |
|
5072 |
||
5073 |
%{ /* NOCONTEXT */ |
|
5074 |
||
5075 |
#if defined(BSD) || defined(MACH) || defined(SYSV4) |
|
5076 |
RETURN ( true ); |
|
13 | 5077 |
#endif |
831 | 5078 |
%}. |
13 | 5079 |
^ false |
10 | 5080 |
! |
5081 |
||
616 | 5082 |
isMSDOSlike |
5083 |
"return true, if the OS we're running on is dos like |
|
5084 |
(in contrast to unix-like)." |
|
5085 |
||
5086 |
%{ /* NOCONTEXT */ |
|
5087 |
||
5088 |
#if defined(MSDOS_LIKE) |
|
5089 |
RETURN ( true ); |
|
5090 |
#endif |
|
831 | 5091 |
%}. |
616 | 5092 |
^ false |
5093 |
! |
|
5094 |
||
831 | 5095 |
isMSWINDOWSlike |
5096 |
"return true, if the OS we're running on is MS-Windows like." |
|
5097 |
||
5098 |
%{ /* NOCONTEXT */ |
|
5099 |
||
5100 |
#if defined(WIN32) |
|
5101 |
RETURN ( true ); |
|
5102 |
#endif |
|
5103 |
||
5104 |
%}. |
|
5105 |
^ false |
|
5106 |
! |
|
5107 |
||
5108 |
isOS2like |
|
5109 |
"return true, if the OS we're running on is OS2 like" |
|
5110 |
||
5111 |
%{ /* NOCONTEXT */ |
|
5112 |
||
5113 |
#if defined(OS2) |
|
5114 |
RETURN (true); |
|
5115 |
#endif |
|
5116 |
||
5117 |
%}. |
|
5118 |
^ false |
|
5119 |
! |
|
5120 |
||
1034 | 5121 |
isUNIXlike |
5122 |
"return true, if the OS we're running on is a unix like." |
|
5123 |
||
5124 |
%{ /* NOCONTEXT */ |
|
5125 |
||
5126 |
#if !defined(UNIX_LIKE) |
|
5127 |
RETURN ( false ); |
|
5128 |
#endif |
|
5129 |
%}. |
|
5130 |
^ true |
|
5131 |
! |
|
5132 |
||
616 | 5133 |
maxFileNameLength |
5134 |
"return the max number of characters in a filename. |
|
831 | 5135 |
CAVEAT: |
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5136 |
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
|
5137 |
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
|
5138 |
We return a somewhat conservative number here." |
10 | 5139 |
|
5140 |
%{ /* NOCONTEXT */ |
|
616 | 5141 |
|
5142 |
/* |
|
5143 |
* XXX: newer systems provide a query function for this ... use it |
|
5144 |
*/ |
|
5145 |
# if defined(BSD) || defined(SYSV4) || defined(LONGFILENAMES) |
|
831 | 5146 |
RETURN ( __MKSMALLINT(255) ); |
616 | 5147 |
# endif |
5148 |
||
5149 |
# ifdef realIX |
|
831 | 5150 |
RETURN ( __MKSMALLINT(127) ); |
616 | 5151 |
# endif |
5152 |
||
5153 |
# ifdef SYSV |
|
831 | 5154 |
RETURN ( __MKSMALLINT(14) ); |
616 | 5155 |
# endif |
5156 |
||
5157 |
# ifdef MSDOS |
|
831 | 5158 |
RETURN ( __MKSMALLINT(9) ); |
616 | 5159 |
# endif |
5160 |
||
831 | 5161 |
# ifdef WIN32 |
616 | 5162 |
/* |
5163 |
* mhmh - depends on the filesystem type |
|
5164 |
*/ |
|
831 | 5165 |
RETURN ( __MKSMALLINT(9) ); |
616 | 5166 |
# endif |
5167 |
%}. |
|
5168 |
"unix default" |
|
831 | 5169 |
|
616 | 5170 |
^ 14 |
5171 |
! |
|
5172 |
||
1034 | 5173 |
setLocaleInfo:anInfoDictionary |
5174 |
"set the locale information; if set, this oerrides the OS's settings. |
|
5175 |
(internal in ST/X only - the OS's settings remain unaffected) |
|
5176 |
See description of fields in #getLocaleInfo. |
|
5177 |
||
5178 |
Notice, that (for now), the system does not use this information; |
|
5179 |
it should be used by applications as required." |
|
5180 |
||
5181 |
LocaleInfo := anInfoDictionary |
|
5182 |
||
5183 |
" |
|
5184 |
|d| |
|
5185 |
||
5186 |
d := IdentityDictionary new. |
|
5187 |
d at:#decimalPoint put:'.' . |
|
5188 |
d at:#thousandsSeparator put:',' . |
|
5189 |
d at:#currencySymbol put:'USD' . |
|
5190 |
d at:#monetaryDecimalPoint put:'.' . |
|
5191 |
d at:#monetaryThousandsSeparator put:'.' . |
|
5192 |
d at:#fractionalDigits put:2 . |
|
5193 |
d at:#positiveSign put:'+' . |
|
5194 |
d at:#negativeSign put:'-' . |
|
5195 |
d at:#positiveSignPrecedesCurrencySymbol put:true . |
|
5196 |
d at:#negativeSignPrecedesCurrencySymbol put:false . |
|
5197 |
OperatingSystem setLocaleInfo:d |
|
5198 |
" |
|
5199 |
! |
|
5200 |
||
616 | 5201 |
supportsIOInterrupts |
5202 |
"return true, if the OS supports IO availability interrupts |
|
5203 |
(i.e. SIGPOLL/SIGIO). |
|
5204 |
||
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
5205 |
Currently, this mechanism does work for SYSV4 only ..." |
616 | 5206 |
|
5207 |
%{ /* NOCONTEXT */ |
|
765
93bdb4f0e095
no, SIGIO does not work on SGI ...
Claus Gittinger <cg@exept.de>
parents:
764
diff
changeset
|
5208 |
#if defined(SYSV4) && defined(USE_SIGIO) |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
5209 |
|
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
5210 |
# if defined(SIGPOLL) || defined(SIGIO) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
5211 |
# 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
|
5212 |
/* |
765
93bdb4f0e095
no, SIGIO does not work on SGI ...
Claus Gittinger <cg@exept.de>
parents:
764
diff
changeset
|
5213 |
* 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
|
5214 |
* (not even on SGI ...) |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
5215 |
*/ |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
5216 |
# if !defined(NEXT) |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
5217 |
RETURN (true); |
616 | 5218 |
# endif |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
5219 |
# endif |
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
5220 |
# endif |
616 | 5221 |
|
10 | 5222 |
#endif |
831 | 5223 |
%}. |
13 | 5224 |
^ false |
123 | 5225 |
! |
5226 |
||
616 | 5227 |
supportsNonBlockingIO |
5228 |
"return true, if the OS supports nonblocking IO." |
|
5229 |
||
5230 |
%{ /* NOCONTEXT */ |
|
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
5231 |
#if defined(F_GETFL) && defined(F_SETFL) && defined(FNDELAY) |
616 | 5232 |
RETURN (true); |
754
0dcc8af63497
Fix enableIoInterrupts for SYSV4.
Stefan Vogel <sv@exept.de>
parents:
714
diff
changeset
|
5233 |
#endif |
831 | 5234 |
%}. |
616 | 5235 |
^ false |
123 | 5236 |
! |
5237 |
||
616 | 5238 |
supportsSelect |
5239 |
"return true, if the OS supports selecting on multiple |
|
5240 |
filedescriptors via select." |
|
5241 |
||
5242 |
%{ /* NOCONTEXT */ |
|
831 | 5243 |
#if defined(WIN32) |
5244 |
RETURN (false); |
|
5245 |
#endif |
|
616 | 5246 |
#if defined(sco) |
5247 |
/* |
|
831 | 5248 |
* sco has a select, but its broken: always waiting 1 second |
616 | 5249 |
*/ |
5250 |
RETURN(false); |
|
5251 |
#endif |
|
5252 |
%} |
|
5253 |
. |
|
5254 |
^ true |
|
5255 |
! ! |
|
5256 |
||
5257 |
!OperatingSystem class methodsFor:'shared memory access'! |
|
5258 |
||
5259 |
shmAttach:id address:addr flags:flags |
|
5260 |
%{ /* NOCONTEXT */ |
|
5261 |
#ifdef WANT_SHM |
|
5262 |
void *address, *shmaddr; |
|
5263 |
int shmflg, shmid; |
|
5264 |
||
5265 |
if (__isSmallInteger(addr) |
|
5266 |
&& __bothSmallInteger(flags, id)) { |
|
5267 |
shmaddr = (void *) __intVal(addr); |
|
5268 |
shmflg = __intVal(flags); |
|
5269 |
shmid = __intVal(id); |
|
5270 |
||
5271 |
address = shmat(shmid, shmaddr, shmflg); |
|
5272 |
if (address != (void *)-1) { |
|
5273 |
RETURN (__MKEXTERNALBYTES(addr)); |
|
5274 |
} |
|
5275 |
OperatingSystem_LastErrorNumber = _MKSMALLINT(errno); |
|
5276 |
RETURN (nil); |
|
5277 |
} |
|
5278 |
#endif |
|
5279 |
%}. |
|
792 | 5280 |
^ self primitiveFailed |
370 | 5281 |
! |
5282 |
||
616 | 5283 |
shmDetach:addr |
5284 |
%{ /* NOCONTEXT */ |
|
5285 |
#ifdef WANT_SHM |
|
5286 |
void *shmaddr; |
|
5287 |
int rslt; |
|
5288 |
||
5289 |
if (__isSmallInteger(addr)) { |
|
5290 |
shmaddr = (void *) __intVal(addr); |
|
5291 |
||
5292 |
rslt = shmdt(shmaddr); |
|
5293 |
if (rslt != -1) { |
|
5294 |
RETURN (true); |
|
370 | 5295 |
} |
616 | 5296 |
OperatingSystem_LastErrorNumber = _MKSMALLINT(errno); |
5297 |
RETURN (false); |
|
370 | 5298 |
} |
616 | 5299 |
#endif |
5300 |
%}. |
|
792 | 5301 |
^ self primitiveFailed |
616 | 5302 |
! |
5303 |
||
5304 |
shmGet:key size:size flags:flags |
|
5305 |
"low level entry to shmget system call. |
|
5306 |
This is not for public use |
|
5307 |
- use the provided wrapper class SharedExternalBytes instead." |
|
5308 |
||
5309 |
%{ /* NOCONTEXT */ |
|
5310 |
#ifdef WANT_SHM |
|
5311 |
if (__bothSmallInteger(key, size) |
|
5312 |
&& __isSmallInteger(flags)) { |
|
5313 |
int rslt; |
|
5314 |
||
5315 |
rslt = shmget(__intVal(key), __intVal(size), __intVal(flags)); |
|
5316 |
if (rslt != -1) { |
|
5317 |
RETURN (__MKSMALLINT(rslt)); |
|
5318 |
} |
|
5319 |
OperatingSystem_LastErrorNumber = _MKSMALLINT(errno); |
|
5320 |
RETURN (nil); |
|
5321 |
} |
|
5322 |
#endif |
|
370 | 5323 |
%}. |
792 | 5324 |
^ self primitiveFailed |
1 | 5325 |
! ! |
5326 |
||
5327 |
!OperatingSystem class methodsFor:'time and date'! |
|
5328 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5329 |
computeDatePartsOf:osTimeLow and:osTimeHi for:aBlock |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5330 |
"compute year, month and day from the OS time-parts osTimeLow and |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5331 |
osTimeHi and evaluate the argument, a 3-arg block with these. |
241 | 5332 |
Conversion is to localtime including any daylight saving adjustments. |
63 | 5333 |
|
5334 |
This method was added to avoid LargeInteger arithmetic and to be |
|
5335 |
independent of how the OperatingSystem represents time; |
|
5336 |
the time-parts expected are those returned by getTimeParts." |
|
1 | 5337 |
|
5338 |
|year month day| |
|
5339 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5340 |
((osTimeLow isMemberOf:SmallInteger) |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5341 |
and:[osTimeHi isMemberOf:SmallInteger]) ifFalse:[ |
185 | 5342 |
^ self primitiveFailed |
1 | 5343 |
]. |
5344 |
%{ |
|
5345 |
struct tm *tmPtr; |
|
5346 |
long t; |
|
5347 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5348 |
t = (_intVal(osTimeHi) << 16) | _intVal(osTimeLow); |
1 | 5349 |
tmPtr = localtime(&t); |
5350 |
year = _MKSMALLINT(tmPtr->tm_year + 1900); |
|
5351 |
month = _MKSMALLINT(tmPtr->tm_mon + 1); |
|
5352 |
day = _MKSMALLINT(tmPtr->tm_mday); |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5353 |
%}. |
1 | 5354 |
aBlock value:year value:month value:day |
5355 |
! |
|
5356 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5357 |
computeDatePartsOf:osTimeParts for:aBlock |
616 | 5358 |
"compute year, month and day from the ostime in timeParts, |
5359 |
and evaluate the argument, a 3-arg block with these. |
|
5360 |
Conversion is to localtime including any daylight saving adjustments." |
|
5361 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5362 |
^ self |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5363 |
computeDatePartsOf:(osTimeParts at:1) |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5364 |
and:(osTimeParts at:2) |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5365 |
for:aBlock |
1 | 5366 |
! |
5367 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5368 |
computeTimeAndDateFrom:osTimeParts |
63 | 5369 |
"given an Array containing the OS-dependent time, return an Array |
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5370 |
containing year, month, day, hour, minute and seconds, |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5371 |
offset to UTC and a daylight savings time flag. |
241 | 5372 |
Conversion is to localtime including any daylight saving adjustments." |
63 | 5373 |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5374 |
|low hi year month day hours minutes seconds utcOffset dst ret| |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5375 |
|
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5376 |
low := osTimeParts at:1. |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5377 |
hi := osTimeParts at:2. |
63 | 5378 |
%{ |
5379 |
struct tm *tmPtr; |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5380 |
struct tm *gmTmPtr; |
63 | 5381 |
long t; |
5382 |
||
811 | 5383 |
#ifdef ultrix /* mhmh - isnt this ifdef BSD ? */ |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5384 |
# define TIMEZONE tmPtr->tm_gmtoff |
811 | 5385 |
#else |
831 | 5386 |
# ifdef MSDOS_LIKE |
5387 |
define TIMEZONE 0 |
|
5388 |
# else |
|
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5389 |
# define TIMEZONE timezone |
831 | 5390 |
# endif |
811 | 5391 |
#endif |
5392 |
||
252 | 5393 |
if (__bothSmallInteger(low, hi)) { |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5394 |
t = (_intVal(hi) << 16) | _intVal(low); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5395 |
tmPtr = localtime(&t); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5396 |
hours = _MKSMALLINT(tmPtr->tm_hour); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5397 |
minutes = _MKSMALLINT(tmPtr->tm_min); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5398 |
seconds = _MKSMALLINT(tmPtr->tm_sec); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5399 |
|
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5400 |
year = _MKSMALLINT(tmPtr->tm_year + 1900); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5401 |
month = _MKSMALLINT(tmPtr->tm_mon + 1); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5402 |
day = _MKSMALLINT(tmPtr->tm_mday); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5403 |
|
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5404 |
if (tmPtr->tm_isdst == 0) { |
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5405 |
dst = false; |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5406 |
utcOffset = _MKSMALLINT(TIMEZONE); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5407 |
} else { |
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5408 |
dst = true; |
800
067094efdaed
use HAS_ALTZONE / HAS_DAYLIGHT
Claus Gittinger <cg@exept.de>
parents:
798
diff
changeset
|
5409 |
#ifdef HAS_ALTZONE |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5410 |
utcOffset = _MKSMALLINT(altzone); |
800
067094efdaed
use HAS_ALTZONE / HAS_DAYLIGHT
Claus Gittinger <cg@exept.de>
parents:
798
diff
changeset
|
5411 |
#else |
811 | 5412 |
utcOffset = _MKSMALLINT(TIMEZONE) + 3600; |
800
067094efdaed
use HAS_ALTZONE / HAS_DAYLIGHT
Claus Gittinger <cg@exept.de>
parents:
798
diff
changeset
|
5413 |
#endif |
067094efdaed
use HAS_ALTZONE / HAS_DAYLIGHT
Claus Gittinger <cg@exept.de>
parents:
798
diff
changeset
|
5414 |
} |
63 | 5415 |
} |
241 | 5416 |
%}. |
63 | 5417 |
year notNil ifTrue:[ |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5418 |
"I would love to have SELF-like inline objects ..." |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5419 |
ret := Array new:8. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5420 |
ret at:1 put:year. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5421 |
ret at:2 put:month. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5422 |
ret at:3 put:day. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5423 |
ret at:4 put:hours. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5424 |
ret at:5 put:minutes. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5425 |
ret at:6 put:seconds. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5426 |
ret at:7 put:utcOffset. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5427 |
ret at:8 put:dst. |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5428 |
^ ret |
63 | 5429 |
]. |
5430 |
^ self primitiveFailed |
|
5431 |
! |
|
5432 |
||
241 | 5433 |
computeTimePartsFromYear:y month:m day:d hour:h minute:min seconds:s |
5434 |
"return an Array containing the OS-dependent time for the given |
|
5435 |
time and day. The arguments are assumed to be in localtime including |
|
5436 |
any daylight saving adjustings." |
|
5437 |
||
5438 |
|low hi| |
|
5439 |
||
5440 |
%{ |
|
5441 |
struct tm tm; |
|
5442 |
long t; |
|
5443 |
||
252 | 5444 |
if (__bothSmallInteger(y, m) |
5445 |
&& __bothSmallInteger(d, h) |
|
5446 |
&& __bothSmallInteger(min, s)) { |
|
5447 |
tm.tm_hour = __intVal(h); |
|
5448 |
tm.tm_min = __intVal(min); |
|
5449 |
tm.tm_sec = __intVal(s); |
|
5450 |
||
5451 |
tm.tm_year = __intVal(y) - 1900; |
|
5452 |
tm.tm_mon = __intVal(m) - 1; |
|
5453 |
tm.tm_mday = __intVal(d); |
|
241 | 5454 |
tm.tm_isdst = -1; |
5455 |
||
5456 |
t = mktime(&tm); |
|
5457 |
low = _MKSMALLINT(t & 0xFFFF); |
|
5458 |
hi = _MKSMALLINT((t >> 16) & 0xFFFF); |
|
5459 |
} |
|
5460 |
%}. |
|
5461 |
low notNil ifTrue:[ |
|
5462 |
^ Array with:low with:hi |
|
5463 |
]. |
|
5464 |
^ self primitiveFailed |
|
5465 |
! |
|
5466 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5467 |
computeTimePartsOf:osTimeLow and:osTimeHi for:aBlock |
616 | 5468 |
"compute hours, minutes and seconds from the time-parts timeLow and |
5469 |
timeHi and evaluate the argument, a 3-arg block with these. |
|
5470 |
Conversion is to localtime including any daylight saving adjustments. |
|
5471 |
||
5472 |
This method was added to avoid LargeInteger arithmetic and to be |
|
5473 |
independent of how the OperatingSystem represents time; |
|
5474 |
the time-parts expected are those returned by getTimeParts." |
|
5475 |
||
5476 |
|hours minutes seconds| |
|
5477 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5478 |
((osTimeLow isMemberOf:SmallInteger) |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5479 |
and:[osTimeHi isMemberOf:SmallInteger]) ifFalse:[ |
616 | 5480 |
^ self primitiveFailed |
5481 |
]. |
|
5482 |
%{ |
|
5483 |
struct tm *tmPtr; |
|
5484 |
long t; |
|
5485 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5486 |
t = (_intVal(osTimeHi) << 16) | _intVal(osTimeLow); |
616 | 5487 |
tmPtr = localtime(&t); |
5488 |
hours = _MKSMALLINT(tmPtr->tm_hour); |
|
5489 |
minutes = _MKSMALLINT(tmPtr->tm_min); |
|
5490 |
seconds = _MKSMALLINT(tmPtr->tm_sec); |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5491 |
%}. |
616 | 5492 |
aBlock value:hours value:minutes value:seconds |
5493 |
! |
|
5494 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5495 |
computeTimePartsOf:osTimeParts for:aBlock |
616 | 5496 |
"compute hour, minute and seconds from the ostime in timeParts, |
5497 |
and evaluate the argument, a 3-arg block with these. |
|
5498 |
Conversion is to localtime including any daylight saving adjustments." |
|
5499 |
||
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5500 |
^ self |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5501 |
computeTimePartsOf:(osTimeParts at:1) |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5502 |
and:(osTimeParts at:2) |
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5503 |
for:aBlock |
275 | 5504 |
! |
5505 |
||
1 | 5506 |
getMillisecondTime |
185 | 5507 |
"This returns the millisecond timers value. |
5508 |
The range is limited to 0..1fffffff (i.e. the SmallInteger range) to avoid |
|
5509 |
LargeInteger arithmetic when doing timeouts and delays. |
|
792 | 5510 |
Since this value is wrapping around in regular intervals, this can only be used for |
185 | 5511 |
short relative time deltas. |
5512 |
Use the millisecondTimeXXX:-methods to compare and add time deltas - these know about the wrap. |
|
5513 |
||
5514 |
BAD DESIGN: |
|
5515 |
This should be changed to return some instance of RelativeTime, |
|
5516 |
and these computations moved there. |
|
95 | 5517 |
|
5518 |
Dont use this method in application code since it is an internal (private) |
|
5519 |
interface. For compatibility with ST-80, use Time millisecondClockValue. |
|
5520 |
" |
|
1 | 5521 |
|
5522 |
%{ /* NOCONTEXT */ |
|
5523 |
||
5524 |
long t; |
|
185 | 5525 |
#if !defined(HAS_GETTIMEOFDAY) && defined(SYSV) && defined(HZ) |
5526 |
/* |
|
5527 |
* sys5 time |
|
5528 |
*/ |
|
1 | 5529 |
long ticks; |
5530 |
struct tms tb; |
|
5531 |
||
5532 |
ticks = times(&tb); |
|
5533 |
t = (ticks * 1000) / HZ; |
|
792 | 5534 |
#else |
5535 |
# ifdef MSDOS_LIKE |
|
5536 |
struct _timeb timebuffer; |
|
5537 |
||
5538 |
_ftime(&timebuffer); |
|
5539 |
t = (timebuffer.time * 1000) + timebuffer.millitm; |
|
5540 |
# else /* assume HAS_GETTIMEOFDAY */ |
|
185 | 5541 |
/* |
5542 |
* bsd time |
|
5543 |
*/ |
|
1 | 5544 |
struct timeval tb; |
5545 |
struct timezone tzb; |
|
5546 |
||
5547 |
gettimeofday(&tb, &tzb); |
|
5548 |
t = tb.tv_sec*1000 + tb.tv_usec/1000; |
|
792 | 5549 |
# endif |
68 | 5550 |
#endif |
185 | 5551 |
RETURN ( _MKSMALLINT(t & 0x1FFFFFFF) ); |
1 | 5552 |
%} |
5553 |
! |
|
5554 |
||
616 | 5555 |
getTime |
5556 |
"return current Time in some OS dependent representation. |
|
5557 |
(on unix, its the seconds since 1970). |
|
5558 |
||
831 | 5559 |
WARNING: |
5560 |
this is OperatingSystem dependent |
|
5561 |
- for portable code, use getTimeParts and compute*PartsOf:and:for:. |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5562 |
Better yet, use Date>>today or Time>>now for fully ST-80 compatible code." |
831 | 5563 |
|
5564 |
^ (OperatingSystem getTimeInto:[:low :hi | hi*16r10000 + low]) |
|
616 | 5565 |
|
5566 |
" |
|
5567 |
OperatingSystem getTime |
|
5568 |
" |
|
5569 |
! |
|
5570 |
||
5571 |
getTimeHi |
|
5572 |
"return hi 16 bits of current time. |
|
5573 |
||
5574 |
OBSOLETE: Dont use this method, use getTimeParts. |
|
5575 |
This method will NOT always return the correct time |
|
5576 |
if used together with getTimeHi, since a wrap between |
|
5577 |
the two getTimeXXX sends could occur. |
|
5578 |
WARNING: this method will vanish - dont use it." |
|
5579 |
||
5580 |
%{ /* NOCONTEXT */ |
|
5581 |
||
5582 |
RETURN ( _MKSMALLINT((time(0) >> 16) & 0xFFFF) ); |
|
5583 |
%} |
|
5584 |
||
5585 |
"OperatingSystem getTimeHi" |
|
5586 |
! |
|
5587 |
||
5588 |
getTimeInto:aBlock |
|
5589 |
"evaluate the argument aBlock, passing the time-parts of |
|
5590 |
the current time as arguments. |
|
5591 |
See comment in 'OperatingSystem>>getTimeParts' on what to |
|
5592 |
do with those parts." |
|
5593 |
||
5594 |
|low hi| |
|
5595 |
%{ |
|
5596 |
int now; |
|
5597 |
||
5598 |
now = time(0); |
|
5599 |
hi = _MKSMALLINT((now >> 16) & 0xFFFF); |
|
5600 |
low = _MKSMALLINT(now & 0xFFFF); |
|
831 | 5601 |
%}. |
5602 |
^ aBlock value:low value:hi |
|
5603 |
||
5604 |
" |
|
5605 |
OperatingSystem getTimeInto:[:low :hi | low printNewline. hi printNewline] |
|
5606 |
" |
|
616 | 5607 |
! |
5608 |
||
5609 |
getTimeLow |
|
5610 |
"return low 16 bits of current time. |
|
5611 |
||
5612 |
OBSOLETE: Dont use this method, use getTimeParts. |
|
5613 |
This method will not always return the correct time |
|
5614 |
if used together with getTimeHi, since a wrap between |
|
5615 |
the two getTimeXXX sends could occur. |
|
5616 |
WARNING: this method will vanish - dont use it." |
|
5617 |
||
5618 |
%{ /* NOCONTEXT */ |
|
5619 |
||
5620 |
RETURN ( _MKSMALLINT(time(0) & 0xFFFF) ); |
|
5621 |
%} |
|
5622 |
||
831 | 5623 |
" |
5624 |
OperatingSystem getTimeLow |
|
5625 |
" |
|
616 | 5626 |
! |
5627 |
||
5628 |
getTimeParts |
|
5629 |
"return the current time as an array of 2 integers representing |
|
5630 |
the current time (usually low 16bits / hi 16 bits) in some OS |
|
5631 |
dependent way. |
|
5632 |
||
5633 |
On unix, the values represent the seconds since 1970, on other |
|
5634 |
systems this may be different. |
|
5635 |
WARNING: |
|
5636 |
for portability, never use these values directly, but pass them |
|
5637 |
to #computeTimeParts and/or #computeDatePartsOf:, which know how to |
|
5638 |
interpret them. |
|
5639 |
Better yet, use Date>>today and Time>>now for ST-80 compatibility." |
|
5640 |
||
5641 |
|low hi| |
|
5642 |
%{ |
|
5643 |
int now; |
|
5644 |
||
5645 |
now = time(0); |
|
5646 |
hi = _MKSMALLINT((now >> 16) & 0xFFFF); |
|
5647 |
low = _MKSMALLINT(now & 0xFFFF); |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5648 |
%}. |
616 | 5649 |
^ Array with:low with:hi |
5650 |
||
831 | 5651 |
" |
5652 |
OperatingSystem getTimeParts |
|
5653 |
" |
|
616 | 5654 |
! |
5655 |
||
5656 |
maximumMillisecondTimeDelta |
|
5657 |
"this returns the maximum delta supported by millisecondCounter |
|
5658 |
based methods. The returned value is half the value at which the |
|
5659 |
timer wraps." |
|
5660 |
||
5661 |
%{ /* NOCONTEXT */ |
|
5662 |
RETURN ( _MKSMALLINT(0x0FFFFFFF) ); |
|
5663 |
%} |
|
5664 |
! |
|
5665 |
||
5666 |
millisecondDelay:millis |
|
5667 |
"delay execution for millis milliseconds or until the next event |
|
5668 |
arrives. |
|
5669 |
All lower priority threads will also sleep for the duration, |
|
5670 |
interrupts (and therefore, higher prio processes) are |
|
5671 |
still handled. |
|
5672 |
Better use a Delay, to only delay the calling thread. |
|
5673 |
(however, a delay cannot be used in the event handler or scheduler)" |
|
5674 |
||
5675 |
|now then delta| |
|
5676 |
||
831 | 5677 |
%{ /* NOCONTEXT */ |
5678 |
#ifdef WIN32 |
|
5679 |
int t = __intVal(millis); |
|
5680 |
||
5681 |
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
|
5682 |
Sleep(t); |
831 | 5683 |
} |
5684 |
RETURN (self); |
|
5685 |
#endif |
|
5686 |
%}. |
|
5687 |
||
616 | 5688 |
now := OperatingSystem getMillisecondTime. |
5689 |
then := OperatingSystem millisecondTimeAdd:now and:millis. |
|
5690 |
||
5691 |
[OperatingSystem millisecondTime:then isAfter:now] whileTrue:[ |
|
5692 |
delta := OperatingSystem millisecondTimeDeltaBetween:then and:now. |
|
5693 |
self selectOnAnyReadable:nil writable:nil exception:nil withTimeOut:delta. |
|
5694 |
now := OperatingSystem getMillisecondTime. |
|
5695 |
] |
|
5696 |
||
5697 |
" |
|
5698 |
OperatingSystem millisecondDelay:2000 |
|
5699 |
" |
|
5700 |
! |
|
5701 |
||
5702 |
millisecondTime:msTime1 isAfter:msTime2 |
|
5703 |
"return true if msTime1 is after msTime2, false if not. |
|
5704 |
The two arguments are supposed to be millisecond times |
|
5705 |
(such as returned getMillisecondTime) which wrap at 16r1FFFFFFF. |
|
5706 |
||
5707 |
This should really be moved to some RelativeTime class." |
|
5708 |
||
5709 |
(msTime1 > msTime2) ifTrue:[ |
|
5710 |
((msTime1 - msTime2) >= 16r10000000) ifTrue:[ |
|
5711 |
^ false |
|
5712 |
]. |
|
5713 |
^ true |
|
5714 |
]. |
|
5715 |
((msTime2 - msTime1) > 16r10000000) ifTrue:[ |
|
5716 |
^ true |
|
5717 |
]. |
|
5718 |
^ false |
|
5719 |
! |
|
5720 |
||
5721 |
millisecondTimeAdd:msTime1 and:msTime2 |
|
5722 |
"Add two millisecond times (such as returned getMillisecondTime). |
|
5723 |
The returned value is msTime1 + msTime2 where a wrap occurs at:16r1FFFFFFF. |
|
5724 |
||
5725 |
This should really be moved to some RelativeTime class." |
|
5726 |
||
5727 |
|sum| |
|
5728 |
||
5729 |
sum := msTime1 + msTime2. |
|
5730 |
(sum > 16r1FFFFFFF) ifTrue:[^ sum - 16r20000000]. |
|
5731 |
(sum < 0) ifTrue:[^ sum + 16r20000000]. |
|
5732 |
^ sum |
|
5733 |
! |
|
5734 |
||
1 | 5735 |
millisecondTimeDeltaBetween:msTime1 and:msTime2 |
95 | 5736 |
"subtract two millisecond times (such as returned getMillisecondTime) |
185 | 5737 |
and return the difference. Since milli-times wrap (at 16r01FFFFFFF), |
95 | 5738 |
some special handling is built-in here. |
185 | 5739 |
The returned value is msTime1 - msTime2. The returned value is invalid |
5740 |
if the delta is >= 0x10000000. |
|
63 | 5741 |
|
810
9b3676f51220
mhmh - even though ultrix defines daylight,
Claus Gittinger <cg@exept.de>
parents:
809
diff
changeset
|
5742 |
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
|
5743 |
better yet: create a subclass of Integer named LimitedRangeInteger." |
1 | 5744 |
|
5745 |
(msTime1 > msTime2) ifTrue:[ |
|
185 | 5746 |
^ msTime1 - msTime2 |
1 | 5747 |
]. |
5748 |
^ msTime1 + 16r10000000 - msTime2 |
|
95 | 5749 |
|
5750 |
" |
|
5751 |
OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:1 |
|
5752 |
OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:(16 / 3) |
|
5753 |
OperatingSystem millisecondTimeAdd:16r0FFFFFFF and:1000 |
|
5754 |
||
5755 |
OperatingSystem millisecondTimeDeltaBetween:0 and:16r0FFFFFFF |
|
5756 |
OperatingSystem millisecondTimeDeltaBetween:(13/3) and:16r0FFFFFFF |
|
5757 |
OperatingSystem millisecondTimeDeltaBetween:999 and:16r0FFFFFFF |
|
5758 |
||
5759 |
OperatingSystem millisecondTime:0 isAfter:16r0FFFFFFF |
|
5760 |
OperatingSystem millisecondTime:(13/3) isAfter:16r0FFFFFFF |
|
5761 |
OperatingSystem millisecondTime:999 isAfter:16r0FFFFFFF |
|
5762 |
||
5763 |
OperatingSystem millisecondTime:0 isAfter:0 |
|
5764 |
OperatingSystem millisecondTime:(13/3) isAfter:0 |
|
5765 |
OperatingSystem millisecondTime:999 isAfter:0 |
|
5766 |
||
5767 |
OperatingSystem millisecondTime:1 isAfter:0 |
|
5768 |
OperatingSystem millisecondTime:(13/3) isAfter:2 |
|
5769 |
OperatingSystem millisecondTime:999 isAfter:900 |
|
5770 |
||
5771 |
|t1 t2| |
|
5772 |
||
5773 |
t1 := Time millisecondClockValue. |
|
5774 |
(Delay forMilliseconds:1) wait. |
|
5775 |
t2 := Time millisecondClockValue. |
|
5776 |
OperatingSystem millisecondTimeDeltaBetween:t2 and:t1 |
|
5777 |
" |
|
1 | 5778 |
! |
5779 |
||
5780 |
sleep:numberOfSeconds |
|
308 | 5781 |
"cease ANY action for some time. This suspends the whole smalltalk |
5782 |
(unix-) process for some time. |
|
1 | 5783 |
Not really useful since not even low-prio processes and interrupt |
95 | 5784 |
handling will run during the sleep. |
5785 |
Use either OperatingSystem>>millisecondDelay: (which makes all |
|
5786 |
threads sleep, but handles interrupts) or use a Delay (which makes |
|
5787 |
only the calling thread sleep)." |
|
1 | 5788 |
|
5789 |
%{ /* NOCONTEXT */ |
|
5790 |
||
252 | 5791 |
if (__isSmallInteger(numberOfSeconds)) { |
185 | 5792 |
sleep(_intVal(numberOfSeconds)); |
5793 |
RETURN ( self ); |
|
1 | 5794 |
} |
68 | 5795 |
%}. |
5796 |
" |
|
5797 |
argument not integer |
|
5798 |
" |
|
792 | 5799 |
^ self primitiveFailed |
95 | 5800 |
|
5801 |
" |
|
5802 |
OperatingSystem sleep:2 |
|
5803 |
" |
|
10 | 5804 |
! ! |
5805 |
||
616 | 5806 |
!OperatingSystem class methodsFor:'users & groups'! |
5807 |
||
5808 |
getEffectiveGroupID |
|
5809 |
"return the current users (thats you) effective numeric group id. |
|
5810 |
This is only different from getGroupID, if you have ST/X running |
|
5811 |
as a setuid program (of which you should think about twice)." |
|
5812 |
||
5813 |
%{ /* NOCONTEXT */ |
|
5814 |
||
5815 |
#ifdef UNIX_LIKE |
|
5816 |
int uid; |
|
5817 |
||
5818 |
uid = getegid(); |
|
5819 |
RETURN ( __MKSMALLINT(uid) ); |
|
5820 |
#endif |
|
5821 |
/* --- return same as getGroupID --- */ |
|
5822 |
%}. |
|
5823 |
^ self getGroupID |
|
5824 |
||
5825 |
" |
|
5826 |
OperatingSystem getEffectiveGroupID |
|
5827 |
" |
|
5828 |
! |
|
5829 |
||
5830 |
getEffectiveUserID |
|
5831 |
"return the current users (thats you) effective numeric user id. |
|
5832 |
This is only different from getUserID, if you have ST/X running |
|
5833 |
as a setuid program (of which you should think about twice)." |
|
10 | 5834 |
|
5835 |
%{ /* NOCONTEXT */ |
|
5836 |
||
616 | 5837 |
#ifdef UNIX_LIKE |
5838 |
int uid; |
|
5839 |
||
5840 |
uid = geteuid(); |
|
5841 |
RETURN ( __MKSMALLINT(uid) ); |
|
5842 |
#endif |
|
5843 |
/* --- return same as getUserID --- */ |
|
5844 |
%}. |
|
5845 |
^ self getUserID |
|
5846 |
||
5847 |
" |
|
5848 |
OperatingSystem getEffectiveUserID |
|
5849 |
" |
|
5850 |
! |
|
5851 |
||
5852 |
getGroupID |
|
5853 |
"return the current users (thats you) numeric group id" |
|
5854 |
||
5855 |
%{ /* NOCONTEXT */ |
|
5856 |
||
5857 |
#ifdef UNIX_LIKE |
|
5858 |
int uid; |
|
5859 |
||
5860 |
uid = getgid(); |
|
5861 |
RETURN ( __MKSMALLINT(uid) ); |
|
5862 |
#else |
|
5863 |
# ifdef SYSTEM_HAS_GROUPS |
|
5864 |
/* ... */ |
|
10 | 5865 |
# endif |
5866 |
#endif |
|
68 | 5867 |
%}. |
616 | 5868 |
^ 1 "just a dummy for systems which do not have userIDs" |
5869 |
||
68 | 5870 |
" |
616 | 5871 |
OperatingSystem getGroupID |
5872 |
" |
|
5873 |
! |
|
5874 |
||
5875 |
getGroupNameFromID:aNumber |
|
5876 |
"return the group-name-string for a given numeric group-id" |
|
5877 |
||
5878 |
%{ /* NOCONTEXT */ |
|
5879 |
||
5880 |
#ifdef UNIX_LIKE |
|
5881 |
struct group *g; |
|
5882 |
||
5883 |
if (__isSmallInteger(aNumber)) { |
|
5884 |
g = getgrgid(_intVal(aNumber)); |
|
5885 |
if (g) { |
|
830 | 5886 |
RETURN ( __MKSTRING(g->gr_name COMMA_CON) ); |
616 | 5887 |
} |
5888 |
} |
|
5889 |
#endif |
|
5890 |
%}. |
|
5891 |
^ '???' |
|
5892 |
||
5893 |
" |
|
5894 |
OperatingSystem getGroupNameFromID:0 |
|
5895 |
OperatingSystem getGroupNameFromID:10 |
|
5896 |
" |
|
5897 |
! |
|
5898 |
||
5899 |
getHomeDirectory |
|
5900 |
"return the name of the users home directory" |
|
5901 |
||
5902 |
^ OperatingSystem getEnvironment:'HOME' |
|
5903 |
||
5904 |
" |
|
5905 |
OperatingSystem getHomeDirectory |
|
5906 |
" |
|
5907 |
! |
|
5908 |
||
5909 |
getLoginName |
|
5910 |
"return a string with the users name" |
|
5911 |
||
5912 |
%{ /* NOCONTEXT */ |
|
5913 |
static char cachedName[64]; |
|
5914 |
static firstCall = 1; |
|
5915 |
||
831 | 5916 |
char *name = (char *)0; |
616 | 5917 |
#ifdef UNIX_LIKE |
5918 |
if (firstCall) { |
|
5919 |
name = (char *)getlogin(); |
|
5920 |
if (! name || (name[0] == 0)) { |
|
5921 |
name = (char *)getenv("LOGNAME"); |
|
5922 |
} |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
5923 |
if (name && (strlen(name) < sizeof(cachedName))) { |
616 | 5924 |
strcpy(cachedName, name); |
5925 |
firstCall = 0; |
|
5926 |
} |
|
5927 |
} else { |
|
5928 |
name = cachedName; |
|
5929 |
} |
|
831 | 5930 |
#else |
5931 |
# ifdef MSDOS_LIKE |
|
5932 |
if (firstCall) { |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5933 |
int nameSize = sizeof(cachedName); |
831 | 5934 |
|
5935 |
if (GetUserName(cachedName, &nameSize) == TRUE) { |
|
5936 |
name = cachedName; |
|
5937 |
firstCall = 0; |
|
5938 |
} |
|
5939 |
} else { |
|
5940 |
name = cachedName; |
|
5941 |
} |
|
5942 |
# endif |
|
5943 |
#endif |
|
5944 |
if (! name || (name[0] == 0) ) { |
|
5945 |
name = (char *)getenv("LOGNAME"); |
|
5946 |
} |
|
5947 |
if (! name || (name[0] == 0) ) { |
|
5948 |
name = "you"; |
|
5949 |
} |
|
5950 |
||
830 | 5951 |
RETURN ( __MKSTRING(name COMMA_CON) ); |
831 | 5952 |
%}. |
616 | 5953 |
" |
5954 |
OperatingSystem getLoginName |
|
5955 |
" |
|
5956 |
! |
|
5957 |
||
5958 |
getUserID |
|
5959 |
"return the current users (thats you) numeric user id" |
|
5960 |
||
5961 |
%{ /* NOCONTEXT */ |
|
5962 |
||
5963 |
#ifdef UNIX_LIKE |
|
5964 |
int uid; |
|
5965 |
||
5966 |
uid = getuid(); |
|
5967 |
RETURN ( __MKSMALLINT(uid) ); |
|
5968 |
#else |
|
5969 |
# ifdef SYSTEM_HAS_USERS |
|
5970 |
/* ... */ |
|
5971 |
# endif |
|
5972 |
#endif |
|
5973 |
%}. |
|
5974 |
^ 1 "just a dummy for systems which do not have userIDs" |
|
5975 |
||
5976 |
" |
|
5977 |
OperatingSystem getUserID |
|
68 | 5978 |
" |
616 | 5979 |
! |
5980 |
||
5981 |
getUserNameFromID:aNumber |
|
5982 |
"return the user-name-string for a given numeric user-id" |
|
5983 |
||
5984 |
%{ /* NOCONTEXT */ |
|
5985 |
||
5986 |
#ifdef UNIX_LIKE |
|
5987 |
struct passwd *p; |
|
5988 |
||
5989 |
if (__isSmallInteger(aNumber)) { |
|
5990 |
p = getpwuid(_intVal(aNumber)); |
|
5991 |
if (p) { |
|
830 | 5992 |
RETURN ( __MKSTRING(p->pw_name COMMA_CON) ); |
616 | 5993 |
} |
5994 |
} |
|
5995 |
#endif |
|
5996 |
%}. |
|
5997 |
^ '? (' , aNumber printString , ')' |
|
5998 |
||
5999 |
" |
|
6000 |
OperatingSystem getUserNameFromID:0 |
|
6001 |
OperatingSystem getUserNameFromID:100 |
|
6002 |
OperatingSystem getUserNameFromID:9991 |
|
6003 |
" |
|
1 | 6004 |
! |
6005 |
||
616 | 6006 |
userInfoOf:aNameOrID |
6007 |
"return a dictionary filled with userinfo. The argument can be either |
|
6008 |
a string with the users name or its numeric id. |
|
6009 |
Notice, that not all systems provide (all of) this info; |
|
6010 |
DOS systems return nothing; |
|
6011 |
non-SYSV4 systems have no age/comment. |
|
6012 |
Portable applications may want to check the systemType and NOT depend |
|
6013 |
on all keys to be present in the returned dictionary. |
|
6014 |
Another notice: on some systems (SYSV4), the gecos field includes multiple |
|
6015 |
entries (i.e. not just the name), separated by commas. You may want to |
|
6016 |
extract any substring, up to the first comma to get the real life name." |
|
6017 |
||
6018 |
|info name passw uid gid age comment |
|
6019 |
gecos dir shell| |
|
6020 |
||
6021 |
%{ |
|
6022 |
#ifdef UNIX_LIKE |
|
6023 |
struct passwd *buf; |
|
6024 |
int ret; |
|
6025 |
||
6026 |
if (__isString(aNameOrID)) { |
|
6027 |
buf = getpwnam(__stringVal(aNameOrID)); |
|
6028 |
} else if (__isSmallInteger(aNameOrID)) { |
|
6029 |
buf = getpwuid(__intVal(aNameOrID)); |
|
6030 |
} else { |
|
6031 |
buf = (struct passwd *)0; |
|
6032 |
} |
|
6033 |
if (buf) { |
|
830 | 6034 |
name = __MKSTRING(buf->pw_name COMMA_CON); |
6035 |
passw = __MKSTRING(buf->pw_passwd COMMA_CON); |
|
616 | 6036 |
# ifdef SYSV4 |
830 | 6037 |
age = __MKSTRING(buf->pw_age COMMA_CON); |
6038 |
comment = __MKSTRING(buf->pw_comment COMMA_CON); |
|
616 | 6039 |
# endif |
830 | 6040 |
dir = __MKSTRING(buf->pw_dir COMMA_CON); |
6041 |
gecos = __MKSTRING(buf->pw_gecos COMMA_CON); |
|
6042 |
shell = __MKSTRING(buf->pw_shell COMMA_CON); |
|
616 | 6043 |
|
6044 |
uid = _MKSMALLINT(buf->pw_uid); |
|
6045 |
gid = _MKSMALLINT(buf->pw_gid); |
|
6046 |
} |
|
6047 |
#endif |
|
6048 |
%}. |
|
6049 |
info := IdentityDictionary new. |
|
6050 |
name notNil ifTrue:[ |
|
6051 |
info at:#name put:name. |
|
6052 |
] ifFalse:[ |
|
6053 |
info at:#name put:'unknown' |
|
6054 |
]. |
|
6055 |
passw notNil ifTrue:[info at:#passwd put:passw]. |
|
6056 |
age notNil ifTrue:[info at:#age put:age]. |
|
6057 |
comment notNil ifTrue:[info at:#comment put:comment]. |
|
6058 |
gecos notNil ifTrue:[info at:#gecos put:gecos]. |
|
6059 |
shell notNil ifTrue:[info at:#shell put:shell]. |
|
6060 |
dir notNil ifTrue:[info at:#dir put:dir]. |
|
6061 |
uid notNil ifTrue:[info at:#uid put:uid]. |
|
6062 |
gid notNil ifTrue:[info at:#gid put:gid]. |
|
6063 |
^ info |
|
6064 |
||
6065 |
" |
|
6066 |
OperatingSystem userInfoOf:'root' |
|
6067 |
OperatingSystem userInfoOf:1 |
|
6068 |
OperatingSystem userInfoOf:'claus' |
|
6069 |
OperatingSystem userInfoOf:'fooBar' |
|
6070 |
OperatingSystem userInfoOf:(OperatingSystem getUserID) |
|
6071 |
" |
|
6072 |
! ! |
|
6073 |
||
6074 |
!OperatingSystem class methodsFor:'waiting for events'! |
|
6075 |
||
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6076 |
blockingChildProcessWait |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6077 |
"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
|
6078 |
%{ /*NOCONTEXT*/ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6079 |
#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
|
6080 |
RETURN(false); |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6081 |
#else |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6082 |
RETURN(true); |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6083 |
#endif |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6084 |
%} |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6085 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6086 |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6087 |
childProcessWait:blocking |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6088 |
"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
|
6089 |
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
|
6090 |
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
|
6091 |
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
|
6092 |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6093 |
|pid status code core| |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6094 |
%{ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6095 |
int p; |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6096 |
#if defined(HAS_WAITPID) |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6097 |
int s; |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6098 |
# define __WAIT waitpid(-1, &s, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED) |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6099 |
#else |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6100 |
# if defined(HAS_WAIT3) |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6101 |
union wait s; |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6102 |
#define __WAIT wait3(&s, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED, 0) |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6103 |
# else /*!HAS_WAIT3*/ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6104 |
int s; |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6105 |
# define __WAIT wait(&s) |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6106 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6107 |
# if !defined(WIFEXITED) |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6108 |
# define WIFEXITED(stat) (((int)((stat)&0377))==0) |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6109 |
# define WIFSIGNALED(stat) (((int)((stat)&0377))>0&&((int)(((stat)>>8)&0377))==0) |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6110 |
# define WIFSTOPPED(stat) (((int)((stat)&0377))==0177&&((int)(((stat)>>8)&0377))!=0) |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6111 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6112 |
# define WEXITSTATUS(stat) ((int)(((stat)>>8)&0377)) |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6113 |
# define WTERMSIG(stat) (((int)((stat)&0377))&0177) |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6114 |
# define WSTOPSIG(stat) ((int)(((stat)>>8)&0377)) |
843 | 6115 |
# endif /*!WIFEXITED*/ |
6116 |
# if !defined(WCOREDUMP) |
|
947
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6117 |
# define WCOREDUMP(stat) ((int)(((stat)>>8)&0200)) |
843 | 6118 |
# 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
|
6119 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6120 |
if (blocking != true) { |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6121 |
/* |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6122 |
* We do not support nonBlocking waits, so signal an error |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6123 |
* Sorry about the goto, but with all these ifdefs ... |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6124 |
*/ |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6125 |
goto done; |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6126 |
} |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6127 |
# endif /*!HAS_WAIT3*/ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6128 |
#endif /*!HAS_WAITPID*/ |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6129 |
|
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6130 |
do { |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6131 |
p = __WAIT; |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6132 |
} 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
|
6133 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6134 |
#undef __WAIT |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6135 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6136 |
if (p == 0) |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6137 |
RETURN(nil) |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6138 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6139 |
if (p == -1) { |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6140 |
if (errno == ECHILD) |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6141 |
RETURN(nil); |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6142 |
} else { |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6143 |
pid = __MKSMALLINT(p); |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6144 |
if (WIFEXITED(s)) { |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6145 |
status = @symbol(exit); |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6146 |
code = __MKSMALLINT(WEXITSTATUS(s)); |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6147 |
core = WCOREDUMP(s) ? true : false; |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6148 |
} else if (WIFSIGNALED(s)) { |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6149 |
status = @symbol(signal); |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6150 |
code = __MKSMALLINT(WTERMSIG(s)); |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6151 |
} else if (WIFSTOPPED(s)) { |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6152 |
status = @symbol(stop); |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6153 |
code = __MKSMALLINT(WSTOPSIG(s)); |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6154 |
} |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6155 |
#if defined(WIFCONTINUED) |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6156 |
else if (WIFCONTINUED(s)) { |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6157 |
status = @symbol(continue); |
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6158 |
} |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6159 |
#endif |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6160 |
} |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6161 |
done: ; |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6162 |
%}. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6163 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6164 |
pid isNil ifTrue:[ |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6165 |
^ self primitiveFailed |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6166 |
]. |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6167 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6168 |
^ 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
|
6169 |
|
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6170 |
" |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6171 |
OperatingSystem childProcessWait:false |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6172 |
" |
840
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6173 |
|
523533898acd
Reset sigCHLD interrupt handler, when no more processes are being waited for.
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
6174 |
"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
|
6175 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
6176 |
|
10 | 6177 |
readCheck:fd |
95 | 6178 |
"return true, if data is available on a filedescriptor (i.e. read |
6179 |
is possible without blocking)" |
|
10 | 6180 |
|
6181 |
(self selectOnAnyReadable:(Array with:fd) |
|
185 | 6182 |
writable:nil |
6183 |
exception:nil |
|
6184 |
withTimeOut:0) == fd |
|
6185 |
ifTrue:[^ true]. |
|
10 | 6186 |
^ false |
6187 |
! |
|
6188 |
||
616 | 6189 |
selectOn:fd1 and:fd2 withTimeOut:millis |
6190 |
"wait for any fd to become ready; timeout after t milliseconds. |
|
6191 |
A zero timeout-time will immediately return (i.e. poll). |
|
6192 |
Return fd if i/o ok, nil if timed-out or interrupted. |
|
6193 |
Obsolete: |
|
6194 |
This is a leftover method and will vanish." |
|
6195 |
||
6196 |
^ self selectOnAnyReadable:(Array with:fd1 with:fd2) |
|
6197 |
writable:(Array with:fd1 with:fd2) |
|
6198 |
exception:nil |
|
6199 |
withTimeOut:millis |
|
10 | 6200 |
! |
6201 |
||
6202 |
selectOn:fd withTimeOut:millis |
|
6203 |
"wait for aFileDesriptor to become ready; timeout after t milliseconds. |
|
1 | 6204 |
Return true, if i/o ok, false if timed-out or interrupted. |
6205 |
With 0 as timeout argument, this can be used to check for availability |
|
6206 |
of read-data. |
|
6207 |
Experimental." |
|
6208 |
||
3 | 6209 |
^ self selectOnAnyReadable:(Array with:fd) |
185 | 6210 |
writable:(Array with:fd) |
6211 |
exception:nil |
|
6212 |
withTimeOut:millis |
|
1 | 6213 |
! |
6214 |
||
616 | 6215 |
selectOnAny:fdArray withTimeOut:millis |
6216 |
"wait for any fd in fdArray (an Array of integers) to become ready; |
|
6217 |
timeout after t milliseconds. An empty set will always wait. |
|
6218 |
Return first ready fd if i/o ok, nil if timed-out or interrupted. |
|
6219 |
Experimental." |
|
6220 |
||
6221 |
^ self selectOnAnyReadable:fdArray |
|
6222 |
writable:fdArray |
|
185 | 6223 |
exception:nil |
6224 |
withTimeOut:millis |
|
1 | 6225 |
! |
6226 |
||
10 | 6227 |
selectOnAnyReadable:fdArray withTimeOut:millis |
95 | 6228 |
"wait for any fd in fdArray (an Array of integers) to become ready for |
6229 |
reading. Timeout after t milliseconds. An empty set will always wait. |
|
6230 |
A zero timeout-time will immediately return (i.e. poll). |
|
3 | 6231 |
Return first ready fd if i/o ok, nil if timed-out or interrupted. |
6232 |
Experimental." |
|
6233 |
||
6234 |
^ self selectOnAnyReadable:fdArray |
|
185 | 6235 |
writable:nil |
6236 |
exception:nil |
|
6237 |
withTimeOut:millis |
|
3 | 6238 |
! |
6239 |
||
95 | 6240 |
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray withTimeOut:millis |
6241 |
"wait for any fd in readFdArray (an Array of integers) to become ready for |
|
6242 |
reading, writeFdArray to become ready for writing, or exceptFdArray to |
|
6243 |
arrive exceptional data (i.e. out-of-band data). |
|
6244 |
Timeout after t milliseconds or, if the timeout time is 0, immediately.. |
|
6245 |
Empty fd-sets will always wait. Zero time can be used to poll file- |
|
6246 |
descriptors (i.e. to check if I/O possible without blocking). |
|
6247 |
Return first ready fd if I/O ok, nil if timed-out or interrupted." |
|
3 | 6248 |
|
1 | 6249 |
%{ |
831 | 6250 |
#ifdef MSDOS_LIKE |
6251 |
/* |
|
6252 |
* support a delay-wait only |
|
6253 |
* (i.e. fail if any filedescriptor is selected upon) |
|
6254 |
*/ |
|
6255 |
int count; |
|
6256 |
int i; |
|
6257 |
int t; |
|
6258 |
OBJ fd; |
|
6259 |
||
6260 |
if (! __isSmallInteger(millis)) { |
|
6261 |
goto fail; |
|
6262 |
} |
|
6263 |
||
6264 |
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
|
6265 |
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
|
6266 |
goto fail; |
831 | 6267 |
} |
6268 |
count = __arraySize(readFdArray); |
|
6269 |
for (i=0; i<count;i++) { |
|
6270 |
fd = _ArrayInstPtr(readFdArray)->a_element[i]; |
|
6271 |
if (fd != nil) { |
|
6272 |
goto fail; |
|
6273 |
} |
|
6274 |
} |
|
6275 |
} |
|
6276 |
if (writeFdArray != nil) { |
|
6277 |
if (! __isArray(writeFdArray)) { |
|
6278 |
goto fail; |
|
6279 |
} |
|
6280 |
count = __arraySize(writeFdArray); |
|
6281 |
for (i=0; i<count;i++) { |
|
6282 |
fd = _ArrayInstPtr(writeFdArray)->a_element[i]; |
|
6283 |
if (fd != nil) { |
|
6284 |
goto fail; |
|
6285 |
} |
|
6286 |
} |
|
6287 |
} |
|
6288 |
if (exceptFdArray != nil) { |
|
6289 |
if (! __isArray(exceptFdArray)) { |
|
6290 |
goto fail; |
|
6291 |
} |
|
6292 |
count = __arraySize(exceptFdArray); |
|
6293 |
for (i=0; i<count;i++) { |
|
6294 |
fd = _ArrayInstPtr(exceptFdArray)->a_element[i]; |
|
6295 |
if (fd != nil) { |
|
6296 |
goto fail; |
|
6297 |
} |
|
6298 |
} |
|
6299 |
} |
|
6300 |
t = _intVal(millis); |
|
6301 |
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
|
6302 |
/* |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6303 |
* delay only |
2d067b1d716c
added a method to fetch a unix processes' exitStatus (to avoid zombies)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6304 |
*/ |
831 | 6305 |
Sleep(t); |
6306 |
} |
|
6307 |
RETURN (nil); |
|
6308 |
||
6309 |
#else /* not MSDOS_LIKE */ |
|
1 | 6310 |
fd_set rset, wset, eset; |
831 | 6311 |
struct timeval wt, et; |
1 | 6312 |
int t, f, maxF, i, lX, bX; |
6313 |
OBJ fd, retFd; |
|
95 | 6314 |
int ret; |
300 | 6315 |
int count; |
1 | 6316 |
|
252 | 6317 |
if (__isSmallInteger(millis)) { |
185 | 6318 |
FD_ZERO(&rset); |
6319 |
FD_ZERO(&wset); |
|
6320 |
FD_ZERO(&eset); |
|
6321 |
||
6322 |
maxF = -1; |
|
308 | 6323 |
if (readFdArray != nil) { |
300 | 6324 |
if (! __isArray(readFdArray)) { |
6325 |
goto fail; |
|
6326 |
} |
|
6327 |
count = __arraySize(readFdArray); |
|
308 | 6328 |
|
6329 |
for (i=0; i<count;i++) { |
|
6330 |
fd = _ArrayInstPtr(readFdArray)->a_element[i]; |
|
6331 |
if (fd != nil) { |
|
6332 |
f = _intVal(fd); |
|
6333 |
if ((f >= 0) && (f < FD_SETSIZE)) { |
|
6334 |
FD_SET(f, &rset); |
|
6335 |
if (f > maxF) maxF = f; |
|
6336 |
} |
|
185 | 6337 |
} |
6338 |
} |
|
6339 |
} |
|
300 | 6340 |
|
308 | 6341 |
if (writeFdArray != nil) { |
300 | 6342 |
if (! __isArray(writeFdArray)) { |
6343 |
goto fail; |
|
6344 |
} |
|
6345 |
count = __arraySize(writeFdArray); |
|
308 | 6346 |
for (i=0; i<count;i++) { |
6347 |
fd = _ArrayInstPtr(writeFdArray)->a_element[i]; |
|
6348 |
if (fd != nil) { |
|
6349 |
f = _intVal(fd); |
|
6350 |
if ((f >= 0) && (f < FD_SETSIZE)) { |
|
6351 |
FD_SET(f, &wset); |
|
6352 |
if (f > maxF) maxF = f; |
|
6353 |
} |
|
185 | 6354 |
} |
6355 |
} |
|
6356 |
} |
|
300 | 6357 |
|
308 | 6358 |
if (exceptFdArray != nil) { |
300 | 6359 |
if (! __isArray(exceptFdArray)) { |
6360 |
goto fail; |
|
6361 |
} |
|
6362 |
count = __arraySize(exceptFdArray); |
|
308 | 6363 |
for (i=0; i<count;i++) { |
6364 |
fd = _ArrayInstPtr(exceptFdArray)->a_element[i]; |
|
6365 |
if (fd != nil) { |
|
6366 |
f = _intVal(fd); |
|
6367 |
if ((f >= 0) && (f < FD_SETSIZE)) { |
|
6368 |
FD_SET(f, &eset); |
|
6369 |
if (f > maxF) maxF = f; |
|
6370 |
} |
|
185 | 6371 |
} |
6372 |
} |
|
6373 |
} |
|
308 | 6374 |
|
185 | 6375 |
t = _intVal(millis); |
774
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
6376 |
if (t) { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
6377 |
wt.tv_sec = t / 1000; |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
6378 |
wt.tv_usec = (t % 1000) * 1000; |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
6379 |
} else { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
6380 |
wt.tv_sec = wt.tv_usec = 0; |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
6381 |
} |
185 | 6382 |
|
6383 |
/* |
|
6384 |
* make certain, that interrupt gets us out of the select |
|
6385 |
*/ |
|
362 | 6386 |
__BEGIN_INTERRUPTABLE__ |
185 | 6387 |
errno = 0; |
774
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
6388 |
|
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
6389 |
if (t == 0) { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
6390 |
/* |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
6391 |
* 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
|
6392 |
* interruptable. |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
6393 |
*/ |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
6394 |
do { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
6395 |
ret = select(maxF+1, &rset, &wset, &eset, &wt); |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
6396 |
} while ((ret < 0) && (errno == EINTR)); |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
6397 |
} else { |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
6398 |
do { |
813
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6399 |
ret = select(maxF+1, &rset, &wset, &eset, &wt); |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6400 |
/* |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6401 |
* 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
|
6402 |
* could otherwise stay in this loop forever ... |
1f9611434418
first stuff for locale support added
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6403 |
* 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
|
6404 |
* 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
|
6405 |
*/ |
774
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
6406 |
} while (0 /* (ret < 0) && (errno == EINTR) */ ); |
e0ee05157570
selectOnAny with timeout vs. no timeout
Claus Gittinger <cg@exept.de>
parents:
771
diff
changeset
|
6407 |
} |
362 | 6408 |
__END_INTERRUPTABLE__ |
95 | 6409 |
|
185 | 6410 |
if (ret > 0) { |
6411 |
for (i=0; i <= maxF; i++) { |
|
6412 |
if (FD_ISSET(i, &rset) |
|
6413 |
|| FD_ISSET(i, &wset) |
|
6414 |
|| FD_ISSET(i, &eset)) { |
|
6415 |
RETURN ( _MKSMALLINT(i) ); |
|
6416 |
} |
|
6417 |
} |
|
855
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
6418 |
} else { |
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
6419 |
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
|
6420 |
if (errno != EINTR) { |
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
6421 |
printf("select errno = %d\n", errno); |
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
6422 |
OperatingSystem_LastErrorNumber = _MKSMALLINT(errno); |
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
6423 |
} |
2de3c842c687
dont use SIGPIPE - it leads to trouble if its executed asynchrounously or
Claus Gittinger <cg@exept.de>
parents:
843
diff
changeset
|
6424 |
} |
185 | 6425 |
} |
308 | 6426 |
|
185 | 6427 |
/* |
6428 |
* return nil (means time expired) |
|
6429 |
*/ |
|
6430 |
RETURN ( nil ); |
|
1 | 6431 |
} |
831 | 6432 |
#endif /* not MSDOS_LIKE */ |
6433 |
||
300 | 6434 |
fail: ; |
68 | 6435 |
%}. |
6436 |
" |
|
300 | 6437 |
timeout argument not integer, |
6438 |
or any fd-array nonNil and not an array |
|
792 | 6439 |
or not supported by OS |
68 | 6440 |
" |
792 | 6441 |
^ self primitiveFailed |
1 | 6442 |
! |
6443 |
||
616 | 6444 |
setBlocking:aBoolean on:fd |
6445 |
"set/clear the blocking attribute - if set (which is the default) |
|
6446 |
a read on the fileDescriptor will block until data is available. |
|
6447 |
If cleared, a read operation will immediately return with a value of |
|
6448 |
nil." |
|
10 | 6449 |
|
6450 |
%{ /* NOCONTEXT */ |
|
6451 |
||
616 | 6452 |
int ret, flags; |
6453 |
int savInt; |
|
6454 |
||
6455 |
#if defined(F_GETFL) && defined(F_SETFL) |
|
6456 |
# if defined(FNDELAY) |
|
6457 |
if (__isSmallInteger(fd)) { |
|
6458 |
flags = fcntl(_intVal(fd), F_GETFL, 0); |
|
6459 |
if (aBoolean == true) { |
|
6460 |
ret = fcntl(_intVal(fd), F_SETFL, flags & ~FNDELAY); |
|
6461 |
} else { |
|
6462 |
ret = fcntl(_intVal(fd), F_SETFL, flags | FNDELAY); |
|
185 | 6463 |
} |
616 | 6464 |
if (ret >= 0) ret = flags; |
6465 |
RETURN ( _MKSMALLINT(ret) ); |
|
77 | 6466 |
} |
616 | 6467 |
# endif |
77 | 6468 |
#endif |
308 | 6469 |
%}. |
77 | 6470 |
" |
616 | 6471 |
fd argument not integer |
185 | 6472 |
" |
792 | 6473 |
^ self primitiveFailed |
1 | 6474 |
! |
6475 |
||
616 | 6476 |
writeCheck:fd |
6477 |
"return true, if filedescriptor can be written without blocking" |
|
6478 |
||
6479 |
(self selectOnAnyReadable:nil |
|
6480 |
writable:(Array with:fd) |
|
6481 |
exception:nil |
|
6482 |
withTimeOut:0) == fd |
|
6483 |
ifTrue:[^ true]. |
|
6484 |
^ false |
|
1 | 6485 |
! ! |
434 | 6486 |
|
630 | 6487 |
!OperatingSystem class methodsFor:'documentation'! |
6488 |
||
6489 |
version |
|
1040
60e4c4bbbca2
return nil from unblockInterrupts (thats what the inlined code returns)
Claus Gittinger <cg@exept.de>
parents:
1034
diff
changeset
|
6490 |
^ '$Header: /cvs/stx/stx/libbasic/Attic/Unix.st,v 1.123 1996-02-29 02:22:16 cg Exp $' |
630 | 6491 |
! ! |
616 | 6492 |
OperatingSystem initialize! |