tailieunhanh - Embedded FreeBSD Cookbook phần 2

ghi âm, hay nói cách khác, mà không cần sự cho phép trước bằng văn bản của nhà xuất bản. Nhận thức được tầm quan trọng của việc bảo tồn những gì đã được viết, Elsevier Science in sách trên giấy acid miễn phí bất cứ khi nào có thể. Thư viện của Quốc hội mục-trong-Xuất bản dữ liệu ISBN: 1-5899-5004-6 Anh Thư viện Biên mục-trong-Xuất bản dữ liệu ghi lại cửa hàng cho cuốn sách này có sẵn từ Thư viện Anh. . | 11 Chapter Two Systems Programming include sys include pid t fork void Fork is unique in that the single call to fork returns twice. Fork returns the process identifier PID of the child to the parent process and it returns 0 to the newly created child process. When a process is created the following list of attributes is inherited from the parent file descriptors process group ID access groups working directory root directory control terminal resources interval timers resource limits file mode mask and signal mask. The execve System Call Many times a process is created to run another program. The execve system call is used this way and is invoked immediately following a fork system. An execve system call will replace the currently executing program with a new program. include int execve const char path char const argv char const envp The execve system call takes three parameters path is the path and filename of the new program to execute argv contains a pointer to the argument string to pass to the program envp contains a list of environment variables. The execve system call returns -1 on error. The execve system call has numerous wrappers in the Standard C Library known as the exec family of functions. Process Termination A process can terminate intentionally by calling exit or unintentionally by receiving a signal from another process. Regardless of the reason when a process terminates a notification is returned to the parent. If the parent process does not receive the notification the child process becomes a zombie. The child will remain a zombie until the parent retrieves the child s exit status. 12 Embedded FreeBSD Cookbook The _exit System Call A process will terminate when the program invokes the _exit system call. The _exit system call will cause the SIGCHLD signal to be thrown to the parent process. include void _exit int status The _exit system call will never return. The _exit system call is more commonly called by the

TỪ KHÓA LIÊN QUAN