Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Monitoring a process

Monitoring a process

Scheduled Pinned Locked Moved C / C++ / MFC
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SiddharthAtw
    wrote on last edited by
    #1

    There is a critical service in my machine which crashes once in a month. I want to write an application which monitors that process and if that crashes sends email, or SMS or if possible restarts the service. I am trying with Enumerating Process . But that doesn't seem to be the solution. thanx in advance

    R 1 Reply Last reply
    0
    • S SiddharthAtw

      There is a critical service in my machine which crashes once in a month. I want to write an application which monitors that process and if that crashes sends email, or SMS or if possible restarts the service. I am trying with Enumerating Process . But that doesn't seem to be the solution. thanx in advance

      R Offline
      R Offline
      rwestgraham
      wrote on last edited by
      #2

      Create a watchdog app. Find the handle to the process you need to monitor. Then go into a WaitForSingleObject state. Set a time limit and let the watchdog app time out and process messages occasionally in case you want to shut it down manually. WaitForSingleObject returns a code that indicates the condition under which the function exits. If it timed out, the process is still running, so you clear the message queue and go back into WaitForSingleObject. If WaitForSingleObject exits because the process ended you send the e-mail, do whatever. Robert

      B 1 Reply Last reply
      0
      • R rwestgraham

        Create a watchdog app. Find the handle to the process you need to monitor. Then go into a WaitForSingleObject state. Set a time limit and let the watchdog app time out and process messages occasionally in case you want to shut it down manually. WaitForSingleObject returns a code that indicates the condition under which the function exits. If it timed out, the process is still running, so you clear the message queue and go back into WaitForSingleObject. If WaitForSingleObject exits because the process ended you send the e-mail, do whatever. Robert

        B Offline
        B Offline
        Blake Miller
        wrote on last edited by
        #3

        Assuming the 'crash' means that the process being monitored has termianted. This will not detect if it has locked up or not - it is still 'running' but uselessly deadlocked or stuck in a loop. If the monitored process is running as a service, you can periodically query the service control manager to get the service status, too.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups