Find the answer to your Linux question:
Results 1 to 3 of 3
hi, there exists a way to get the pid of a process which issued a signal? because I'm writing a little shell where there are several processes running in the ...
  1. #1
    Just Joined!
    Join Date
    May 2009
    Posts
    5

    how to get pid of a process which issued a signal

    hi, there exists a way to get the pid of a process which issued a signal?

    because I'm writing a little shell where there are several processes running in the background, so I need to know which process has issued a SIGCHLD

    regards

    frank

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    It won't tell you what the signal was that terminated it, but you can execute the wait command in a bash shell which will return the pid of a terminating child process. If you are running a C/C++ program, then the wait() function basically does the same thing.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    May 2009
    Posts
    5
    yes, I already knew it. The problem is that for my purpose this solution does not work, since I made the backgrounds processes as processes which are not waited from the parent, and so the wait() is done only for the foreground processes.
    Sadly now the parent never waits for the backgrounds ones, neither when they have finished. So I'm trying to implement a sigchld handler in order to allow the shell to wait also for those into bg, but I have no way to know which process has issued the sig, and so I can't know if the process signaled is a bg one, and so it has to perform wait() yet, or if it is a foreground one, so it should not wait again, since it has already waited. Otherwise I get two waits and it's not very useful

    There are no other ways?

    regards

Posting Permissions

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