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

parent and child processes race each other #1

Open
jduck opened this issue Sep 14, 2015 · 3 comments
Open

parent and child processes race each other #1

jduck opened this issue Sep 14, 2015 · 3 comments

Comments

@jduck
Copy link
Contributor

jduck commented Sep 14, 2015

When synchronizing the parent and child processes using the pipe, the child might read the parent's status data before the parent is able to. I added a "sleep(1);" between the child's calls to "send_status_to_parent" and "wait_to_close" and that corrected it. The more correct solution would be to use a different mechanism for synchronization (perhaps a shared file mapping, with one entry per child denoting a state value).

@fi01
Copy link
Owner

fi01 commented Sep 15, 2015

I've updated to use non-blocking read to avoid race condition. Please check it.
Thanks.

@hubert3 hubert3 mentioned this issue Sep 15, 2015
@jduck
Copy link
Contributor Author

jduck commented Sep 17, 2015

Okay but now you are never closing the icmp sockets of the child (since wait_to_close never returns). Is that intended??

@jduck
Copy link
Contributor Author

jduck commented Sep 17, 2015

OH I see. The sockets get closed anyway when you kill the child process from the parent. In that case, all of the code after wait_for_close() is dead code and should be removed.

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