Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
WAIT(3)			   Library Functions Manual		       WAIT(3)

NAME
       await, awaitnohang, awaitfor, wait, waitnohang, waitfor,	waitpid	- wait
       for a process to	exit

SYNOPSIS
       #include	<u.h>
       #include	<libc.h>

       Waitmsg*	 wait(void)

       Waitmsg*	 waitnohang(void)

       Waitmsg*	 waitfor(int pid)

       int	 waitpid(void)

       int	 await(char *s,	int n)

       int	 awaitnohang(char *s, int n)

       int	 awaitfor(int pid, char	*s, int	n)

DESCRIPTION
       Wait causes a process to	wait for any child process (see	and  to	 exit.
       It  returns  a  Waitmsg	holding	information about the exited child.  A
       Waitmsg has this	structure:

	      typedef
	      struct Waitmsg
	      {
		    int	pid;		  /* of	loved one */
		    ulong time[3];	  /* of	loved one & descendants	*/
		    char *msg;
	      }	Waitmsg;

       Pid is the child's process id.  The time	array contains	the  time  the
       child  and its descendants spent	in user	code, the time spent in	system
       calls, and the child's elapsed real time, all in	units of milliseconds.
       Msg contains the	message	that the child specified in For	a normal exit,
       msg[0] is zero, otherwise msg  is  the  exit  string  prefixed  by  the
       process name, a blank, the process id, and a colon.

       If  there  are  no more children	to wait	for, wait returns immediately,
       with return value nil.

       The Waitmsg structure is	allocated by and should	be  freed  after  use.
       For programs that only need the pid of the exiting program, waitpid re-
       turns just the pid and discards the rest	of the information.

       Waitnohang is like wait but does	not block if there are no  more	 chil-
       dren to wait for.  Instead it returns immediately and sets errstr.

       Waitfor is like wait but	waits for a particular pid.

       The  underlying	calls are await, awaitnohang, and awaitfor, which fill
       in the n-byte buffer s with a textual representation of the pid,	times,
       and  exit  string.   There is no	terminal NUL.  The return value	is the
       length, in bytes, of the	data.

       The filled-in buffer may	be parsed (after appending a NUL)  using  tok-
       enize  (see  the	 resulting fields are, in order, pid, the three	times,
       and the exit string, which will be '' for normal	exit.  If  the	repre-
       sentation  is  longer  than  n bytes, it	is truncated but, if possible,
       properly	formatted.  The	information that does not fit in the buffer is
       discarded,  so  a  subsequent call to await will	return the information
       about the next exiting child, not the remainder of the  truncated  mes-
       sage.  In other words, each call	to await returns the information about
       one child, blocking if necessary	if no child has	exited.	 If the	 call-
       ing process has no living children, await returns -1.

SOURCE
       /src/lib9/wait.c

       /src/lib9/await.c

SEE ALSO
DIAGNOSTICS
       These routines set errstr.

BUGS
       To  avoid name conflicts	with the underlying system, wait, waitpid, and
       waitfor are preprocessor	 macros	 defined  as  p9wait,  p9waitpid,  and
       p9waitfor; see

								       WAIT(3)

NAME | SYNOPSIS | DESCRIPTION | SOURCE | SEE ALSO | DIAGNOSTICS | BUGS

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=wait&sektion=3&manpath=FreeBSD+13.0-RELEASE+and+Ports>

home | help