X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Funix.lisp;h=7a1a62888c6d29f34fd0457e39aebf85328226de;hb=a6a12ed609d5467ec43b411283e5b3568fee81df;hp=64db7ed483ee66aef185abe89e3b48cb4a42ccaf;hpb=b021c15b8d8e4ea4740323eaee9535c4e7cb2232;p=sbcl.git diff --git a/src/code/unix.lisp b/src/code/unix.lisp index 64db7ed..7a1a628 100644 --- a/src/code/unix.lisp +++ b/src/code/unix.lisp @@ -427,9 +427,20 @@ corresponds to NAME, or NIL if there is none." ;;; Terminate the current process with an optional error code. If ;;; successful, the call doesn't return. If unsuccessful, the call ;;; returns NIL and an error number. -(defun unix-exit (&optional (code 0)) - (declare (type (signed-byte 32) code)) - (void-syscall ("exit" int) code)) +(deftype exit-code () + `(signed-byte 32)) +(defun os-exit (code &key abort) + #!+sb-doc + "Exit the process with CODE. If ABORT is true, exit is performed using _exit(2), +avoiding atexit(3) hooks, etc. Otherwise exit(2) is called." + (unless (typep code 'exit-code) + (setf code (if abort 1 0))) + (if abort + (void-syscall ("_exit" int) code) + (void-syscall ("exit" int) code))) + +(define-deprecated-function :early "1.0.56.55" unix-exit os-exit (code) + (os-exit code)) ;;; Return the process id of the current process. (define-alien-routine ("getpid" unix-getpid) int) @@ -950,8 +961,8 @@ corresponds to NAME, or NIL if there is none." (defun nanosleep (secs nsecs) (with-alien ((req (struct timespec)) (rem (struct timespec))) - (setf (slot req 'tv-sec) secs) - (setf (slot req 'tv-nsec) nsecs) + (setf (slot req 'tv-sec) secs + (slot req 'tv-nsec) nsecs) (loop while (and (eql sb!unix:eintr (nth-value 1 (int-syscall ("nanosleep" (* (struct timespec)) @@ -976,10 +987,12 @@ corresponds to NAME, or NIL if there is none." (rem-nsec (slot rem 'tv-nsec))) (when (or (> secs rem-sec) (and (= secs rem-sec) (>= nsecs rem-nsec))) - (setf secs rem-sec + ;; Update for next round. + (setf secs rem-sec nsecs rem-nsec) t))) - do (rotatef req rem)))) + do (setf (slot req 'tv-sec) (slot rem 'tv-sec) + (slot req 'tv-nsec) (slot rem 'tv-nsec))))) (defun unix-get-seconds-west (secs) (multiple-value-bind (ignore seconds dst) (get-timezone secs)