0

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

Castaglia
  • 3,349
  • 3
  • 21
  • 42
Nikita
  • 125
  • 1
  • 4

2 Answers2

0

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 ' $!
Gregory MOUSSAT
  • 1,673
  • 2
  • 25
  • 50
  • 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
0

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

Castaglia
  • 3,349
  • 3
  • 21
  • 42