Bug 494 - nsd does not exit with non-zero status when fails to start
nsd does not exit with non-zero status when fails to start
Status: CLOSED FIXED
Product: NSD
Classification: Unclassified
Component: NSD Code
3.2.x
i386 Linux
: P5 major
Assigned To: NSD team
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-03-27 09:20 CET by Stephen Fung
Modified: 2018-08-21 16:43 CEST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephen Fung 2013-03-27 09:20:00 CET
I am testing nsd 3.2.14.

I just tested that when nsd fails to start because the port to listen is in used, exit code is zero(non-zero is expected). This happens when nsd is being started as daemon. Exit code is one when starts in debug mode.
Comment 1 Matthijs Mekking 2013-03-27 10:05:16 CET
Hi Stephen,

It works for me:

$ nsd -d; echo $?
1

$ tail -n 2 /etc/nsd/cache/nsd.log 
[1364374929] nsd[31540]: error: can't bind udp socket: Address already in use
[1364374929] nsd[31540]: error: server initialization failed, nsd could not be started

What is it that I do different?
Comment 2 Stephen Fung 2013-03-27 10:07:46 CET
(In reply to comment #1)
> Hi Stephen,
> 
> It works for me:
> 
> $ nsd -d; echo $?
> 1
> 
> $ tail -n 2 /etc/nsd/cache/nsd.log 
> [1364374929] nsd[31540]: error: can't bind udp socket: Address already in use
> [1364374929] nsd[31540]: error: server initialization failed, nsd could not be
> started
> 
> What is it that I do different?

without -d, it exits with 0.
Comment 3 Matthijs Mekking 2013-03-27 10:54:18 CET
Ah, I have interpreted that last line incorrectly (I thought the issue was with debug mode).

Without -d, exit code is indeed zero. NSD has successfully been forked off. Port binding happens after that. Not sure what we can do otherwise if that part fails.
Comment 4 Matthijs Mekking 2013-04-08 09:58:52 CEST
Hi,

The server initialization code has been moved before the fork (in branches/NSD_3_2). This should fix your issue.