This preview shows page 1. Sign up to view the full content.
Unformatted text preview: he process group ID of the current process.
#include <unistd.h> pid t getpgrp(void);
returns: process group ID of calling process By default, a child process belongs to the same process group as its parent. A process can change the process group of itself or another process by using the setpgid function: 424
#include <unistd.h> pid t setpgid(pid t pid, pid t pgid); CHAPTER 8. EXCEPTIONAL CONTROL FLOW returns: 0 on success, -1 on error. The setpgid function changes the process group of process pid to pgid. If pid is zero, the PID of the current process is used. If pgid is zero, the PID of the process speciﬁed by pid is used for the process group ID. For example, if process 15213 is the calling process, then
setpgid(0, 0); creates a new process group whose process group ID is 15213, and adds process 15213 to this new group. Sending Signals With the kill Program
The /bin/kill program sends an arbitrary signal to another process. For example
unix> kill -9 15213 sends signal 9 (SIGKILL) to process 15213. A negative PID causes the sig...
View Full Document
- Spring '10
- The American