diff options
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | sysif.c | 98 | ||||
-rw-r--r-- | tl.vim | 261 | ||||
-rw-r--r-- | txr.1 | 132 | ||||
-rw-r--r-- | txr.vim | 261 |
5 files changed, 510 insertions, 258 deletions
@@ -1,3 +1,19 @@ +2015-04-09 Kaz Kylheku <kaz@kylheku.com> + + Fork and wait support. + + * sysif.c (work_wrap, wait_wrap, wifexited, wexitstatus, + wifsignaled, wtermsig, wcoredump, wifstopped, wstopsig, + wifcontinued): New static functions. + (sysif_init): Register new intrinsics: functions fork, wait, + w-ifexited, w-exitstatus, w-ifsignaled, w-termsig, + w-coredump, w-ifstopped, w-stopsig, w-ifcontinued; and + variables w-nohang, w-untraced, w-continued. + + * txr.1: Documented. + + * tl.vim, txr.vim: Regenerated. + 2015-04-06 Kaz Kylheku <kaz@kylheku.com> * eval.c (iflet_s, when_s): New global variables. @@ -384,6 +384,78 @@ static val readlink_wrap(val path) #endif +#if HAVE_SYS_WAIT +static val fork_wrap(void) +{ + pid_t pid = fork(); + + if (pid < 0) + return nil; + return num(pid); +} + +static val wait_wrap(val pid, val flags) +{ + cnum p = c_num(default_arg(pid, negone)); + cnum f = c_num(default_arg(flags, zero)); + int status = 0, result = waitpid(p, &status, f); + return if2(result >= 0, cons(num(result), num(status))); +} + +static val wifexited(val status) +{ + int s = c_num(if3(consp(status), cdr(status), status)); + return c_true(WIFEXITED(s)); +} + +static val wexitstatus(val status) +{ + int s = c_num(if3(consp(status), cdr(status), status)); + return num(WEXITSTATUS(s)); +} + +static val wifsignaled(val status) +{ + int s = c_num(if3(consp(status), cdr(status), status)); + return c_true(WIFSIGNALED(s)); +} + +static val wtermsig(val status) +{ + int s = c_num(if3(consp(status), cdr(status), status)); + return num(WTERMSIG(s)); +} + +#ifdef WCOREDUMP +static val wcoredump(val status) +{ + int s = c_num(if3(consp(status), cdr(status), status)); + return c_true(WCOREDUMP(s)); +} +#endif + +static val wifstopped(val status) +{ + int s = c_num(if3(consp(status), cdr(status), status)); + return c_true(WIFSTOPPED(s)); +} + +static val wstopsig(val status) +{ + int s = c_num(if3(consp(status), cdr(status), status)); + return num(WSTOPSIG(s)); +} + +#ifdef WIFCONTINUED +static val wifcontinued(val status) +{ + int s = c_num(if3(consp(status), cdr(status), status)); + return c_true(WIFCONTINUED(s)); +} +#endif + +#endif + #if HAVE_SYS_STAT static int w_stat(const wchar_t *wpath, struct stat *buf) { @@ -554,4 +626,30 @@ void sysif_init(void) reg_var(intern(lit("s-iwoth"), user_package), num_fast(S_IWOTH)); reg_var(intern(lit("s-ixoth"), user_package), num_fast(S_IXOTH)); #endif + +#if HAVE_SYS_WAIT + reg_fun(intern(lit("fork"), user_package), func_n0(fork_wrap)); + reg_fun(intern(lit("wait"), user_package), func_n2o(wait_wrap, 0)); + reg_fun(intern(lit("w-ifexited"), user_package), func_n1(wifexited)); + reg_fun(intern(lit("w-exitstatus"), user_package), func_n1(wexitstatus)); + reg_fun(intern(lit("w-ifsignaled"), user_package), func_n1(wifsignaled)); + reg_fun(intern(lit("w-termsig"), user_package), func_n1(wtermsig)); +#ifdef WCOREDUMP + reg_fun(intern(lit("w-coredump"), user_package), func_n1(wcoredump)); +#endif + reg_fun(intern(lit("w-ifstopped"), user_package), func_n1(wifstopped)); + reg_fun(intern(lit("w-stopsig"), user_package), func_n1(wstopsig)); +#ifdef WIFCONTINUED + reg_fun(intern(lit("w-ifcontinued"), user_package), func_n1(wifcontinued)); +#endif +#ifdef WNOHANG + reg_var(intern(lit("w-nohang"), user_package), num_fast(WNOHANG)); +#endif +#ifdef WUNTRACED + reg_var(intern(lit("w-untraced"), user_package), num_fast(WUNTRACED)); +#endif +#ifdef WCONTINUED + reg_var(intern(lit("w-continued"), user_package), num_fast(WCONTINUED)); +#endif +#endif } @@ -66,135 +66,138 @@ syn keyword txl_keyword contained find-max find-min find-package first syn keyword txl_keyword contained fixnump flatten flatten* flet syn keyword txl_keyword contained flip flo-int flo-str floatp syn keyword txl_keyword contained floor flush-stream for for* -syn keyword txl_keyword contained force format fourth fun -syn keyword txl_keyword contained func-get-env func-get-form func-set-env functionp -syn keyword txl_keyword contained gcd gen generate gensym -syn keyword txl_keyword contained gequal get-byte get-char get-error -syn keyword txl_keyword contained get-error-str get-hash-userdata get-line get-lines -syn keyword txl_keyword contained get-list-from-stream get-sig-handler get-string get-string-from-stream -syn keyword txl_keyword contained gethash getitimer getpid getppid -syn keyword txl_keyword contained giterate glob glob-altdirfunc glob-brace -syn keyword txl_keyword contained glob-err glob-mark glob-nocheck glob-noescape -syn keyword txl_keyword contained glob-nomagic glob-nosort glob-onlydir glob-period -syn keyword txl_keyword contained glob-tilde glob-tilde-check greater group-by -syn keyword txl_keyword contained gun hash hash-alist hash-construct -syn keyword txl_keyword contained hash-count hash-diff hash-eql hash-equal -syn keyword txl_keyword contained hash-isec hash-keys hash-pairs hash-uni -syn keyword txl_keyword contained hash-update hash-update-1 hash-values hashp -syn keyword txl_keyword contained html-decode html-encode iapply identity -syn keyword txl_keyword contained ido if iff iffi -syn keyword txl_keyword contained iflet ignerr in inc -syn keyword txl_keyword contained inhash int-flo int-str integerp -syn keyword txl_keyword contained intern interp-fun-p interpose ip -syn keyword txl_keyword contained ipf isqrt itimer-prov itimer-real -syn keyword txl_keyword contained itimer-virtual juxt keep-if keep-if* -syn keyword txl_keyword contained keywordp kill labels lambda -syn keyword txl_keyword contained last lazy-str lazy-str-force lazy-str-force-upto -syn keyword txl_keyword contained lazy-str-get-trailing-list lazy-stream-cons lazy-stringp lbind -syn keyword txl_keyword contained lcm lcons-fun lconsp ldiff -syn keyword txl_keyword contained length length-list length-str length-str-< -syn keyword txl_keyword contained length-str-<= length-str-> length-str->= length-vec -syn keyword txl_keyword contained lequal less let let* -syn keyword txl_keyword contained lexical-fun-p lexical-lisp1-binding lexical-var-p link -syn keyword txl_keyword contained lisp-parse list list* list-str -syn keyword txl_keyword contained list-vector listp log log-alert -syn keyword txl_keyword contained log-auth log-authpriv log-cons log-crit -syn keyword txl_keyword contained log-daemon log-debug log-emerg log-err -syn keyword txl_keyword contained log-info log-ndelay log-notice log-nowait -syn keyword txl_keyword contained log-odelay log-perror log-pid log-user -syn keyword txl_keyword contained log-warning log10 log2 logand -syn keyword txl_keyword contained logior lognot logtest logtrunc -syn keyword txl_keyword contained logxor macro-form-p macro-time macroexpand -syn keyword txl_keyword contained macroexpand-1 macrolet major make-catenated-stream -syn keyword txl_keyword contained make-env make-hash make-lazy-cons make-like -syn keyword txl_keyword contained make-package make-random-state make-similar-hash make-string-byte-input-stream -syn keyword txl_keyword contained make-string-input-stream make-string-output-stream make-strlist-output-stream make-sym -syn keyword txl_keyword contained make-time make-time-utc make-trie makedev -syn keyword txl_keyword contained mapcar mapcar* mapdo mapf -syn keyword txl_keyword contained maphash mappend mappend* mask -syn keyword txl_keyword contained match-fun match-regex match-regex-right match-regst -syn keyword txl_keyword contained match-regst-right match-str match-str-tree max -syn keyword txl_keyword contained member member-if memq memql -syn keyword txl_keyword contained memqual merge min minor -syn keyword txl_keyword contained minusp mkdir mknod mkstring -syn keyword txl_keyword contained mod multi multi-sort n-choose-k -syn keyword txl_keyword contained n-perm-k nconc nilf none -syn keyword txl_keyword contained not notf nreverse null -syn keyword txl_keyword contained nullify num-chr num-str numberp -syn keyword txl_keyword contained oand oddp op open-command -syn keyword txl_keyword contained open-directory open-file open-files open-files* -syn keyword txl_keyword contained open-pipe open-process open-tail openlog -syn keyword txl_keyword contained opip or orf packagep -syn keyword txl_keyword contained pad partition partition* partition-by -syn keyword txl_keyword contained perm plusp pop pos -syn keyword txl_keyword contained pos-if pos-max pos-min posq -syn keyword txl_keyword contained posql posqual pppred ppred -syn keyword txl_keyword contained pprinl pprint pprof pred -syn keyword txl_keyword contained prinl print prof prog1 -syn keyword txl_keyword contained progn prop proper-listp push -syn keyword txl_keyword contained pushhash put-byte put-char put-line -syn keyword txl_keyword contained put-lines put-string put-strings pwd -syn keyword txl_keyword contained qquote quasi quasilist quote -syn keyword txl_keyword contained rand random random-fixnum random-state-p -syn keyword txl_keyword contained range range* range-regex rcomb -syn keyword txl_keyword contained read readlink real-time-stream-p reduce-left -syn keyword txl_keyword contained reduce-right ref refset regex-compile -syn keyword txl_keyword contained regex-parse regexp regsub rehome-sym -syn keyword txl_keyword contained remhash remove-if remove-if* remove-path -syn keyword txl_keyword contained remq remq* remql remql* -syn keyword txl_keyword contained remqual remqual* rename-path repeat -syn keyword txl_keyword contained replace replace-list replace-str replace-vec -syn keyword txl_keyword contained rest ret retf return -syn keyword txl_keyword contained return-from reverse rlcp rperm -syn keyword txl_keyword contained rplaca rplacd run s-ifblk -syn keyword txl_keyword contained s-ifchr s-ifdir s-ififo s-iflnk -syn keyword txl_keyword contained s-ifmt s-ifreg s-ifsock s-irgrp -syn keyword txl_keyword contained s-iroth s-irusr s-irwxg s-irwxo -syn keyword txl_keyword contained s-irwxu s-isgid s-isuid s-isvtx -syn keyword txl_keyword contained s-iwgrp s-iwoth s-iwusr s-ixgrp -syn keyword txl_keyword contained s-ixoth s-ixusr search search-regex -syn keyword txl_keyword contained search-regst search-str search-str-tree second -syn keyword txl_keyword contained seek-stream select seqp set -syn keyword txl_keyword contained set-diff set-hash-userdata set-sig-handler sethash -syn keyword txl_keyword contained setitimer setlogmask sh sig-abrt -syn keyword txl_keyword contained sig-alrm sig-bus sig-check sig-chld -syn keyword txl_keyword contained sig-cont sig-fpe sig-hup sig-ill -syn keyword txl_keyword contained sig-int sig-io sig-iot sig-kill -syn keyword txl_keyword contained sig-lost sig-pipe sig-poll sig-prof -syn keyword txl_keyword contained sig-pwr sig-quit sig-segv sig-stkflt -syn keyword txl_keyword contained sig-stop sig-sys sig-term sig-trap -syn keyword txl_keyword contained sig-tstp sig-ttin sig-ttou sig-urg -syn keyword txl_keyword contained sig-usr1 sig-usr2 sig-vtalrm sig-winch -syn keyword txl_keyword contained sig-xcpu sig-xfsz sign-extend sin -syn keyword txl_keyword contained sixth size-vec some sort -syn keyword txl_keyword contained sort-group source-loc source-loc-str span-str -syn keyword txl_keyword contained splice split-str split-str-set sqrt -syn keyword txl_keyword contained sssucc ssucc stat stdlib -syn keyword txl_keyword contained str< str<= str= str> -syn keyword txl_keyword contained str>= stream-get-prop stream-set-prop streamp -syn keyword txl_keyword contained string-extend string-lt stringp sub -syn keyword txl_keyword contained sub-list sub-str sub-vec succ -syn keyword txl_keyword contained symacrolet symbol-function symbol-name symbol-package -syn keyword txl_keyword contained symbol-value symbolp symlink sys-qquote -syn keyword txl_keyword contained sys-splice sys-unquote syslog tan -syn keyword txl_keyword contained tb tc tf third -syn keyword txl_keyword contained throw throwf time time-fields-local -syn keyword txl_keyword contained time-fields-utc time-string-local time-string-utc time-usec -syn keyword txl_keyword contained tofloat toint tok-str tok-where -syn keyword txl_keyword contained tostring tostringp tprint transpose -syn keyword txl_keyword contained tree-bind tree-case tree-find trie-add -syn keyword txl_keyword contained trie-compress trie-lookup-begin trie-lookup-feed-char trie-value-at -syn keyword txl_keyword contained trim-str true trunc trunc-rem -syn keyword txl_keyword contained tuples txr-case txr-if txr-when -syn keyword txl_keyword contained typeof unget-byte unget-char uniq -syn keyword txl_keyword contained unique unless unquote until -syn keyword txl_keyword contained upcase-str update url-decode url-encode -syn keyword txl_keyword contained usleep uw-protect vec vec-push -syn keyword txl_keyword contained vec-set-length vecref vector vector-list -syn keyword txl_keyword contained vectorp weave when whenlet -syn keyword txl_keyword contained where while whilet width -syn keyword txl_keyword contained with-saved-vars wrap wrap* zap -syn keyword txl_keyword contained zerop zip +syn keyword txl_keyword contained force fork format fourth +syn keyword txl_keyword contained fun func-get-env func-get-form func-set-env +syn keyword txl_keyword contained functionp gcd gen generate +syn keyword txl_keyword contained gensym gequal get-byte get-char +syn keyword txl_keyword contained get-error get-error-str get-hash-userdata get-line +syn keyword txl_keyword contained get-lines get-list-from-stream get-sig-handler get-string +syn keyword txl_keyword contained get-string-from-stream gethash getitimer getpid +syn keyword txl_keyword contained getppid giterate glob glob-altdirfunc +syn keyword txl_keyword contained glob-brace glob-err glob-mark glob-nocheck +syn keyword txl_keyword contained glob-noescape glob-nomagic glob-nosort glob-onlydir +syn keyword txl_keyword contained glob-period glob-tilde glob-tilde-check greater +syn keyword txl_keyword contained group-by gun hash hash-alist +syn keyword txl_keyword contained hash-construct hash-count hash-diff hash-eql +syn keyword txl_keyword contained hash-equal hash-isec hash-keys hash-pairs +syn keyword txl_keyword contained hash-uni hash-update hash-update-1 hash-values +syn keyword txl_keyword contained hashp html-decode html-encode iapply +syn keyword txl_keyword contained identity ido if iff +syn keyword txl_keyword contained iffi iflet ignerr in +syn keyword txl_keyword contained inc inhash int-flo int-str +syn keyword txl_keyword contained integerp intern interp-fun-p interpose +syn keyword txl_keyword contained ip ipf isqrt itimer-prov +syn keyword txl_keyword contained itimer-real itimer-virtual juxt keep-if +syn keyword txl_keyword contained keep-if* keywordp kill labels +syn keyword txl_keyword contained lambda last lazy-str lazy-str-force +syn keyword txl_keyword contained lazy-str-force-upto lazy-str-get-trailing-list lazy-stream-cons lazy-stringp +syn keyword txl_keyword contained lbind lcm lcons-fun lconsp +syn keyword txl_keyword contained ldiff length length-list length-str +syn keyword txl_keyword contained length-str-< length-str-<= length-str-> length-str->= +syn keyword txl_keyword contained length-vec lequal less let +syn keyword txl_keyword contained let* lexical-fun-p lexical-lisp1-binding lexical-var-p +syn keyword txl_keyword contained link lisp-parse list list* +syn keyword txl_keyword contained list-str list-vector listp log +syn keyword txl_keyword contained log-alert log-auth log-authpriv log-cons +syn keyword txl_keyword contained log-crit log-daemon log-debug log-emerg +syn keyword txl_keyword contained log-err log-info log-ndelay log-notice +syn keyword txl_keyword contained log-nowait log-odelay log-perror log-pid +syn keyword txl_keyword contained log-user log-warning log10 log2 +syn keyword txl_keyword contained logand logior lognot logtest +syn keyword txl_keyword contained logtrunc logxor macro-form-p macro-time +syn keyword txl_keyword contained macroexpand macroexpand-1 macrolet major +syn keyword txl_keyword contained make-catenated-stream make-env make-hash make-lazy-cons +syn keyword txl_keyword contained make-like make-package make-random-state make-similar-hash +syn keyword txl_keyword contained make-string-byte-input-stream make-string-input-stream make-string-output-stream make-strlist-output-stream +syn keyword txl_keyword contained make-sym make-time make-time-utc make-trie +syn keyword txl_keyword contained makedev mapcar mapcar* mapdo +syn keyword txl_keyword contained mapf maphash mappend mappend* +syn keyword txl_keyword contained mask match-fun match-regex match-regex-right +syn keyword txl_keyword contained match-regst match-regst-right match-str match-str-tree +syn keyword txl_keyword contained max member member-if memq +syn keyword txl_keyword contained memql memqual merge min +syn keyword txl_keyword contained minor minusp mkdir mknod +syn keyword txl_keyword contained mkstring mod multi multi-sort +syn keyword txl_keyword contained n-choose-k n-perm-k nconc nilf +syn keyword txl_keyword contained none not notf nreverse +syn keyword txl_keyword contained null nullify num-chr num-str +syn keyword txl_keyword contained numberp oand oddp op +syn keyword txl_keyword contained open-command open-directory open-file open-files +syn keyword txl_keyword contained open-files* open-pipe open-process open-tail +syn keyword txl_keyword contained openlog opip or orf +syn keyword txl_keyword contained packagep pad partition partition* +syn keyword txl_keyword contained partition-by perm plusp pop +syn keyword txl_keyword contained pos pos-if pos-max pos-min +syn keyword txl_keyword contained posq posql posqual pppred +syn keyword txl_keyword contained ppred pprinl pprint pprof +syn keyword txl_keyword contained pred prinl print prof +syn keyword txl_keyword contained prog1 progn prop proper-listp +syn keyword txl_keyword contained push pushhash put-byte put-char +syn keyword txl_keyword contained put-line put-lines put-string put-strings +syn keyword txl_keyword contained pwd qquote quasi quasilist +syn keyword txl_keyword contained quote rand random random-fixnum +syn keyword txl_keyword contained random-state-p range range* range-regex +syn keyword txl_keyword contained rcomb read readlink real-time-stream-p +syn keyword txl_keyword contained reduce-left reduce-right ref refset +syn keyword txl_keyword contained regex-compile regex-parse regexp regsub +syn keyword txl_keyword contained rehome-sym remhash remove-if remove-if* +syn keyword txl_keyword contained remove-path remq remq* remql +syn keyword txl_keyword contained remql* remqual remqual* rename-path +syn keyword txl_keyword contained repeat replace replace-list replace-str +syn keyword txl_keyword contained replace-vec rest ret retf +syn keyword txl_keyword contained return return-from reverse rlcp +syn keyword txl_keyword contained rperm rplaca rplacd run +syn keyword txl_keyword contained s-ifblk s-ifchr s-ifdir s-ififo +syn keyword txl_keyword contained s-iflnk s-ifmt s-ifreg s-ifsock +syn keyword txl_keyword contained s-irgrp s-iroth s-irusr s-irwxg +syn keyword txl_keyword contained s-irwxo s-irwxu s-isgid s-isuid +syn keyword txl_keyword contained s-isvtx s-iwgrp s-iwoth s-iwusr +syn keyword txl_keyword contained s-ixgrp s-ixoth s-ixusr search +syn keyword txl_keyword contained search-regex search-regst search-str search-str-tree +syn keyword txl_keyword contained second seek-stream select seqp +syn keyword txl_keyword contained set set-diff set-hash-userdata set-sig-handler +syn keyword txl_keyword contained sethash setitimer setlogmask sh +syn keyword txl_keyword contained sig-abrt sig-alrm sig-bus sig-check +syn keyword txl_keyword contained sig-chld sig-cont sig-fpe sig-hup +syn keyword txl_keyword contained sig-ill sig-int sig-io sig-iot +syn keyword txl_keyword contained sig-kill sig-lost sig-pipe sig-poll +syn keyword txl_keyword contained sig-prof sig-pwr sig-quit sig-segv +syn keyword txl_keyword contained sig-stkflt sig-stop sig-sys sig-term +syn keyword txl_keyword contained sig-trap sig-tstp sig-ttin sig-ttou +syn keyword txl_keyword contained sig-urg sig-usr1 sig-usr2 sig-vtalrm +syn keyword txl_keyword contained sig-winch sig-xcpu sig-xfsz sign-extend +syn keyword txl_keyword contained sin sixth size-vec some +syn keyword txl_keyword contained sort sort-group source-loc source-loc-str +syn keyword txl_keyword contained span-str splice split-str split-str-set +syn keyword txl_keyword contained sqrt sssucc ssucc stat +syn keyword txl_keyword contained stdlib str< str<= str= +syn keyword txl_keyword contained str> str>= stream-get-prop stream-set-prop +syn keyword txl_keyword contained streamp string-extend string-lt stringp +syn keyword txl_keyword contained sub sub-list sub-str sub-vec +syn keyword txl_keyword contained succ symacrolet symbol-function symbol-name +syn keyword txl_keyword contained symbol-package symbol-value symbolp symlink +syn keyword txl_keyword contained sys-qquote sys-splice sys-unquote syslog +syn keyword txl_keyword contained tan tb tc tf +syn keyword txl_keyword contained third throw throwf time +syn keyword txl_keyword contained time-fields-local time-fields-utc time-string-local time-string-utc +syn keyword txl_keyword contained time-usec tofloat toint tok-str +syn keyword txl_keyword contained tok-where tostring tostringp tprint +syn keyword txl_keyword contained transpose tree-bind tree-case tree-find +syn keyword txl_keyword contained trie-add trie-compress trie-lookup-begin trie-lookup-feed-char +syn keyword txl_keyword contained trie-value-at trim-str true trunc +syn keyword txl_keyword contained trunc-rem tuples txr-case txr-if +syn keyword txl_keyword contained txr-when typeof unget-byte unget-char +syn keyword txl_keyword contained uniq unique unless unquote +syn keyword txl_keyword contained until upcase-str update url-decode +syn keyword txl_keyword contained url-encode usleep uw-protect vec +syn keyword txl_keyword contained vec-push vec-set-length vecref vector +syn keyword txl_keyword contained vector-list vectorp w-continued w-coredump +syn keyword txl_keyword contained w-exitstatus w-ifcontinued w-ifexited w-ifsignaled +syn keyword txl_keyword contained w-ifstopped w-nohang w-stopsig w-termsig +syn keyword txl_keyword contained w-untraced wait weave when +syn keyword txl_keyword contained whenlet where while whilet +syn keyword txl_keyword contained width with-saved-vars wrap wrap* +syn keyword txl_keyword contained zap zerop zip syn match txr_metanum "@[0-9]\+" syn match txr_nested_error "[^\t `]\+" contained @@ -24684,6 +24684,138 @@ If the argument is omitted, it defaults to the same value as .codn sig-term . +.SS* Unix Processes + +.coNP Functions @ fork and @ wait +.synb +.mets (fork) +.mets (wait >> [ pid <> [ flags ]]) +.syne +.desc +The +.code fork +and +.code wait +functions are interfaces to the Unix functions +.code fork +and +.codn waitpid . + +The +.code fork +function creates a child process which is a replica of the parent. Both +processes return from the function. In the child process, the return value is +zero. In the parent, it is an integer representing the process ID of the child. +If the function fails to create a child, it returns +.code nil +rather than an integer. In this case, the +.code errno +function can be used to inquire about the cause. + +The +.code wait +function, if successful, returns a cons cell consisting of a pair of integers. +The +.code car +of the cons is the process ID of the process or group which was successfully +waited on, and the +.code cdr +is the status. If +.code wait +fails, it returns +.codn nil . +The +.code errno +function can be used to inquire about the cause. + +The +.meta process-id +argument, if not supplied, defaults to -1, which means that +.code wait +waits for any process, rather than a specific process. Certain other +values have special meaning, as documented in the POSIX standard +for the +.code waitpid +function. + +The +.meta flags +argument defaults to zero. If it is specified as nonzero, it should be +a bitwise combination (via the +.code logior +function) of the constants +.codn w-nohang , +.codn w-untraced +and +.codn w-continued . +If +.code w-nohang +is used, then +.code wait +returns a cons cell whose +.code car +specifies a process ID value of zero in the situation that at least +one of the processes designated by +.code process-id +exist and are children of the calling process, but have not changed state. +In this case, the status value in the +.code cdr +is unspecified. + +Status values may be inspected with the functions +.codn w-ifexited , +.codn w-exitstatus , +.codn w-ifsignaled , +.codn w-termsig , +.codn w-coredump , +.codn w-ifstopped , +.code w-stopsig +and +.codn w-ifcontinued . + +.coNP Functions @, w-ifexited @, w-exitstatus @, w-ifsignaled @, w-termsig @, w-coredump @ w-ifstopped and @ w-stopsig +.synb +.mets (w-ifexited << status ) +.mets (w-exitstatus << status ) +.mets (w-ifsignaled << status ) +.mets (w-termsig << status ) +.mets (w-coredump << status ) +.mets (w-ifstopped << status ) +.mets (w-stopsig << status ) +.mets (w-ifcontinued << status ) +.syne +.desc +These functions analyze process exit values produced by the +.code wait +function. + +They are closely based on the +POSIX macros +.codn WIFEXITED , +.code WEXITSTATUS , +and so on. + +The +.meta status +value is either an integer, or a cons cell. In this case, the cons +cell is expected to have an integer in its +.code cdr +which is used as the status. + +The +.codn w-ifexited , +.codn w-ifsignaled , +.codn w-coredump , +.code w-ifstopped +and +.code w-ifcontinued +functions have Lisp boolean return semantics, unlike their C language +counterparts: they return +.code t +or +.codn nil , +rather than zero or nonzero. The others return integer values. + .SS* Unix Itimers Itimers ("interval timers") can be used in combination with signal handling to execute asynchronous actions. Itimers deliver delayed, one-time signals, @@ -66,135 +66,138 @@ syn keyword txl_keyword contained find-max find-min find-package first syn keyword txl_keyword contained fixnump flatten flatten* flet syn keyword txl_keyword contained flip flo-int flo-str floatp syn keyword txl_keyword contained floor flush-stream for for* -syn keyword txl_keyword contained force format fourth fun -syn keyword txl_keyword contained func-get-env func-get-form func-set-env functionp -syn keyword txl_keyword contained gcd gen generate gensym -syn keyword txl_keyword contained gequal get-byte get-char get-error -syn keyword txl_keyword contained get-error-str get-hash-userdata get-line get-lines -syn keyword txl_keyword contained get-list-from-stream get-sig-handler get-string get-string-from-stream -syn keyword txl_keyword contained gethash getitimer getpid getppid -syn keyword txl_keyword contained giterate glob glob-altdirfunc glob-brace -syn keyword txl_keyword contained glob-err glob-mark glob-nocheck glob-noescape -syn keyword txl_keyword contained glob-nomagic glob-nosort glob-onlydir glob-period -syn keyword txl_keyword contained glob-tilde glob-tilde-check greater group-by -syn keyword txl_keyword contained gun hash hash-alist hash-construct -syn keyword txl_keyword contained hash-count hash-diff hash-eql hash-equal -syn keyword txl_keyword contained hash-isec hash-keys hash-pairs hash-uni -syn keyword txl_keyword contained hash-update hash-update-1 hash-values hashp -syn keyword txl_keyword contained html-decode html-encode iapply identity -syn keyword txl_keyword contained ido if iff iffi -syn keyword txl_keyword contained iflet ignerr in inc -syn keyword txl_keyword contained inhash int-flo int-str integerp -syn keyword txl_keyword contained intern interp-fun-p interpose ip -syn keyword txl_keyword contained ipf isqrt itimer-prov itimer-real -syn keyword txl_keyword contained itimer-virtual juxt keep-if keep-if* -syn keyword txl_keyword contained keywordp kill labels lambda -syn keyword txl_keyword contained last lazy-str lazy-str-force lazy-str-force-upto -syn keyword txl_keyword contained lazy-str-get-trailing-list lazy-stream-cons lazy-stringp lbind -syn keyword txl_keyword contained lcm lcons-fun lconsp ldiff -syn keyword txl_keyword contained length length-list length-str length-str-< -syn keyword txl_keyword contained length-str-<= length-str-> length-str->= length-vec -syn keyword txl_keyword contained lequal less let let* -syn keyword txl_keyword contained lexical-fun-p lexical-lisp1-binding lexical-var-p link -syn keyword txl_keyword contained lisp-parse list list* list-str -syn keyword txl_keyword contained list-vector listp log log-alert -syn keyword txl_keyword contained log-auth log-authpriv log-cons log-crit -syn keyword txl_keyword contained log-daemon log-debug log-emerg log-err -syn keyword txl_keyword contained log-info log-ndelay log-notice log-nowait -syn keyword txl_keyword contained log-odelay log-perror log-pid log-user -syn keyword txl_keyword contained log-warning log10 log2 logand -syn keyword txl_keyword contained logior lognot logtest logtrunc -syn keyword txl_keyword contained logxor macro-form-p macro-time macroexpand -syn keyword txl_keyword contained macroexpand-1 macrolet major make-catenated-stream -syn keyword txl_keyword contained make-env make-hash make-lazy-cons make-like -syn keyword txl_keyword contained make-package make-random-state make-similar-hash make-string-byte-input-stream -syn keyword txl_keyword contained make-string-input-stream make-string-output-stream make-strlist-output-stream make-sym -syn keyword txl_keyword contained make-time make-time-utc make-trie makedev -syn keyword txl_keyword contained mapcar mapcar* mapdo mapf -syn keyword txl_keyword contained maphash mappend mappend* mask -syn keyword txl_keyword contained match-fun match-regex match-regex-right match-regst -syn keyword txl_keyword contained match-regst-right match-str match-str-tree max -syn keyword txl_keyword contained member member-if memq memql -syn keyword txl_keyword contained memqual merge min minor -syn keyword txl_keyword contained minusp mkdir mknod mkstring -syn keyword txl_keyword contained mod multi multi-sort n-choose-k -syn keyword txl_keyword contained n-perm-k nconc nilf none -syn keyword txl_keyword contained not notf nreverse null -syn keyword txl_keyword contained nullify num-chr num-str numberp -syn keyword txl_keyword contained oand oddp op open-command -syn keyword txl_keyword contained open-directory open-file open-files open-files* -syn keyword txl_keyword contained open-pipe open-process open-tail openlog -syn keyword txl_keyword contained opip or orf packagep -syn keyword txl_keyword contained pad partition partition* partition-by -syn keyword txl_keyword contained perm plusp pop pos -syn keyword txl_keyword contained pos-if pos-max pos-min posq -syn keyword txl_keyword contained posql posqual pppred ppred -syn keyword txl_keyword contained pprinl pprint pprof pred -syn keyword txl_keyword contained prinl print prof prog1 -syn keyword txl_keyword contained progn prop proper-listp push -syn keyword txl_keyword contained pushhash put-byte put-char put-line -syn keyword txl_keyword contained put-lines put-string put-strings pwd -syn keyword txl_keyword contained qquote quasi quasilist quote -syn keyword txl_keyword contained rand random random-fixnum random-state-p -syn keyword txl_keyword contained range range* range-regex rcomb -syn keyword txl_keyword contained read readlink real-time-stream-p reduce-left -syn keyword txl_keyword contained reduce-right ref refset regex-compile -syn keyword txl_keyword contained regex-parse regexp regsub rehome-sym -syn keyword txl_keyword contained remhash remove-if remove-if* remove-path -syn keyword txl_keyword contained remq remq* remql remql* -syn keyword txl_keyword contained remqual remqual* rename-path repeat -syn keyword txl_keyword contained replace replace-list replace-str replace-vec -syn keyword txl_keyword contained rest ret retf return -syn keyword txl_keyword contained return-from reverse rlcp rperm -syn keyword txl_keyword contained rplaca rplacd run s-ifblk -syn keyword txl_keyword contained s-ifchr s-ifdir s-ififo s-iflnk -syn keyword txl_keyword contained s-ifmt s-ifreg s-ifsock s-irgrp -syn keyword txl_keyword contained s-iroth s-irusr s-irwxg s-irwxo -syn keyword txl_keyword contained s-irwxu s-isgid s-isuid s-isvtx -syn keyword txl_keyword contained s-iwgrp s-iwoth s-iwusr s-ixgrp -syn keyword txl_keyword contained s-ixoth s-ixusr search search-regex -syn keyword txl_keyword contained search-regst search-str search-str-tree second -syn keyword txl_keyword contained seek-stream select seqp set -syn keyword txl_keyword contained set-diff set-hash-userdata set-sig-handler sethash -syn keyword txl_keyword contained setitimer setlogmask sh sig-abrt -syn keyword txl_keyword contained sig-alrm sig-bus sig-check sig-chld -syn keyword txl_keyword contained sig-cont sig-fpe sig-hup sig-ill -syn keyword txl_keyword contained sig-int sig-io sig-iot sig-kill -syn keyword txl_keyword contained sig-lost sig-pipe sig-poll sig-prof -syn keyword txl_keyword contained sig-pwr sig-quit sig-segv sig-stkflt -syn keyword txl_keyword contained sig-stop sig-sys sig-term sig-trap -syn keyword txl_keyword contained sig-tstp sig-ttin sig-ttou sig-urg -syn keyword txl_keyword contained sig-usr1 sig-usr2 sig-vtalrm sig-winch -syn keyword txl_keyword contained sig-xcpu sig-xfsz sign-extend sin -syn keyword txl_keyword contained sixth size-vec some sort -syn keyword txl_keyword contained sort-group source-loc source-loc-str span-str -syn keyword txl_keyword contained splice split-str split-str-set sqrt -syn keyword txl_keyword contained sssucc ssucc stat stdlib -syn keyword txl_keyword contained str< str<= str= str> -syn keyword txl_keyword contained str>= stream-get-prop stream-set-prop streamp -syn keyword txl_keyword contained string-extend string-lt stringp sub -syn keyword txl_keyword contained sub-list sub-str sub-vec succ -syn keyword txl_keyword contained symacrolet symbol-function symbol-name symbol-package -syn keyword txl_keyword contained symbol-value symbolp symlink sys-qquote -syn keyword txl_keyword contained sys-splice sys-unquote syslog tan -syn keyword txl_keyword contained tb tc tf third -syn keyword txl_keyword contained throw throwf time time-fields-local -syn keyword txl_keyword contained time-fields-utc time-string-local time-string-utc time-usec -syn keyword txl_keyword contained tofloat toint tok-str tok-where -syn keyword txl_keyword contained tostring tostringp tprint transpose -syn keyword txl_keyword contained tree-bind tree-case tree-find trie-add -syn keyword txl_keyword contained trie-compress trie-lookup-begin trie-lookup-feed-char trie-value-at -syn keyword txl_keyword contained trim-str true trunc trunc-rem -syn keyword txl_keyword contained tuples txr-case txr-if txr-when -syn keyword txl_keyword contained typeof unget-byte unget-char uniq -syn keyword txl_keyword contained unique unless unquote until -syn keyword txl_keyword contained upcase-str update url-decode url-encode -syn keyword txl_keyword contained usleep uw-protect vec vec-push -syn keyword txl_keyword contained vec-set-length vecref vector vector-list -syn keyword txl_keyword contained vectorp weave when whenlet -syn keyword txl_keyword contained where while whilet width -syn keyword txl_keyword contained with-saved-vars wrap wrap* zap -syn keyword txl_keyword contained zerop zip +syn keyword txl_keyword contained force fork format fourth +syn keyword txl_keyword contained fun func-get-env func-get-form func-set-env +syn keyword txl_keyword contained functionp gcd gen generate +syn keyword txl_keyword contained gensym gequal get-byte get-char +syn keyword txl_keyword contained get-error get-error-str get-hash-userdata get-line +syn keyword txl_keyword contained get-lines get-list-from-stream get-sig-handler get-string +syn keyword txl_keyword contained get-string-from-stream gethash getitimer getpid +syn keyword txl_keyword contained getppid giterate glob glob-altdirfunc +syn keyword txl_keyword contained glob-brace glob-err glob-mark glob-nocheck +syn keyword txl_keyword contained glob-noescape glob-nomagic glob-nosort glob-onlydir +syn keyword txl_keyword contained glob-period glob-tilde glob-tilde-check greater +syn keyword txl_keyword contained group-by gun hash hash-alist +syn keyword txl_keyword contained hash-construct hash-count hash-diff hash-eql +syn keyword txl_keyword contained hash-equal hash-isec hash-keys hash-pairs +syn keyword txl_keyword contained hash-uni hash-update hash-update-1 hash-values +syn keyword txl_keyword contained hashp html-decode html-encode iapply +syn keyword txl_keyword contained identity ido if iff +syn keyword txl_keyword contained iffi iflet ignerr in +syn keyword txl_keyword contained inc inhash int-flo int-str +syn keyword txl_keyword contained integerp intern interp-fun-p interpose +syn keyword txl_keyword contained ip ipf isqrt itimer-prov +syn keyword txl_keyword contained itimer-real itimer-virtual juxt keep-if +syn keyword txl_keyword contained keep-if* keywordp kill labels +syn keyword txl_keyword contained lambda last lazy-str lazy-str-force +syn keyword txl_keyword contained lazy-str-force-upto lazy-str-get-trailing-list lazy-stream-cons lazy-stringp +syn keyword txl_keyword contained lbind lcm lcons-fun lconsp +syn keyword txl_keyword contained ldiff length length-list length-str +syn keyword txl_keyword contained length-str-< length-str-<= length-str-> length-str->= +syn keyword txl_keyword contained length-vec lequal less let +syn keyword txl_keyword contained let* lexical-fun-p lexical-lisp1-binding lexical-var-p +syn keyword txl_keyword contained link lisp-parse list list* +syn keyword txl_keyword contained list-str list-vector listp log +syn keyword txl_keyword contained log-alert log-auth log-authpriv log-cons +syn keyword txl_keyword contained log-crit log-daemon log-debug log-emerg +syn keyword txl_keyword contained log-err log-info log-ndelay log-notice +syn keyword txl_keyword contained log-nowait log-odelay log-perror log-pid +syn keyword txl_keyword contained log-user log-warning log10 log2 +syn keyword txl_keyword contained logand logior lognot logtest +syn keyword txl_keyword contained logtrunc logxor macro-form-p macro-time +syn keyword txl_keyword contained macroexpand macroexpand-1 macrolet major +syn keyword txl_keyword contained make-catenated-stream make-env make-hash make-lazy-cons +syn keyword txl_keyword contained make-like make-package make-random-state make-similar-hash +syn keyword txl_keyword contained make-string-byte-input-stream make-string-input-stream make-string-output-stream make-strlist-output-stream +syn keyword txl_keyword contained make-sym make-time make-time-utc make-trie +syn keyword txl_keyword contained makedev mapcar mapcar* mapdo +syn keyword txl_keyword contained mapf maphash mappend mappend* +syn keyword txl_keyword contained mask match-fun match-regex match-regex-right +syn keyword txl_keyword contained match-regst match-regst-right match-str match-str-tree +syn keyword txl_keyword contained max member member-if memq +syn keyword txl_keyword contained memql memqual merge min +syn keyword txl_keyword contained minor minusp mkdir mknod +syn keyword txl_keyword contained mkstring mod multi multi-sort +syn keyword txl_keyword contained n-choose-k n-perm-k nconc nilf +syn keyword txl_keyword contained none not notf nreverse +syn keyword txl_keyword contained null nullify num-chr num-str +syn keyword txl_keyword contained numberp oand oddp op +syn keyword txl_keyword contained open-command open-directory open-file open-files +syn keyword txl_keyword contained open-files* open-pipe open-process open-tail +syn keyword txl_keyword contained openlog opip or orf +syn keyword txl_keyword contained packagep pad partition partition* +syn keyword txl_keyword contained partition-by perm plusp pop +syn keyword txl_keyword contained pos pos-if pos-max pos-min +syn keyword txl_keyword contained posq posql posqual pppred +syn keyword txl_keyword contained ppred pprinl pprint pprof +syn keyword txl_keyword contained pred prinl print prof +syn keyword txl_keyword contained prog1 progn prop proper-listp +syn keyword txl_keyword contained push pushhash put-byte put-char +syn keyword txl_keyword contained put-line put-lines put-string put-strings +syn keyword txl_keyword contained pwd qquote quasi quasilist +syn keyword txl_keyword contained quote rand random random-fixnum +syn keyword txl_keyword contained random-state-p range range* range-regex +syn keyword txl_keyword contained rcomb read readlink real-time-stream-p +syn keyword txl_keyword contained reduce-left reduce-right ref refset +syn keyword txl_keyword contained regex-compile regex-parse regexp regsub +syn keyword txl_keyword contained rehome-sym remhash remove-if remove-if* +syn keyword txl_keyword contained remove-path remq remq* remql +syn keyword txl_keyword contained remql* remqual remqual* rename-path +syn keyword txl_keyword contained repeat replace replace-list replace-str +syn keyword txl_keyword contained replace-vec rest ret retf +syn keyword txl_keyword contained return return-from reverse rlcp +syn keyword txl_keyword contained rperm rplaca rplacd run +syn keyword txl_keyword contained s-ifblk s-ifchr s-ifdir s-ififo +syn keyword txl_keyword contained s-iflnk s-ifmt s-ifreg s-ifsock +syn keyword txl_keyword contained s-irgrp s-iroth s-irusr s-irwxg +syn keyword txl_keyword contained s-irwxo s-irwxu s-isgid s-isuid +syn keyword txl_keyword contained s-isvtx s-iwgrp s-iwoth s-iwusr +syn keyword txl_keyword contained s-ixgrp s-ixoth s-ixusr search +syn keyword txl_keyword contained search-regex search-regst search-str search-str-tree +syn keyword txl_keyword contained second seek-stream select seqp +syn keyword txl_keyword contained set set-diff set-hash-userdata set-sig-handler +syn keyword txl_keyword contained sethash setitimer setlogmask sh +syn keyword txl_keyword contained sig-abrt sig-alrm sig-bus sig-check +syn keyword txl_keyword contained sig-chld sig-cont sig-fpe sig-hup +syn keyword txl_keyword contained sig-ill sig-int sig-io sig-iot +syn keyword txl_keyword contained sig-kill sig-lost sig-pipe sig-poll +syn keyword txl_keyword contained sig-prof sig-pwr sig-quit sig-segv +syn keyword txl_keyword contained sig-stkflt sig-stop sig-sys sig-term +syn keyword txl_keyword contained sig-trap sig-tstp sig-ttin sig-ttou +syn keyword txl_keyword contained sig-urg sig-usr1 sig-usr2 sig-vtalrm +syn keyword txl_keyword contained sig-winch sig-xcpu sig-xfsz sign-extend +syn keyword txl_keyword contained sin sixth size-vec some +syn keyword txl_keyword contained sort sort-group source-loc source-loc-str +syn keyword txl_keyword contained span-str splice split-str split-str-set +syn keyword txl_keyword contained sqrt sssucc ssucc stat +syn keyword txl_keyword contained stdlib str< str<= str= +syn keyword txl_keyword contained str> str>= stream-get-prop stream-set-prop +syn keyword txl_keyword contained streamp string-extend string-lt stringp +syn keyword txl_keyword contained sub sub-list sub-str sub-vec +syn keyword txl_keyword contained succ symacrolet symbol-function symbol-name +syn keyword txl_keyword contained symbol-package symbol-value symbolp symlink +syn keyword txl_keyword contained sys-qquote sys-splice sys-unquote syslog +syn keyword txl_keyword contained tan tb tc tf +syn keyword txl_keyword contained third throw throwf time +syn keyword txl_keyword contained time-fields-local time-fields-utc time-string-local time-string-utc +syn keyword txl_keyword contained time-usec tofloat toint tok-str +syn keyword txl_keyword contained tok-where tostring tostringp tprint +syn keyword txl_keyword contained transpose tree-bind tree-case tree-find +syn keyword txl_keyword contained trie-add trie-compress trie-lookup-begin trie-lookup-feed-char +syn keyword txl_keyword contained trie-value-at trim-str true trunc +syn keyword txl_keyword contained trunc-rem tuples txr-case txr-if +syn keyword txl_keyword contained txr-when typeof unget-byte unget-char +syn keyword txl_keyword contained uniq unique unless unquote +syn keyword txl_keyword contained until upcase-str update url-decode +syn keyword txl_keyword contained url-encode usleep uw-protect vec +syn keyword txl_keyword contained vec-push vec-set-length vecref vector +syn keyword txl_keyword contained vector-list vectorp w-continued w-coredump +syn keyword txl_keyword contained w-exitstatus w-ifcontinued w-ifexited w-ifsignaled +syn keyword txl_keyword contained w-ifstopped w-nohang w-stopsig w-termsig +syn keyword txl_keyword contained w-untraced wait weave when +syn keyword txl_keyword contained whenlet where while whilet +syn keyword txl_keyword contained width with-saved-vars wrap wrap* +syn keyword txl_keyword contained zap zerop zip syn keyword txr_keyword contained accept all and assert syn keyword txr_keyword contained bind block cases cat |