Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

naemon doesn't properly close stdout/stderr/stdin #401

Closed
datamuc opened this issue Nov 18, 2022 · 2 comments
Closed

naemon doesn't properly close stdout/stderr/stdin #401

datamuc opened this issue Nov 18, 2022 · 2 comments

Comments

@datamuc
Copy link

datamuc commented Nov 18, 2022

Hi,

i think the faulty commit is fa9c19d.

there are some close(0) .. close(2) lines, they where moved from daemon_init to main. daemon_init is called before init_worker but now the fds are closed after init_worker, so they are only closed in the main process and not in the workers. That leads to the following problem:

code like this does not return:

output=$( ./src/naemon/naemon  -du sample-config/naemon.cfg )

in reality i'm doing output=$( omd restart ) and that doesn't work anymore.

Before this commit it works as expected.

So I think in init_worker you also need to close the fds?

@datamuc
Copy link
Author

datamuc commented Nov 18, 2022

Before the commit:

$ ./src/naemon/naemon  -du sample-config/naemon.cfg > testdir/output 2>&1
$ fuser testdir/output 
$ 

After this commit:

$ ./src/naemon/naemon  -du sample-config/naemon.cfg > testdir/output 2>&1
$ fuser testdir/output 
/home/danielt/vc/git/naemon-core/testdir/output:  7843  7844  7845  7846  7847  7848  7849  7850  7851
$ ps -fp 7843 
UID        PID  PPID  C STIME TTY          TIME CMD
danielt   7843  7842  0 09:06 ?        00:00:00 /home/danielt/vc/git/naemon-core/src/naemon/.libs/naemon --worker /home/danielt/tmp/naemon/var/naemon.qh
# the others are also workers

sni added a commit to sni/naemon-core that referenced this issue Nov 18, 2022
@sni sni closed this as completed in 8a0fbc7 Nov 22, 2022
@sni
Copy link
Contributor

sni commented Nov 22, 2022

should be fine now, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants