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

Posix wait #513

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Posix wait #513

wants to merge 2 commits into from

Conversation

ikbenlike
Copy link
Contributor

This PR aims to implement the pid = 0 and pid <= -1 cases in Process::wait. It also adds checks in init-stage2 to ensure that processes launched with execl actually get executed.

@@ -31,8 +31,7 @@ int main() {
std::cout << "init: Starting udevd" << std::endl;
auto udev = fork();
if(!udev) {
// execl("/usr/sbin/udevd", "udevd", nullptr);
execl("/usr/sbin/udevd", "udevd", "--debug", nullptr);
assert(-1 != execl("/usr/sbin/udevd", "udevd", "--debug", nullptr));
Copy link
Member

Choose a reason for hiding this comment

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

Building with NDEBUG should not remove udev.

This definitely classifies as assert abuse.

Instead, we can write a wrapper macro that calls error()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I'll write a wrapper that calls error() and then terminates by either calling exit() or abort() (whichever is deemed more appropriate).

Copy link
Member

Choose a reason for hiding this comment

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

error(3) terminates after printing the error if passed a nonzero value as the exit code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has been implemented; however due to the absense of error() in mlibc this is stuck on mlibc#793

else if(pid == 0 && groupid != it->gid()){
continue;
}
else if(pid < -1 && groupid != it->gid()){
Copy link
Member

Choose a reason for hiding this comment

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

Why are these cases distinct?

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 did it like this because I was just going down the list of cases in the man-page; they do mean different things but because they all just continue; it could also be one singular if-statement if so desired

resp.set_error(managarm::posix::Errors::WAIT_INTERRUPTED);
}
else {

Copy link
Member

Choose a reason for hiding this comment

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

We really need a better way to map managarm errors to posix (not something for you to address, just saying)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, doing it this way feels clunky and the amount of code overhead isn't really optimal. I was thinking about just returning a POSIX error from Process::wait, but that didn't seem appropriate either

Copy link
Member

@qookei qookei left a comment

Choose a reason for hiding this comment

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

Indentation is wrong in some places (4 spaces instead of a tab). Also else goes on the same line as the closing } of the if body (as in: } else {)

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

3 participants