8000 Add daemon option to avoid making BaseDir by nwf · Pull Request #2422 · collectd/collectd · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add daemon option to avoid making BaseDir #2422

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

Merged
merged 1 commit into from
Sep 21, 2017
Merged

Add daemon option to avoid making BaseDir #2422

merged 1 commit into from
Sep 21, 2017

Conversation

nwf
Copy link
Contributor
@nwf nwf commented Sep 6, 2017

One possible implementation of #2421

Copy link
Member
@octo octo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @nwf,

thank you very much for opening this PR! I think the feature is sane, I'd just like the boolean to be inverted for easier reading of the source; details inline.

Thanks and best regards,
—octo

P.S.: I'd even be open to make erroring out the default and make -B enable the mkdir behavior. @rubenk, any thoughts?

@@ -158,7 +158,7 @@ static int init_global_variables(void) {
return 0;
} /* int init_global_variables */

static int change_basedir(const char *orig_dir) {
static int change_basedir(const char *orig_dir, int nocreate) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a positive logic here, "not nocreate" is a double negation and hard to read and I'd much prefer a create boolean.

Also, please use _Bool instead of int.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both done.

sstrerror(errno, errbuf, sizeof(errbuf)));
free(dir);
return -1;
if (nocreate == 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tries the chdir() call a second time, which is not elegant. How about we extend the above logic to:

else if (!create || (errno != ENOENT)) {
  //     ^^^^^^^^^^
  /* report error, return */
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's better, I agree.

One possible implementation of #2421
8000
@octo octo merged commit 71d8519 into collectd:master Sep 21, 2017
@octo
Copy link
Member
octo commented Sep 21, 2017

Thanks @nwf!

octo added a commit that referenced this pull request Sep 21, 2017
Also add a manual page entry.

Issue: #2421
Pull-Request: #2422
@octo octo added this to the 5.8 milestone Oct 11, 2017
@maryamtahhan maryamtahhan mentioned this pull request Oct 12, 2017
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0