#ifndef _SYS_WAIT_H
#define _SYS_WAIT_H

#include <sys/types.h>

#define _LOW(v) ( (v) & 0377)	// ȡֽڣ8 Ʊʾ
#define _HIGH(v) ( ((v) >> 8) & 0377)	// ȡֽڡ

/* options for waitpid, WUNTRACED not supported */
/* waitpid ѡWUNTRACED δ֧ */
#define WNOHANG 1		// û״̬ҲҪ𣬲̷ء
#define WUNTRACED 2		// ִֹͣеӽ״̬

#define WIFEXITED(s) (!((s)&0xFF)	// ӽ˳Ϊ档
#define WIFSTOPPED(s) (((s)&0xFF)==0x7F)	// ӽֹͣţΪtrue
#define WEXITSTATUS(s) (((s)>>8)&0xFF)	// ˳״̬
#define WTERMSIG(s) ((s)&0x7F)	// ص½ֹźֵź
#define WSTOPSIG(s) (((s)>>8)&0xFF)	// ص½ֹͣźֵ
#define WIFSIGNALED(s) (((unsigned int)(s)-1 & 0xFFFF) < 0xFF)	// δ׽ź
// ӽ˳Ϊ档

// wait()waitpit()̻ȡӽ֮һ״̬ϢѡȡѾֹ
// ֹͣӽ״̬Ϣӽ̵״̬Ϣ򱨸˳ǲָġ
// wait()ǰֱ̣ӽ֮һ˳ֹյҪֹý̵źţ
// ҪһźžźŴ򣩡
// waitpid()ǰֱ̣pid ָӽ˳ֹյҪֹý̵źţ
// ҪһźžźŴ򣩡
// pid= -1options=0waitpid()wait()һΪpid options
// Ĳͬͬμkernel/exit.c,142
pid_t wait (int *stat_loc);
pid_t waitpid (pid_t pid, int *stat_loc, int options);

#endif
