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

simplify run() to use daemon(3) #1596

Closed
wants to merge 5 commits into from
Closed

Conversation

epsilon-0
Copy link
Contributor

current method is a 'hack' and using daemon(3)
reduces code burden by reusing standard libraries.

Signed-off-by: Aisha Tammy aisha@bsd.ac

Copy link
Member

@ammen99 ammen99 left a comment

Choose a reason for hiding this comment

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

Also the formatting is off, see the CI logs for a patch you can apply to fix the code style.


/* The following is a "hack" for disowning the child processes,
Copy link
Member

Choose a reason for hiding this comment

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

I think the comment should stay. We still do a double fork (even though daemonize does it for us), and I think that the purpose of this may not be clear to all readers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

readded

pid_t child_pid;
read(pipe_fd[READ_END], &child_pid, sizeof(child_pid));
#endif
execl("/bin/sh", "/bin/sh", "-c", command.c_str(), NULL);
Copy link
Member

Choose a reason for hiding this comment

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

I see you have removed the _exit() call. Wouldn't that cause issues if execl fails?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I still do have the _exit but it's moved above to line 787.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah but the exit should happen after a failed exec

@ammen99
Copy link
Member

ammen99 commented Sep 23, 2023

Ping?

current method is a 'hack' and using daemon(3)
reduces code burden by reusing standard libraries.

Signed-off-by: Aisha Tammy <aisha@bsd.ac>
Signed-off-by: Aisha Tammy <aisha@bsd.ac>
Signed-off-by: Aisha Tammy <aisha@bsd.ac>
@@ -274,7 +274,7 @@ class compositor_core_t : public wf::object_base_t, public signal::provider_t
* This also sets some environment variables for the new process, including
* correct WAYLAND_DISPLAY and DISPLAY.
*
* @return The PID of the started client, or -1 on failure.
* @return The PID of the started client, or 0 on failure.
Copy link
Member

Choose a reason for hiding this comment

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

Can we avoid breaking changes like this? I think we can easily continue returning -1 on failure.

@ammen99
Copy link
Member

ammen99 commented Jun 11, 2024

Thanks for the PR but I have decided not to accept it. I think this PR makes much more than the title suggests - simply using daemon instead of fork might be a good idea, using anything more complicated than pipes is not.

@ammen99 ammen99 closed this Jun 11, 2024
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

Successfully merging this pull request may close these issues.

None yet

2 participants