Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, please see the attachment for the program. sig_prg.JPG When i execute kill -2 <pid of sig> from the shell of another terminal the below message is printed "signal caught ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2011
    Posts
    21

    Behaviour of the signal in linux


    Hi,
    please see the attachment for the program.sig_prg.JPG

    When i execute kill -2 <pid of sig> from the shell of another terminal the below message is printed
    "signal caught with signum (%2): from process < pid of shell>"

    When i press CTRL + C on the terminal where the sig is running the below message is printed
    signal caught with signum (%2): from process 0

    I read that signal are sent by the currently running process.

    So in the second case was the swapper running at the time when we pressed CTRL + C OR
    The signals are always handled by the swapper when we press CTRL + C on the same terminal where the program is running.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,517
    The CTRL+C key press is caught by the kernel, which then signals the process. In such a case, it would be PID 0 (kernel). In the case where you send the signal from another process, the signal is handled by the kernel differently, and the pid of the requesting / sending task is inserted by the kernel into the info data.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •