lab5 Pipe Signals
  • Introduction
  • Signals
    • kill() system call
    • Custom signal handler
  • Knowing about pipe
    • Pipe Overview
    • System call pipe()
  • Learn to use pipe
    • Pipe Creation
    • Pipe with fork
    • Exercise 1
  • Connecting two programs with pipe
    • Implement ls | less in C
  • Shell Examples
    • Get Current Path
    • Change Directory
    • Change Environment Variables
  • Reference
Powered by GitBook
On this page

Was this helpful?

  1. Signals

kill() system call

Don't think that kill() is to terminate a process only. It can send all kinds of signals.

#include <sys/types.h>
#include <signal.h>
int kill(pid_t pid, int sig);

The following code demonstrates the use of kill(). Check the manual to see what SIGSEGV is?

/* Signals/kill.c */
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <signal.h>
#include <unistd.h>


int main(int argc,char *argv[])
{
    printf("My PID: %d\n",getpid());
    sleep(5);
    kill(getpid(),SIGSEGV);
    return 0;
}
PreviousSignalsNextCustom signal handler

Last updated 5 months ago

Was this helpful?