Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wrote a small init script for proftpd (latest stable version, compiled myself) and am noticing that the executable exits with status 0 even if server fails to start (in my case, for example, due to SSH port conflict).

  1. Shouldn’t it exit with > 0? Or,
  2. How can a script detect whether startup was successful short of sleeping for arbitrary time and checking for PID?
# ./proftpd
# echo $? //returns 0

…but in /var/log/messages:

Jan 27 12:20:15 staging3 proftpd[9103]: - Failed binding to 0.0.0.0, port 22: Address already in use Jan 27 12:20:15 staging3 proftpd[9103]: - Check the ServerType directive to ensure you are configured correctly.

Thanks -nikita

share|improve this question

As you suggest, if you can't rely one the return code, you have to check the PID (or to check if the port 22 is in use, or whatever other trick).

./proftpd &
echo 'the PID is ' $!
share|improve this answer
    
specific to ProFTPD, is it OK to check for pid as soon as ./proftp call returns, or do I have to sleep for an arbitrary amt of time? in other words, if proftpd is started successfully, is PID guaranteed to exist by the time proftpd exits? – Nikita Jan 27 '12 at 21:50

This issue was filed and addressed in ProFTPD; see Bug#3752.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.