FD_CLR FD_ISSET FD_SET FD_ZERO accept acct adjtime adjtimex bdflush
bind break brk cacheflush capget capset chroot clone connect
-create_module delete_module execve exit flock fork
+create_module delete_module execve exit flock
fstatfs ftime getcontext getdents getdomainname
getdtablesize getgroups gethostid gethostname getitimer
getpeername getpriority getrlimit getrusage getsockname getsockopt
sigpending sigprocmask sigreturn sigsetmask sigsuspend sigvec socket
socketcall socketpair ssetmask statfs stime stty swapoff swapon
syscalls sysctl sysfs sysinfo syslog time times
-ulimit umount uname ustat utime utimes vfork vhangup wait wait3
-wait4 waitpid write writev
+ulimit umount uname ustat utime utimes vfork vhangup wait3
+wait4 write writev
4) In the spec but not implemented:
;;; first, the headers necessary to find definitions of everything
(#||#
"sys/types.h"
- "unistd.h"
"sys/stat.h"
"sys/socket.h" "sys/un.h" "netinet/in.h" "netinet/in_systm.h"
- "netinet/ip.h" "net/if.h" "netdb.h" "errno.h" "netinet/tcp.h"
- "fcntl.h" "sys/mman.h"
+ "netinet/ip.h" "net/if.h" "netinet/tcp.h" "sys/mman.h" "sys/wait.h"
+ "fcntl.h"
+ "netdb.h" "errno.h"
"dirent.h" "signal.h"
+ "unistd.h"
"termios.h")
(:integer enomedium "ENOMEDIUM" nil t)
(:integer emediumtype "EMEDIUMTYPE" nil t)
+ ;; wait
+ (:integer wnohang "WNOHANG")
+ (:integer wuntraced "WUNTRACED")
+
;; mode_t
(:type mode-t "mode_t")
(:integer s-isuid "S_ISUID" nil t)
(define-call "chmod" int minusp (pathname filename) (mode sb-posix::mode-t))
(define-call "chown" int minusp (pathname filename)
(owner sb-posix::uid-t) (group sb-posix::gid-t))
+(define-call "chroot" int minusp (pathname filename))
(define-call "close" int minusp (fd file-descriptor))
(define-call "creat" int minusp (pathname filename) (mode sb-posix::mode-t))
(define-call "dup" int minusp (oldfd file-descriptor))
;;; processes, signals
(define-call "alarm" int never-fails (seconds unsigned))
+(define-call "fork" sb-posix::pid-t minusp)
(define-call "getpgid" sb-posix::pid-t minusp (pid sb-posix::pid-t))
(define-call "getpid" sb-posix::pid-t never-fails)
(define-call "getppid" sb-posix::pid-t never-fails)
(pid sb-posix::pid-t) (pgid sb-posix::pid-t))
(define-call "setpgrp" int minusp)
+(export 'sb-posix::wait :sb-posix)
+(declaim (inline sb-posix::wait))
+(defun sb-posix::wait (&optional statusptr)
+ (declare (type (or null (simple-array (signed-byte 32) (1))) statusptr))
+ (let* ((ptr (or statusptr (make-array 1 :element-type '(signed-byte 32))))
+ (pid (alien-funcall
+ (extern-alien "wait" (function sb-posix::pid-t (* int)))
+ (sb-sys:vector-sap ptr))))
+ (if (minusp pid)
+ (syscall-error)
+ (values pid (aref ptr 0)))))
+
+(export 'sb-posix::waitpid :sb-posix)
+(declaim (inline sb-posix::waitpid))
+(defun sb-posix::waitpid (pid options &optional statusptr)
+ (declare (type (sb-alien:alien sb-posix::pid-t) pid)
+ (type (sb-alien:alien int) options)
+ (type (or null (simple-array (signed-byte 32) (1))) statusptr))
+ (let* ((ptr (or statusptr (make-array 1 :element-type '(signed-byte 32))))
+ (pid (alien-funcall
+ (extern-alien "waitpid" (function sb-posix::pid-t
+ sb-posix::pid-t (* int) int))
+ pid (sb-sys:vector-sap ptr) options)))
+ (if (minusp pid)
+ (syscall-error)
+ (values pid (aref ptr 0)))))
+
+;; waitpid macros
+(define-call "wifexited" boolean never-fails (status int))
+(define-call "wexitstatus" int never-fails (status int))
+(define-call "wifsignaled" boolean never-fails (status int))
+(define-call "wtermsig" int never-fails (status int))
+(define-call "wifstopped" boolean never-fails (status int))
+(define-call "wstopsig" int never-fails (status int))
+#+nil ; see alien/waitpid-macros.c
+(define-call "wifcontinued" boolean never-fails (status int))
+
;;; mmap, msync
(define-call "mmap" sb-sys:system-area-pointer
;; KLUDGE: #XFFFFFFFF is (void *)-1, which is the charming return