Thread: Building a watchdog

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    101

    Question Building a watchdog

    I need to do a watchdog for a process. That process (let's call it p2) is also coded by me.

    However, since this is a assignment for school, I'm supposed to figure a way to see if p2 is still alive without p2 doing anything at all.

    The way i'm thinking this means no semaphores and no pipes.

    Anyone has any idea of what mechanism can be used? I've been thinking about this for days but can't come up with anything.

    Thanks in advance.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    This seems operating system-specific. Weren't you just asking about how to find whether processes are active? Why wouldn't that work here too?

  3. #3
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    I agree with tabstop since this question seems OS specific.
    Do you know if the watchdog runs in user or supervisor mode?

  4. #4
    Registered User
    Join Date
    Apr 2008
    Posts
    101
    I was about to reply on that thread but then i thought it would be off topic because the solution might be something else entirely but if you think it's more appropriate I can move back there.

  5. #5
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Well it belongs to an OS board, for sure; and since it would appear to be the exact same question then there's no problem with that thread.

  6. #6
    Registered User
    Join Date
    Apr 2008
    Posts
    101
    Ok my bad, I'll reply there then.

  7. #7
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    One possibility is to have the watched process write its pid to a file in a known location and file name. The watchdog could periodically open the file, read the pid, and check that the process with that pid is still running.

  8. #8
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by rags_to_riches View Post
    One possibility is to have the watched process write its pid to a file in a known location and file name. The watchdog could periodically open the file, read the pid, and check that the process with that pid is still running.
    I would guess that doesn't fit "without p2 doing anything at all", though.

  9. #9
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Doh! Reading fail.

  10. #10
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    The answer comes right down to the definition of "p2 is still alive".
    Pin down that definition and you should have your answer.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  11. #11
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by iMalc View Post
    The answer comes right down to the definition of "p2 is still alive".
    Pin down that definition and you should have your answer.
    I was discussing exactly that point in the other thread on the subject.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 0
    Last Post: 06-08-2009, 05:33 PM
  2. Undertaking Website Building Project and Application Software Development
    By Programmer168 in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 03-21-2009, 04:44 AM
  3. How to solve warnings that appear when building my DLL...
    By starcatcher in forum Windows Programming
    Replies: 6
    Last Post: 12-14-2008, 11:47 AM
  4. GUI building, is RAD the way to go?
    By indigo0086 in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 09-21-2007, 09:36 PM
  5. Warning when building!
    By electrolove in forum C Programming
    Replies: 21
    Last Post: 02-12-2003, 09:39 PM

Tags for this Thread