-   Programming (
-   -   C++ and PIDs (

dbcoder 07-15-2004 09:52 PM

C++ and PIDs
I'm going to right a program (hopefully) for my friend who runs a NeverWinter Nights server that crashes every once and a while.

I was thinking I can have a program running that records the PID of the server when it runs, and if it's absent (it crashes) it starts it again.

I just need to know where to look for that sort of programming. I need to learn how to write code that interacts w/ the operating system.

Can anyone point out a site that would have tuts?

itsme86 07-15-2004 09:58 PM

It might be easier to just write a wrapper program:


  if(WEXITSTATUS(system("command_to_start_server")) <= 0)

system() won't return until the server exits (or crashes) and if the server is sane it will return 0 on a successful exit. If it crashes the return value should be greater than 0.

Then you can just run this wrapper program to start the server and it should constantly restart it as long as it crashes and doesn't exit normally.

All times are GMT -5. The time now is 07:31 PM.