222 # include <sys/shm.h> |
149 # include <sys/shm.h> |
223 # define _SYS_SHM_H_INCLUDED_ |
150 # define _SYS_SHM_H_INCLUDED_ |
224 |
151 |
225 #endif /* WANT_SHM */ |
152 #endif /* WANT_SHM */ |
226 |
153 |
227 #ifdef IRIX5 |
154 |
228 # include <sys/syssgi.h> |
155 |
229 #endif |
156 #ifndef _SIGNAL_H_INCLUDED_ |
230 |
157 # include <signal.h> |
231 |
158 # define _SIGNAL_H_INCLUDED_ |
232 #ifdef transputer |
159 #endif |
233 |
160 |
234 # define unlink(f) ((remove(f) == 0) ? 0 : -1) |
161 #ifdef SYSV |
235 |
162 # ifndef _SYS_TYPES_H_INCLUDED_ |
236 #else /* not transputer */ |
163 # include <sys/types.h> |
237 |
164 # define _SYS_TYPES_H_INCLUDED_ |
238 # ifndef _SIGNAL_H_INCLUDED_ |
165 # endif |
239 # include <signal.h> |
166 |
240 # define _SIGNAL_H_INCLUDED_ |
167 # ifndef _SYS_PARAM_H_INCLUDED_ |
241 # endif |
168 # ifndef NO_SYS_PARAM_H |
242 |
169 # include <sys/param.h> |
243 # ifdef SYSV |
170 # define _SYS_PARAM_H_INCLUDED_ |
244 # ifndef _SYS_TYPES_H_INCLUDED_ |
|
245 # include <sys/types.h> |
|
246 # define _SYS_TYPES_H_INCLUDED_ |
|
247 # endif |
171 # endif |
248 |
172 # endif |
249 # ifndef _SYS_PARAM_H_INCLUDED_ |
173 |
250 # ifndef NO_SYS_PARAM_H |
174 # ifndef _SYS_TIMES_H_INCLUDED_ |
251 # include <sys/param.h> |
175 # include <sys/times.h> |
252 # define _SYS_PARAM_H_INCLUDED_ |
176 # define _SYS_TIMES_H_INCLUDED_ |
253 # endif |
|
254 # endif |
|
255 |
|
256 # ifndef _SYS_TIMES_H_INCLUDED_ |
|
257 # include <sys/times.h> |
|
258 # define _SYS_TIMES_H_INCLUDED_ |
|
259 # endif |
|
260 |
|
261 # ifndef _SYS_FILE_H_INCLUDED_ |
|
262 # include <sys/file.h> |
|
263 # define _SYS_FILE_H_INCLUDED_ |
|
264 # endif |
|
265 |
|
266 # if ! defined(sco3_2) |
|
267 # ifndef _UNISTD_H_INCLUDED_ |
|
268 # include <unistd.h> |
|
269 # define _UNISTD_H_INCLUDED_ |
|
270 # endif |
|
271 # endif |
|
272 |
|
273 # if defined(isc3_2) || defined(sco3_2) |
|
274 # ifndef _SYS_TIME_H_INCLUDED_ |
|
275 # include <sys/time.h> |
|
276 # define _SYS_TIME_H_INCLUDED_ |
|
277 # endif |
|
278 # endif |
|
279 |
|
280 # if !defined(isc3_2) |
|
281 # if defined(PCS) && defined(mips) |
|
282 # include "/usr/include/bsd/sys/time.h" |
|
283 # include "/usr/include/sys/time.h" |
|
284 # else |
|
285 # ifndef _TIME_H_INCLUDED_ |
|
286 # include <time.h> |
|
287 # define _TIME_H_INCLUDED_ |
|
288 # endif |
|
289 # endif |
|
290 # endif |
|
291 |
|
292 # if defined(isc3_2) |
|
293 # include <sys/bsdtypes.h> |
|
294 # endif |
|
295 |
|
296 # else /* not SYSV */ |
|
297 |
|
298 # ifdef MSDOS_LIKE |
|
299 |
|
300 # ifndef _SYS_TYPES_H_INCLUDED_ |
|
301 # include <sys/types.h> |
|
302 # define _SYS_TYPES_H_INCLUDED_ |
|
303 # endif |
|
304 |
|
305 # ifndef _TIME_H_INCLUDED_ |
|
306 # include <time.h> |
|
307 # define _TIME_H_INCLUDED_ |
|
308 # endif |
|
309 |
|
310 # ifndef _SYS_TIMEB_H_INCLUDED_ |
|
311 # include <sys/timeb.h> |
|
312 # define _SYS_TIMEB_H_INCLUDED_ |
|
313 # endif |
|
314 |
|
315 # else /* not MSDOS_like */ |
|
316 |
|
317 # ifndef _SYS_TIME_H_INCLUDED_ |
|
318 # include <sys/time.h> |
|
319 # define _SYS_TIME_H_INCLUDED_ |
|
320 # endif |
|
321 |
|
322 # ifndef _SYS_TYPES_H_INCLUDED_ |
|
323 # include <sys/types.h> |
|
324 # define _SYS_TYPES_H_INCLUDED_ |
|
325 # endif |
|
326 |
|
327 # endif /* not MSDOS */ |
|
328 # endif /* not SYSV */ |
|
329 |
|
330 |
|
331 # ifdef aix |
|
332 |
|
333 # ifndef _TIME_H_INCLUDED_ |
|
334 # include <time.h> |
|
335 # define _TIME_H_INCLUDED_ |
|
336 # endif |
|
337 # ifndef _SYS_SELECT_H_INCLUDED_ |
|
338 # include <sys/select.h> |
|
339 # define _SYS_SELECT_H_INCLUDED_ |
|
340 # endif |
|
341 |
|
342 # endif /* aix */ |
|
343 |
|
344 |
|
345 # ifndef MSDOS_LIKE |
|
346 |
|
347 # ifndef _PWD_H_INCLUDED_ |
|
348 # include <pwd.h> |
|
349 # define _PWD_H_INCLUDED_ |
|
350 # endif |
|
351 |
|
352 # ifndef NO_GRP_H |
|
353 # ifndef _GRP_H_INCLUDED_ |
|
354 # include <grp.h> |
|
355 # define _GRP_H_INCLUDED_ |
|
356 # endif |
|
357 # endif |
|
358 |
|
359 # endif /* not MSDOS */ |
|
360 |
|
361 # ifndef _SYS_STAT_H_INCLUDED_ |
|
362 # include <sys/stat.h> |
|
363 # define _SYS_STAT_H_INCLUDED_ |
|
364 # endif |
177 # endif |
365 |
178 |
366 # ifndef _SYS_FILE_H_INCLUDED_ |
179 # ifndef _SYS_FILE_H_INCLUDED_ |
367 # ifndef WIN32 |
180 # include <sys/file.h> |
368 # include <sys/file.h> |
|
369 # endif |
|
370 # define _SYS_FILE_H_INCLUDED_ |
181 # define _SYS_FILE_H_INCLUDED_ |
371 # endif |
182 # endif |
372 |
183 |
373 # ifndef _ERRNO_H_INCLUDED_ |
184 # ifndef _UNISTD_H_INCLUDED_ |
374 # include <errno.h> |
185 # include <unistd.h> |
375 # define _ERRNO_H_INCLUDED_ |
186 # define _UNISTD_H_INCLUDED_ |
376 # endif |
187 # endif |
377 |
188 |
378 # ifndef _STDIO_H_INCLUDED_ |
189 # ifndef _TIME_H_INCLUDED_ |
379 # include <stdio.h> |
190 # include <time.h> |
380 # define _STDIO_H_INCLUDED_ |
191 # define _TIME_H_INCLUDED_ |
381 # endif |
192 # endif |
382 |
193 |
383 # ifndef _FCNTL_H_INCLUDED_ |
194 #else /* not SYSV */ |
384 # include <fcntl.h> |
195 |
385 # define _FCNTL_H_INCLUDED_ |
196 # ifndef _SYS_TIME_H_INCLUDED_ |
386 # endif |
197 # include <sys/time.h> |
387 |
198 # define _SYS_TIME_H_INCLUDED_ |
388 # ifndef _IOCTL_H_INCLUDED_ |
199 # endif |
389 # ifndef WIN32 |
200 |
390 # include <sys/ioctl.h> |
201 # ifndef _SYS_TYPES_H_INCLUDED_ |
391 # define _IOCTL_H_INCLUDED_ |
202 # include <sys/types.h> |
392 # endif |
203 # define _SYS_TYPES_H_INCLUDED_ |
393 # endif |
204 # endif |
394 |
205 |
395 # ifdef WIN32 |
206 #endif /* not SYSV */ |
396 /*# define PROCESSDEBUGWIN32*/ |
207 |
397 # define xxUSE_TimerProc |
208 #ifndef _PWD_H_INCLUDED_ |
398 |
209 # include <pwd.h> |
399 # undef INT |
210 # define _PWD_H_INCLUDED_ |
400 # undef Array |
211 #endif |
401 # undef Number |
212 |
402 # undef Method |
213 #ifndef NO_GRP_H |
403 # undef Point |
214 # ifndef _GRP_H_INCLUDED_ |
404 # undef Rectangle |
215 # include <grp.h> |
405 # undef Block |
216 # define _GRP_H_INCLUDED_ |
406 # undef String |
217 # endif |
407 # undef Message |
218 #endif |
408 # undef Object |
219 |
409 # undef Context |
220 #ifndef _SYS_STAT_H_INCLUDED_ |
410 |
221 # include <sys/stat.h> |
411 /* # include <windows.h> /* */ |
222 # define _SYS_STAT_H_INCLUDED_ |
412 # include <stdarg.h> /* */ |
223 #endif |
413 # include <windef.h> /* */ |
224 |
414 # include <winbase.h> /* */ |
225 #ifndef _SYS_FILE_H_INCLUDED_ |
415 # include <wingdi.h> /* */ |
226 # include <sys/file.h> |
416 # include <winuser.h> /* */ |
227 # define _SYS_FILE_H_INCLUDED_ |
417 # include <winsock.h> /* */ |
228 #endif |
418 |
229 |
419 # ifdef __DEF_Array |
230 #ifndef _ERRNO_H_INCLUDED_ |
420 # define Array __DEF_Array |
231 # include <errno.h> |
421 # endif |
232 # define _ERRNO_H_INCLUDED_ |
422 # ifdef __DEF_Number |
233 #endif |
423 # define Number __DEF_Number |
234 |
424 # endif |
235 #ifndef _STDIO_H_INCLUDED_ |
425 # ifdef __DEF_Method |
236 # include <stdio.h> |
426 # define Method __DEF_Method |
237 # define _STDIO_H_INCLUDED_ |
427 # endif |
238 #endif |
428 # ifdef __DEF_Point |
239 |
429 # define Point __DEF_Point |
240 #ifndef _FCNTL_H_INCLUDED_ |
430 # endif |
241 # include <fcntl.h> |
431 # ifdef __DEF_Block |
242 # define _FCNTL_H_INCLUDED_ |
432 # define Block __DEF_Block |
243 #endif |
433 # endif |
244 |
434 # ifdef __DEF_String |
245 #ifndef _IOCTL_H_INCLUDED_ |
435 # define String __DEF_String |
246 # ifndef WIN32 |
436 # endif |
247 # include <sys/ioctl.h> |
437 # ifdef __DEF_Message |
248 # define _IOCTL_H_INCLUDED_ |
438 # define Message __DEF_Message |
249 # endif |
439 # endif |
250 #endif |
440 # ifdef __DEF_Object |
251 |
441 # define Object __DEF_Object |
252 |
442 # endif |
253 #if defined (HAS_LOCALECONV) |
443 # ifdef __DEF_Context |
254 # ifndef _LOCALE_H_INCLUDED_ |
444 # define Context __DEF_Context |
255 # include <locale.h> |
445 # endif |
256 # define _LOCALE_H_INCLUDED_ |
446 |
257 # endif |
447 # define INT int |
258 #endif |
448 |
|
449 # define stat _stat |
|
450 # define WIN32_ERR(x) ((x) | 0x01000000) /* tag GetLastError codes */ |
|
451 /* as opposed to Posix errors */ |
|
452 |
|
453 typedef int (*intf)(int); |
|
454 BOOL __signalUserInterruptWIN32(DWORD sig); |
|
455 # endif /* WIN32 */ |
|
456 |
|
457 |
|
458 # if defined(LINUX) |
|
459 # define HAS_LOCALECONV |
|
460 # endif |
|
461 |
|
462 # if defined (HAS_LOCALECONV) |
|
463 # ifndef _LOCALE_H_INCLUDED_ |
|
464 # include <locale.h> |
|
465 # define _LOCALE_H_INCLUDED_ |
|
466 # endif |
|
467 # endif |
|
468 |
259 |
469 /* |
260 /* |
470 * posix systems should define these ... |
261 * posix systems should define these ... |
471 * but on some (older) systems, they are not. |
262 * but on some (older) systems, they are not. |
472 */ |
263 */ |
473 # ifndef S_IXUSR |
264 #ifndef S_IXUSR |
474 # ifdef S_IEXEC |
265 # ifdef S_IEXEC |
475 # define S_IXUSR S_IEXEC |
266 # define S_IXUSR S_IEXEC |
476 # define S_IXGRP (S_IEXEC>>3) |
267 # define S_IXGRP (S_IEXEC>>3) |
477 # define S_IXOTH (S_IEXEC>>6) |
268 # define S_IXOTH (S_IEXEC>>6) |
|
269 # endif |
|
270 #endif |
|
271 |
|
272 #ifndef S_IXUSR |
|
273 # define S_IXUSR 0100 |
|
274 # define S_IXGRP 0010 |
|
275 # define S_IXOTH 0001 |
|
276 #endif |
|
277 |
|
278 #ifndef S_IRUSR |
|
279 # define S_IRUSR 0400 |
|
280 # define S_IRGRP 0040 |
|
281 # define S_IROTH 0004 |
|
282 #endif |
|
283 |
|
284 #ifndef S_IWUSR |
|
285 # define S_IWUSR 0200 |
|
286 # define S_IWGRP 0020 |
|
287 # define S_IWOTH 0002 |
|
288 #endif |
|
289 |
|
290 #ifndef MAXPATHLEN |
|
291 # ifndef MSDOS_LIKE |
|
292 # ifndef NO_SYS_PARAM_H |
|
293 # include <sys/param.h> |
478 # endif |
294 # endif |
479 # endif |
295 # endif |
480 |
|
481 # ifndef S_IXUSR |
|
482 # define S_IXUSR 0100 |
|
483 # define S_IXGRP 0010 |
|
484 # define S_IXOTH 0001 |
|
485 # endif |
|
486 |
|
487 # ifndef S_IRUSR |
|
488 # define S_IRUSR 0400 |
|
489 # define S_IRGRP 0040 |
|
490 # define S_IROTH 0004 |
|
491 # endif |
|
492 |
|
493 # ifndef S_IWUSR |
|
494 # define S_IWUSR 0200 |
|
495 # define S_IWGRP 0020 |
|
496 # define S_IWOTH 0002 |
|
497 # endif |
|
498 |
|
499 # ifndef MAXPATHLEN |
296 # ifndef MAXPATHLEN |
500 # ifndef MSDOS_LIKE |
297 # ifdef FILENAME_MAX /* i.e. MSDOS_LIKE */ |
501 # ifndef NO_SYS_PARAM_H |
298 # define MAXPATHLEN FILENAME_MAX |
502 # include <sys/param.h> |
299 # else |
|
300 # ifdef MAX_PATH |
|
301 # define MAXPATHLEN MAX_PATH |
|
302 # else |
|
303 # define MAXPATHLEN 1024 |
503 # endif |
304 # endif |
504 # endif |
305 # endif |
505 # ifndef MAXPATHLEN |
306 # endif |
506 # ifdef FILENAME_MAX /* i.e. MSDOS_LIKE */ |
307 #endif |
507 # define MAXPATHLEN FILENAME_MAX |
308 |
508 # else |
309 #if defined(HAS_UNAME) |
509 # ifdef MAX_PATH |
310 # include <sys/utsname.h> |
510 # define MAXPATHLEN MAX_PATH |
311 #endif |
511 # else |
312 |
512 # define MAXPATHLEN 1024 |
|
513 # endif |
|
514 # endif |
|
515 # endif |
|
516 # endif |
|
517 |
|
518 # if defined(HAS_UNAME) |
|
519 # include <sys/utsname.h> |
|
520 # endif |
|
521 |
|
522 # if defined(SYSV4) |
|
523 # include <stropts.h> |
|
524 # endif |
|
525 |
|
526 /* |
|
527 * NeXT has no pid_t |
|
528 * and no sigemptyset |
|
529 */ |
|
530 # ifdef NEXT3 |
|
531 typedef int pid_t; |
|
532 # define sigemptyset(set) ((*(set) = 0L), 0) |
|
533 # define HAS_GETDOMAINNAME |
|
534 # define NO_WAITPID |
|
535 # endif |
|
536 |
|
537 # ifdef sunos |
|
538 # undef NO_WAITPID |
|
539 # undef HAS_WAITPID |
|
540 # define HAS_WAIT3 |
|
541 # define HAS_SIGACTION |
|
542 # endif |
|
543 |
|
544 # ifdef _AIX |
|
545 # undef HAS_WAIT3 |
|
546 # endif |
|
547 |
|
548 /* |
|
549 * some (BSD ?) have no timezone global, |
|
550 * but provide the info in struct timezone. |
|
551 */ |
|
552 # if defined(ultrix) || defined(sunos) || defined(NEXT) |
|
553 # define HAS_NO_TIMEZONE |
|
554 # endif |
|
555 |
313 |
556 /* |
314 /* |
557 * sigaction dummies (you won't believe these call themself ``POSIX'' systems ...) |
315 * sigaction dummies (you won't believe these call themself ``POSIX'' systems ...) |
558 */ |
316 */ |
559 # ifndef SA_RESTART |
317 #ifndef SA_RESTART |
560 # define SA_RESTART 0 |
318 # define SA_RESTART 0 |
561 # endif |
319 #endif |
562 # ifndef SA_SIGINFO |
320 #ifndef SA_SIGINFO |
563 # define SA_SIGINFO 0 |
321 # define SA_SIGINFO 0 |
564 # endif |
322 #endif |
565 |
323 |
566 # if defined(HAS_WAITPID) || defined(HAS_WAIT3) |
324 #if defined(HAS_SYSINFO) |
567 # include <sys/wait.h> |
325 # include <sys/systeminfo.h> |
568 # endif |
326 #endif |
569 |
327 |
570 # if defined(HAS_SYSINFO) |
|
571 # include <sys/systeminfo.h> |
|
572 # endif |
|
573 |
|
574 #endif /* not transputer */ |
|
575 |
328 |
576 /* |
329 /* |
577 * on some systems errno is a macro ... check for it here |
330 * on some systems errno is a macro ... check for it here |
578 */ |
331 */ |
579 #ifndef errno |
332 #ifndef errno |
655 %} |
385 %} |
656 ! ! |
386 ! ! |
657 |
387 |
658 !OpenVMSOperatingSystem primitiveFunctions! |
388 !OpenVMSOperatingSystem primitiveFunctions! |
659 %{ |
389 %{ |
660 |
|
661 /* |
|
662 * some systems' system() is broken in that it does not correctly |
|
663 * handle EINTR and returns failure even though it actually succeeded. |
|
664 * (LINUX is one of them) |
|
665 * Here is a fixed version. If you encounter EINTR returns from |
|
666 * OpenVMSOperatingSystem>>executeCommand, you ought to define WANT_SYSTEM |
|
667 * in the xxxIntern.h file to get this fixed version. |
|
668 * |
|
669 * As an added BONUS, this system() enables interrupts while waiting |
|
670 * for the child which enables other threads to continue. |
|
671 * (i.e. it is RT safe) |
|
672 */ |
|
673 |
|
674 #if defined(WANT_SYSTEM) |
|
675 |
|
676 /* # define DPRINTF(x) printf x */ |
|
677 # define DPRINTF(x) /* nothing */ |
|
678 |
|
679 # ifndef _STDDEF_H_INCLUDED_ |
|
680 # include <stddef.h> |
|
681 # define _STDDEF_H_INCLUDED_ |
|
682 # endif |
|
683 |
|
684 # ifndef _STDLIB_H_INCLUDED_ |
|
685 # include <stdlib.h> |
|
686 # define _STDLIB_H_INCLUDED_ |
|
687 # endif |
|
688 |
|
689 # ifndef _UNISTD_H_INCLUDED_ |
|
690 # include <unistd.h> |
|
691 # define _UNISTD_H_INCLUDED_ |
|
692 # endif |
|
693 |
|
694 # ifndef _SYS_WAIT_H_INCLUDED |
|
695 # include <sys/wait.h> |
|
696 # define _SYS_WAIT_H_INCLUDED |
|
697 # endif |
|
698 |
|
699 # ifndef _SIGNAL_H_INCLUDED_ |
|
700 # include <signal.h> |
|
701 # define _SIGNAL_H_INCLUDED_ |
|
702 # endif |
|
703 |
|
704 # ifndef _SYS_TYPES_H_INCLUDED_ |
|
705 # include <sys/types.h> |
|
706 # define _SYS_TYPES_H_INCLUDED_ |
|
707 # endif |
|
708 |
|
709 # if (!defined(HAVE_GNU_LD) && !defined (__ELF__)) || !defined(LINUX) |
|
710 # define __environ environ |
|
711 # if !defined(LINUX) |
|
712 # define __sigemptyset sigemptyset |
|
713 # define __sigaction sigaction |
|
714 # define __sigaddset sigaddset |
|
715 # define __sigprocmask sigprocmask |
|
716 # define __execve execve |
|
717 # define __wait wait |
|
718 # define __waitpid waitpid |
|
719 # if defined(HAS_VFORK) |
|
720 # define FORK vfork |
|
721 # else |
|
722 # define FORK fork |
|
723 # endif |
|
724 # endif /* ! LINUX */ |
|
725 extern char **environ; |
|
726 # endif |
|
727 |
|
728 # define SHELL_PATH "/bin/sh" /* Path of the shell. */ |
|
729 # define SHELL_NAME "sh" /* Name to give it. */ |
|
730 |
|
731 # ifndef FORK |
|
732 # define FORK __fork |
|
733 # endif |
|
734 |
|
735 # ifndef CONST |
|
736 # ifdef __GNUC__ |
|
737 # define CONST const |
|
738 # else |
|
739 # define CONST /* nothing */ |
|
740 # endif |
|
741 # endif |
|
742 |
|
743 static int |
|
744 mySystem(line) |
|
745 register CONST char *line; |
|
746 { |
|
747 int status, save; |
|
748 pid_t pid; |
|
749 struct sigaction sa, intr, quit; |
|
750 sigset_t block, omask; |
|
751 |
|
752 if (line == NULL) |
|
753 return -1; |
|
754 |
|
755 sa.sa_handler = SIG_IGN; |
|
756 sa.sa_flags = 0; |
|
757 __sigemptyset (&sa.sa_mask); |
|
758 |
|
759 if (__sigaction (SIGINT, &sa, &intr) < 0) { |
|
760 DPRINTF(("1: errno=%d\n", errno)); |
|
761 return -1; |
|
762 } |
|
763 if (__sigaction (SIGQUIT, &sa, &quit) < 0) { |
|
764 save = errno; |
|
765 (void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL); |
|
766 errno = save; |
|
767 DPRINTF(("2: errno=%d\n", errno)); |
|
768 return -1; |
|
769 } |
|
770 |
|
771 __sigemptyset (&block); |
|
772 __sigaddset (&block, SIGCHLD); |
|
773 save = errno; |
|
774 if (__sigprocmask(SIG_BLOCK, &block, &omask) < 0) { |
|
775 if (errno == ENOSYS) |
|
776 errno = save; |
|
777 else { |
|
778 save = errno; |
|
779 (void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL); |
|
780 (void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL); |
|
781 errno = save; |
|
782 DPRINTF(("3: errno=%d\n", errno)); |
|
783 return -1; |
|
784 } |
|
785 } |
|
786 |
|
787 pid = FORK (); |
|
788 if (pid == (pid_t) 0) { |
|
789 /* Child side. */ |
|
790 CONST char *new_argv[4]; |
|
791 new_argv[0] = SHELL_NAME; |
|
792 new_argv[1] = "-c"; |
|
793 new_argv[2] = line; |
|
794 new_argv[3] = NULL; |
|
795 |
|
796 /* Restore the signals. */ |
|
797 (void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL); |
|
798 (void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL); |
|
799 (void) __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL); |
|
800 |
|
801 /* Exec the shell. */ |
|
802 (void) __execve (SHELL_PATH, (char *CONST *) new_argv, __environ); |
|
803 _exit (127); |
|
804 } else { |
|
805 if (pid < (pid_t) 0) { |
|
806 /* The fork failed. */ |
|
807 DPRINTF(("4: errno=%d\n", errno)); |
|
808 status = -1; |
|
809 } else { |
|
810 /* Parent side. */ |
|
811 #ifdef NO_WAITPID |
|
812 pid_t child; |
|
813 |
|
814 do { |
|
815 __BEGIN_INTERRUPTABLE__ |
|
816 child = __wait (&status); |
|
817 __END_INTERRUPTABLE__ |
|
818 if (child < 0 && errno != EINTR) { |
|
819 DPRINTF(("5: errno=%d\n", errno)); |
|
820 status = -1; |
|
821 break; |
|
822 } |
|
823 } while (child != pid); |
|
824 #else |
|
825 pid_t child; |
|
826 |
|
827 /* claus: the original did not care for EINTR here ... */ |
|
828 do { |
|
829 __BEGIN_INTERRUPTABLE__ |
|
830 child = __waitpid (pid, &status, 0); |
|
831 __END_INTERRUPTABLE__ |
|
832 } while ((child != pid) && (errno == EINTR)); |
|
833 if (child != pid) { |
|
834 DPRINTF(("6: errno=%d\n", errno)); |
|
835 status = -1; |
|
836 } |
|
837 #endif /* NO_WAITPID */ |
|
838 } |
|
839 } |
|
840 save = errno; |
|
841 if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL) |
|
842 | __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL) |
|
843 | __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)) != 0) { |
|
844 if (errno == ENOSYS) { |
|
845 errno = save; |
|
846 } else { |
|
847 status = -1; |
|
848 DPRINTF(("7: errno=%d\n", errno)); |
|
849 } |
|
850 } |
|
851 |
|
852 return status; |
|
853 } |
|
854 #else |
|
855 # define __wait wait |
|
856 #endif /* WANT_SYSTEM */ |
|
857 |
|
858 |
|
859 /* |
|
860 * some systems do not have realpath(); |
|
861 * the alternative of reading from a 'pwp'-pipe |
|
862 * is way too slow. Here is a realpath for the rest of us. |
|
863 * define WANT_REALPATH in the xxxIntern-file to get it. |
|
864 */ |
|
865 |
|
866 #if defined(HAS_REALPATH) |
|
867 # undef WANT_REALPATH |
|
868 #endif |
|
869 #if !defined(HAS_GETWD) && !defined(HAS_GETCWD) |
|
870 # undef WANT_REALPATH |
|
871 #endif |
|
872 |
|
873 #if defined(WANT_REALPATH) |
|
874 |
|
875 # ifndef NULL |
|
876 # define NULL (char *)0 |
|
877 # endif |
|
878 |
|
879 # define MAX_READLINKS 32 |
|
880 |
|
881 # ifndef MAXPATHLEN |
|
882 # define MAXPATHLEN 1024 |
|
883 # endif |
|
884 |
|
885 static |
|
886 char *realpath(path, resolved_path) |
|
887 char *path; |
|
888 char resolved_path []; |
|
889 { |
|
890 char copy_path[MAXPATHLEN]; |
|
891 char link_path[MAXPATHLEN]; |
|
892 char *new_path = resolved_path; |
|
893 char *max_path; |
|
894 int readlinks = 0; |
|
895 int n; |
|
896 |
|
897 /* Make a copy of the source path since we may need to modify it. */ |
|
898 strcpy(copy_path, path); |
|
899 path = copy_path; |
|
900 max_path = copy_path + MAXPATHLEN - 2; |
|
901 /* If it's a relative pathname use getwd for starters. */ |
|
902 if (*path != '/') { |
|
903 #ifdef HAS_GETCWD |
|
904 new_path = getcwd(new_path, MAXPATHLEN - 1); |
|
905 #else |
|
906 new_path = getwd(new_path); |
|
907 #endif |
|
908 if (new_path == NULL) |
|
909 return(NULL); |
|
910 |
|
911 new_path += strlen(new_path); |
|
912 if (new_path[-1] != '/') |
|
913 *new_path++ = '/'; |
|
914 } |
|
915 else { |
|
916 *new_path++ = '/'; |
|
917 path++; |
|
918 } |
|
919 /* Expand each slash-separated pathname component. */ |
|
920 while (*path != '\0') { |
|
921 /* Ignore stray "/". */ |
|
922 if (*path == '/') { |
|
923 path++; |
|
924 continue; |
|
925 } |
|
926 if (*path == '.') { |
|
927 /* Ignore ".". */ |
|
928 if (path[1] == '\0' || path[1] == '/') { |
|
929 path++; |
|
930 continue; |
|
931 } |
|
932 if (path[1] == '.') { |
|
933 if (path[2] == '\0' || path[2] == '/') { |
|
934 path += 2; |
|
935 /* Ignore ".." at root. */ |
|
936 if (new_path == resolved_path + 1) |
|
937 continue; |
|
938 /* Handle ".." by backing up. */ |
|
939 while ((--new_path)[-1] != '/') |
|
940 ; |
|
941 continue; |
|
942 } |
|
943 } |
|
944 } |
|
945 /* Safely copy the next pathname component. */ |
|
946 while (*path != '\0' && *path != '/') { |
|
947 if (path > max_path) { |
|
948 errno = ENAMETOOLONG; |
|
949 return NULL; |
|
950 } |
|
951 *new_path++ = *path++; |
|
952 } |
|
953 #ifdef S_IFLNK |
|
954 /* Protect against infinite loops. */ |
|
955 if (readlinks++ > MAX_READLINKS) { |
|
956 errno = ELOOP; |
|
957 return NULL; |
|
958 } |
|
959 /* See if latest pathname component is a symlink. */ |
|
960 *new_path = '\0'; |
|
961 n = readlink(resolved_path, link_path, MAXPATHLEN - 1); |
|
962 if (n < 0) { |
|
963 /* EINVAL means the file exists but isn't a symlink. */ |
|
964 if (errno != EINVAL) |
|
965 return NULL; |
|
966 } |
|
967 else { |
|
968 /* Note: readlink doesn't add the null byte. */ |
|
969 link_path[n] = '\0'; |
|
970 if (*link_path == '/') |
|
971 /* Start over for an absolute symlink. */ |
|
972 new_path = resolved_path; |
|
973 else |
|
974 /* Otherwise back up over this component. */ |
|
975 while (*(--new_path) != '/') |
|
976 ; |
|
977 /* Safe sex check. */ |
|
978 if (strlen(path) + n >= MAXPATHLEN) { |
|
979 errno = ENAMETOOLONG; |
|
980 return NULL; |
|
981 } |
|
982 /* Insert symlink contents into path. */ |
|
983 strcat(link_path, path); |
|
984 strcpy(copy_path, link_path); |
|
985 path = copy_path; |
|
986 } |
|
987 #endif /* S_IFLNK */ |
|
988 *new_path++ = '/'; |
|
989 } |
|
990 /* Delete trailing slash but don't whomp a lone slash. */ |
|
991 if (new_path != resolved_path + 1 && new_path[-1] == '/') |
|
992 new_path--; |
|
993 /* Make sure it's null terminated. */ |
|
994 *new_path = '\0'; |
|
995 return resolved_path; |
|
996 } |
|
997 # define HAS_REALPATH |
|
998 #endif /* WANT_REALPATH && not HAS_REALPATH */ |
|
999 |
390 |
1000 #ifdef __VMS__ |
391 #ifdef __VMS__ |
1001 |
392 |
1002 /* #define TRACE_STAT_CALLS /* */ |
393 /* #define TRACE_STAT_CALLS /* */ |
1003 /* #define TRACE_ACCESS_CALLS /* */ |
394 /* #define TRACE_ACCESS_CALLS /* */ |
7724 code = __MKUINT(endStatus); |
7028 code = __MKUINT(endStatus); |
7725 pid = __MKUINT(endPid); |
7029 pid = __MKUINT(endPid); |
7726 core = false; |
7030 core = false; |
7727 } |
7031 } |
7728 #endif /* __VMS__ */ |
7032 #endif /* __VMS__ */ |
7729 |
|
7730 #if defined(UNIX_LIKE) && !defined(__VMS__) |
|
7731 int p; |
|
7732 |
|
7733 # if defined(HAS_WAITPID) |
|
7734 |
|
7735 int s; |
|
7736 # define __WAIT waitpid(-1, &s, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED) |
|
7737 |
|
7738 # else |
|
7739 # if defined(HAS_WAIT3) |
|
7740 |
|
7741 union wait s; |
|
7742 # define __WAIT wait3(&s, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED, 0) |
|
7743 |
|
7744 # else /* neither waitpid, nor wait3; use wait, which is blocking */ |
|
7745 |
|
7746 int s; |
|
7747 # define __WAIT wait(&s) |
|
7748 # define __BLOCKING_WAIT__ 1 |
|
7749 |
|
7750 if (blocking != true) { |
|
7751 /* |
|
7752 * We do not support nonBlocking waits, so signal an error |
|
7753 * Sorry about the goto, but with all these ifdefs ... |
|
7754 */ |
|
7755 goto done; |
|
7756 } |
|
7757 # endif /*!HAS_WAIT3*/ |
|
7758 # endif /*!HAS_WAITPID*/ |
|
7759 |
|
7760 # if !defined(WIFEXITED) |
|
7761 # define WIFEXITED(stat) (((int)((stat)&0377))==0) |
|
7762 # define WIFSIGNALED(stat) (((int)((stat)&0377))>0&&((int)(((stat)>>8)&0377))==0) |
|
7763 # define WIFSTOPPED(stat) (((int)((stat)&0377))==0177&&((int)(((stat)>>8)&0377))!=0) |
|
7764 |
|
7765 # define WEXITSTATUS(stat) ((int)(((stat)>>8)&0377)) |
|
7766 # define WTERMSIG(stat) (((int)((stat)&0377))&0177) |
|
7767 # define WSTOPSIG(stat) ((int)(((stat)>>8)&0377)) |
|
7768 # endif /*!WIFEXITED*/ |
|
7769 |
|
7770 # if !defined(WCOREDUMP) |
|
7771 /* |
|
7772 * some systems lack that definition, although the field is there ... |
|
7773 */ |
|
7774 # if defined(HAS_WAIT3) |
|
7775 # define WCOREDUMP(status) (((union __wait*)&(status))->__w_coredump) |
|
7776 # else |
|
7777 # define WCOREDUMP(status) ((int)(((status)>>8)&0200)) |
|
7778 # endif |
|
7779 # endif /*!WCOREDUMP*/ |
|
7780 |
|
7781 # if __BLOCKING_WAIT__ |
|
7782 __BEGIN_INTERRUPTABLE__ |
|
7783 # endif |
|
7784 |
|
7785 do { |
|
7786 p = __WAIT; |
|
7787 } while (p == -1 && errno == EINTR); |
|
7788 |
|
7789 # if __BLOCKING_WAIT__ |
|
7790 __END_INTERRUPTABLE__ |
|
7791 # undef __BLOCKING_WAIT__ |
|
7792 # endif |
|
7793 |
|
7794 # undef __WAIT |
|
7795 |
|
7796 if (p == 0) |
|
7797 RETURN(nil) |
|
7798 |
|
7799 if (p == -1) { |
|
7800 if (errno == ECHILD) |
|
7801 RETURN(nil); |
|
7802 } else { |
|
7803 pid = __MKSMALLINT(p); |
|
7804 if (WIFEXITED(s)) { |
|
7805 status = @symbol(exit); |
|
7806 code = __MKSMALLINT(WEXITSTATUS(s)); |
|
7807 core = WCOREDUMP(s) ? true : false; |
|
7808 } else if (WIFSIGNALED(s)) { |
|
7809 status = @symbol(signal); |
|
7810 code = __MKSMALLINT(WTERMSIG(s)); |
|
7811 } else if (WIFSTOPPED(s)) { |
|
7812 status = @symbol(stop); |
|
7813 code = __MKSMALLINT(WSTOPSIG(s)); |
|
7814 } |
|
7815 # if defined(WIFCONTINUED) |
|
7816 else if (WIFCONTINUED(s)) { |
|
7817 status = @symbol(continue); |
|
7818 } |
|
7819 # endif |
|
7820 } |
|
7821 done: ; |
|
7822 #endif /* UNIX_LIKE */ |
|
7823 %}. |
7033 %}. |
7824 |
7034 |
7825 (status isNil or:[pid isNil]) ifTrue:[ |
7035 (status isNil or:[pid isNil]) ifTrue:[ |
7826 ^ self primitiveFailed |
7036 ^ self primitiveFailed |
7827 ]. |
7037 ]. |
7930 Empty fd-sets will always wait. Zero time can be used to poll file- |
7140 Empty fd-sets will always wait. Zero time can be used to poll file- |
7931 descriptors (i.e. to check if I/O possible without blocking). |
7141 descriptors (i.e. to check if I/O possible without blocking). |
7932 Return first ready fd if I/O ok, nil if timed-out or interrupted." |
7142 Return first ready fd if I/O ok, nil if timed-out or interrupted." |
7933 |
7143 |
7934 %{ |
7144 %{ |
7935 #ifdef WIN32S /* OLD code - without select NO-LONGER-USED */ |
|
7936 /* |
|
7937 * support a delay-wait only |
|
7938 * (i.e. fail if any filedescriptor is selected upon) |
|
7939 */ |
|
7940 int count; |
|
7941 int i; |
|
7942 int t; |
|
7943 OBJ fd; |
|
7944 |
|
7945 @global(LastErrorNumber) = nil; |
|
7946 |
|
7947 if (! __isSmallInteger(millis)) { |
|
7948 goto fail; |
|
7949 } |
|
7950 |
|
7951 if (readFdArray != nil) { |
|
7952 if (! __isArray(readFdArray)) { |
|
7953 goto fail; |
|
7954 } |
|
7955 count = __arraySize(readFdArray); |
|
7956 for (i=0; i<count;i++) { |
|
7957 fd = __ArrayInstPtr(readFdArray)->a_element[i]; |
|
7958 if (fd != nil) { |
|
7959 if (__isSmallInteger(fd) && (__intVal(fd) >= 0)) { |
|
7960 goto fail; |
|
7961 } |
|
7962 } |
|
7963 } |
|
7964 } |
|
7965 if (writeFdArray != nil) { |
|
7966 if (! __isArray(writeFdArray)) { |
|
7967 goto fail; |
|
7968 } |
|
7969 count = __arraySize(writeFdArray); |
|
7970 for (i=0; i<count;i++) { |
|
7971 fd = __ArrayInstPtr(writeFdArray)->a_element[i]; |
|
7972 if (fd != nil) { |
|
7973 if (__isSmallInteger(fd) && (__intVal(fd) >= 0)) { |
|
7974 goto fail; |
|
7975 } |
|
7976 } |
|
7977 } |
|
7978 } |
|
7979 if (exceptFdArray != nil) { |
|
7980 if (! __isArray(exceptFdArray)) { |
|
7981 goto fail; |
|
7982 } |
|
7983 count = __arraySize(exceptFdArray); |
|
7984 for (i=0; i<count;i++) { |
|
7985 fd = __ArrayInstPtr(exceptFdArray)->a_element[i]; |
|
7986 if (fd != nil) { |
|
7987 if (__isSmallInteger(fd) && (__intVal(fd) >= 0)) { |
|
7988 goto fail; |
|
7989 } |
|
7990 } |
|
7991 } |
|
7992 } |
|
7993 t = __intVal(millis); |
|
7994 if (t != 0) { |
|
7995 # if !defined(WIN32) || defined(WIN32s) |
|
7996 /* |
|
7997 * delay only |
|
7998 */ |
|
7999 Sleep(t); |
|
8000 } |
|
8001 RETURN (nil); |
|
8002 # else /* NT or WIN95 */ |
|
8003 HANDLE dummyHandle = (HANDLE)0; |
|
8004 |
|
8005 /* |
|
8006 * notice: MsgWait blocks if there is already a message in the q. |
|
8007 * (brain damage behavior) therefore, check queueStatus before |
|
8008 */ |
|
8009 fd_set rset, wset, eset; |
7145 fd_set rset, wset, eset; |
8010 struct timeval wt, et; |
7146 struct timeval wt, et; |
8011 int f, maxF, i, lX, bX; |
7147 int f, maxF, i, lX, bX; |
8012 INT t; |
7148 INT t; |
8013 OBJ fd, retFd; |
7149 OBJ fd, retFd; |
8014 int ret; |
7150 int ret; |
8015 int count; |
7151 int count; |
8016 int numFds = 0; |
7152 int numFds = 0; |
8017 |
7153 |
8018 if (__isSmallInteger(millis)) |
7154 if (__isSmallInteger(millis)) { |
8019 { |
|
8020 FD_ZERO(&rset); |
7155 FD_ZERO(&rset); |
8021 FD_ZERO(&wset); |
7156 FD_ZERO(&wset); |
8022 FD_ZERO(&eset); |
7157 FD_ZERO(&eset); |
8023 |
7158 |
8024 maxF = -1; |
7159 maxF = -1; |
8025 if (readFdArray != nil) { |
7160 if (__isNonNilObject(readFdArray)) { |
8026 if (! __isArray(readFdArray)) { |
7161 if (! __isArray(readFdArray)) { |
8027 goto fail; |
7162 goto fail; |
8028 } |
7163 } |
8029 count = __arraySize(readFdArray); |
7164 count = __arraySize(readFdArray); |
8030 |
7165 |
8031 for (i=0; i<count;i++) { |
7166 for (i=0; i<count;i++) { |
8032 fd = __ArrayInstPtr(readFdArray)->a_element[i]; |
7167 fd = __ArrayInstPtr(readFdArray)->a_element[i]; |
8085 wt.tv_sec = wt.tv_usec = 0; |
7220 wt.tv_sec = wt.tv_usec = 0; |
8086 } |
7221 } |
8087 |
7222 |
8088 /* |
7223 /* |
8089 * make certain, that interrupt gets us out of the select |
7224 * make certain, that interrupt gets us out of the select |
|
7225 * However, we must then care for moved objects. |
8090 */ |
7226 */ |
8091 __BEGIN_INTERRUPTABLE__ |
7227 __BEGIN_INTERRUPTABLE__ |
8092 errno = 0; |
7228 errno = 0; |
8093 |
7229 |
8094 if (t == 0) { |
7230 if (t == 0) { |
8095 /* |
7231 /* |
8096 * if there is no timeout time, we can stay here |
7232 * if there is no timeout time, we can stay here interruptable. |
8097 * interruptable. |
|
8098 */ |
7233 */ |
8099 do { |
7234 do { |
8100 # ifdef WIN32 |
|
8101 intf we; |
|
8102 if (numFds == 0) { |
|
8103 HANDLE dummyHandle = (HANDLE)0; |
|
8104 # if 0 |
|
8105 if (! GetQueueStatus(QS_ALLINPUT)) { |
|
8106 MsgWaitForMultipleObjects(0, &dummyHandle, FALSE, t, QS_ALLINPUT); |
|
8107 } |
|
8108 ret = 0; |
|
8109 # endif |
|
8110 if (we = __getWaitInputEvent()) |
|
8111 we(t); |
|
8112 ret = 0; |
|
8113 } else { |
|
8114 ret = select(0, &rset, &wset, &eset, &wt); |
|
8115 } |
|
8116 # else |
|
8117 ret = select(maxF+1, &rset, &wset, &eset, &wt); |
7235 ret = select(maxF+1, &rset, &wset, &eset, &wt); |
8118 # endif /* WIN32 */ |
|
8119 } while ((ret < 0) && (errno == EINTR)); |
7236 } while ((ret < 0) && (errno == EINTR)); |
8120 } else { |
7237 } else { |
8121 do { |
7238 do { |
8122 # ifdef WIN32 |
|
8123 intf we; |
|
8124 if (numFds == 0) { |
|
8125 HANDLE dummyHandle = (HANDLE)0; |
|
8126 # if 0 |
|
8127 if (! GetQueueStatus(QS_ALLINPUT)) { |
|
8128 MsgWaitForMultipleObjects(0, &dummyHandle, FALSE, t, QS_ALLINPUT); |
|
8129 } |
|
8130 ret = 0; |
|
8131 # endif |
|
8132 if (we = __getWaitInputEvent()) |
|
8133 we(t); |
|
8134 ret = 0; |
|
8135 } else { |
|
8136 ret = select(0, &rset, &wset, &eset, &wt); |
|
8137 } |
|
8138 # else |
|
8139 ret = select(maxF+1, &rset, &wset, &eset, &wt); |
7239 ret = select(maxF+1, &rset, &wset, &eset, &wt); |
8140 # endif /* WIN32 */ |
7240 /* |
8141 /* |
|
8142 * for now: dont loop; if we did, we had to adjust the vt-timeval; |
7241 * for now: dont loop; if we did, we had to adjust the vt-timeval; |
8143 * could otherwise stay in this loop forever ... |
7242 * could otherwise stay in this loop forever ... |
8144 * Premature return (before the time expired) must be handled by the caller. |
7243 * Premature return (before the time expired) must be handled by the caller. |
8145 * A good solution is to update the wt-timeval and redo the select. |
7244 * A good solution is to update the wt-timeval and redo the select. |
8146 */ |
7245 */ |
8176 * return nil (means time expired or interrupted) |
7275 * return nil (means time expired or interrupted) |
8177 */ |
7276 */ |
8178 RETURN ( nil ); |
7277 RETURN ( nil ); |
8179 } |
7278 } |
8180 |
7279 |
8181 # endif /* NT or WIN95 */ |
|
8182 |
|
8183 #else /* not WIN32S */ |
|
8184 |
|
8185 fd_set rset, wset, eset; |
|
8186 struct timeval wt, et; |
|
8187 int f, maxF, i, lX, bX; |
|
8188 INT t; |
|
8189 OBJ fd, retFd; |
|
8190 int ret; |
|
8191 int count; |
|
8192 int numFds = 0; |
|
8193 |
|
8194 if (__isSmallInteger(millis)) { |
|
8195 FD_ZERO(&rset); |
|
8196 FD_ZERO(&wset); |
|
8197 FD_ZERO(&eset); |
|
8198 |
|
8199 maxF = -1; |
|
8200 if (__isNonNilObject(readFdArray)) { |
|
8201 if (! __isArray(readFdArray)) { |
|
8202 goto fail; |
|
8203 } |
|
8204 count = __arraySize(readFdArray); |
|
8205 |
|
8206 for (i=0; i<count;i++) { |
|
8207 fd = __ArrayInstPtr(readFdArray)->a_element[i]; |
|
8208 if (fd != nil) { |
|
8209 f = __intVal(fd); |
|
8210 if ((unsigned)f < FD_SETSIZE) { |
|
8211 FD_SET(f, &rset); |
|
8212 if (f > maxF) maxF = f; |
|
8213 numFds++; |
|
8214 } |
|
8215 } |
|
8216 } |
|
8217 } |
|
8218 |
|
8219 if (__isNonNilObject(writeFdArray)) { |
|
8220 if (! __isArray(writeFdArray)) { |
|
8221 goto fail; |
|
8222 } |
|
8223 count = __arraySize(writeFdArray); |
|
8224 for (i=0; i<count;i++) { |
|
8225 fd = __ArrayInstPtr(writeFdArray)->a_element[i]; |
|
8226 if (fd != nil) { |
|
8227 f = __intVal(fd); |
|
8228 if ((unsigned)f < FD_SETSIZE) { |
|
8229 FD_SET(f, &wset); |
|
8230 if (f > maxF) maxF = f; |
|
8231 numFds++; |
|
8232 } |
|
8233 } |
|
8234 } |
|
8235 } |
|
8236 |
|
8237 if (__isNonNilObject(exceptFdArray)) { |
|
8238 if (! __isArray(exceptFdArray)) { |
|
8239 goto fail; |
|
8240 } |
|
8241 count = __arraySize(exceptFdArray); |
|
8242 for (i=0; i<count;i++) { |
|
8243 fd = __ArrayInstPtr(exceptFdArray)->a_element[i]; |
|
8244 if (fd != nil) { |
|
8245 f = __intVal(fd); |
|
8246 if ((unsigned)f < FD_SETSIZE) { |
|
8247 FD_SET(f, &eset); |
|
8248 if (f > maxF) maxF = f; |
|
8249 numFds++; |
|
8250 } |
|
8251 } |
|
8252 } |
|
8253 } |
|
8254 |
|
8255 t = __intVal(millis); |
|
8256 if (t) { |
|
8257 wt.tv_sec = t / 1000; |
|
8258 wt.tv_usec = (t % 1000) * 1000; |
|
8259 } else { |
|
8260 wt.tv_sec = wt.tv_usec = 0; |
|
8261 } |
|
8262 |
|
8263 /* |
|
8264 * make certain, that interrupt gets us out of the select |
|
8265 * However, we must then care for moved objects. |
|
8266 */ |
|
8267 __BEGIN_INTERRUPTABLE__ |
|
8268 errno = 0; |
|
8269 |
|
8270 if (t == 0) { |
|
8271 /* |
|
8272 * if there is no timeout time, we can stay here interruptable. |
|
8273 */ |
|
8274 do { |
|
8275 # ifdef WIN32 |
|
8276 intf we; |
|
8277 |
|
8278 if (numFds == 0) { |
|
8279 HANDLE dummyHandle = (HANDLE)0; |
|
8280 |
|
8281 # if 0 /* does not work under WIN95 - sigh */ |
|
8282 if (! GetQueueStatus(QS_ALLINPUT)) { |
|
8283 MsgWaitForMultipleObjects(0, &dummyHandle, FALSE, t, QS_ALLINPUT); |
|
8284 } |
|
8285 # else |
|
8286 if (we = __getWaitInputEvent()) { |
|
8287 we(t); |
|
8288 } |
|
8289 # endif |
|
8290 ret = 0; |
|
8291 } else { |
|
8292 ret = select(0, &rset, &wset, &eset, &wt); |
|
8293 } |
|
8294 # else /* a real OS */ |
|
8295 ret = select(maxF+1, &rset, &wset, &eset, &wt); |
|
8296 # endif /* to WIN or not to WIN */ |
|
8297 } while ((ret < 0) && (errno == EINTR)); |
|
8298 } else { |
|
8299 do { |
|
8300 # ifdef WIN32 |
|
8301 intf we; |
|
8302 |
|
8303 if (numFds == 0) { |
|
8304 HANDLE dummyHandle = (HANDLE)0; |
|
8305 # if 0 /* does not work under WIN95 - sigh */ |
|
8306 if (! GetQueueStatus(QS_ALLINPUT)) { |
|
8307 MsgWaitForMultipleObjects(0, &dummyHandle, FALSE, t, QS_ALLINPUT); |
|
8308 } |
|
8309 # else |
|
8310 if (we = __getWaitInputEvent()) { |
|
8311 we(t); |
|
8312 } |
|
8313 # endif |
|
8314 ret = 0; |
|
8315 } else { |
|
8316 ret = select(0, &rset, &wset, &eset, &wt); |
|
8317 } |
|
8318 # else /* a real OS */ |
|
8319 ret = select(maxF+1, &rset, &wset, &eset, &wt); |
|
8320 # endif * to WIN or not to WIN */ |
|
8321 /* |
|
8322 * for now: dont loop; if we did, we had to adjust the vt-timeval; |
|
8323 * could otherwise stay in this loop forever ... |
|
8324 * Premature return (before the time expired) must be handled by the caller. |
|
8325 * A good solution is to update the wt-timeval and redo the select. |
|
8326 */ |
|
8327 } while (0 /* (ret < 0) && (errno == EINTR) */ ); |
|
8328 } |
|
8329 __END_INTERRUPTABLE__ |
|
8330 |
|
8331 if (ret > 0) { |
|
8332 for (i=0; i <= maxF; i++) { |
|
8333 if (FD_ISSET(i, &rset) |
|
8334 || FD_ISSET(i, &wset) |
|
8335 || FD_ISSET(i, &eset)) { |
|
8336 RETURN ( __MKSMALLINT(i) ); |
|
8337 } |
|
8338 } |
|
8339 } else { |
|
8340 if (ret < 0) { |
|
8341 if (errno == EINTR) { |
|
8342 errno = 0; |
|
8343 @global(LastErrorNumber) = nil; |
|
8344 } else { |
|
8345 if (@global(InfoPrinting) == true) { |
|
8346 fprintf(stderr, "OS [info]: select errno = %d\n", errno); |
|
8347 } |
|
8348 @global(LastErrorNumber) = __MKSMALLINT(errno); |
|
8349 } |
|
8350 } else { |
|
8351 @global(LastErrorNumber) = nil; |
|
8352 } |
|
8353 } |
|
8354 |
|
8355 /* |
|
8356 * return nil (means time expired or interrupted) |
|
8357 */ |
|
8358 RETURN ( nil ); |
|
8359 } |
|
8360 #endif /* not MSDOS_LIKE */ |
|
8361 |
|
8362 fail: ; |
7280 fail: ; |
8363 %}. |
7281 %}. |
8364 " |
7282 " |
8365 timeout argument not integer, |
7283 timeout argument not integer, |
8366 or any fd-array nonNil and not an array |
7284 or any fd-array nonNil and not an array |