Describe these system calls of linux C language Describe the
Describe these system calls of linux (C language):
Describe the functionality of each of the following system calls: kill(456, 0); wapitis(-1, &status;, 0); raise(SIGUSR1);Solution
a. kill(pid_t processId, int signal) system call is used to pass signal to any process in linux system. First parameter processId identifies a process in linux. Second parameter signal specifies the signal to be sent to the process.
If the second parameter is 0, system call will not send any signal, but will check whether the process with processId exist or not.
kill(456,0) checks whether the process with processId 456 exist or not.
b. Syntax of waitpid function is pid_t waitpid(pid_t pid, int *status, int options).
waitpid(-1, &status, 0) function call will suspend the execution of calling process until any child process changes state.
Parameter pid = -1 specifies that wait for any child process
Parameter options = 0 is the default value which signifies no changes in the default behaviour.
c. Syntax of raise function is int raise(int signal)
Raise function raises the signal specified by the parameter signal.
raise(SIGUSR1) raises the signal SIGUSR1. SIGUSR1 is an user defined signal which should have been defined earlier. If the signal handler for SIGUSR1 is not defined, signal would be handled by default signal handler.
