Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-15-2004, 09:52 PM   #1
LQ Newbie
Registered: Aug 2003
Distribution: Ubuntu
Posts: 15

Rep: Reputation: 0
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?
Old 07-15-2004, 09:58 PM   #2
Senior Member
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Process and thread PIDs msriram_linux Programming 4 11-27-2004 12:43 PM
Parent PIDs Sinope Linux - Newbie 6 10-06-2004 12:46 AM
killing pids i_is_cat Linux - Newbie 6 05-01-2003 12:07 PM
Samba multiple pids The Jesus Linux - Software 1 12-11-2002 11:46 AM
Multiple PIDs ? Si|entKey Linux - General 0 03-28-2001 12:03 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:35 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration