This is an archive of the discontinued LLVM Phabricator instance.

Add pretty-printer for wait(2) statuses and modernize the code handling them
ClosedPublic

Authored by labath on Jun 7 2017, 9:36 AM.

Details

Summary

A number of places were trying to decode the result of wait(). Add a simple
utility function that does that and a struct that encapsulates the
decoded result. Then also provide a pretty-printer for that class.

Diff Detail

Repository
rL LLVM

Event Timeline

labath created this revision.Jun 7 2017, 9:36 AM
labath updated this revision to Diff 101759.Jun 7 2017, 9:44 AM

Fix typo

krytarowski added inline comments.Jun 7 2017, 10:30 AM
source/Host/common/Host.cpp
1001 ↗(On Diff #101758)

WIFCONTINUED()?

labath added inline comments.Jun 7 2017, 11:18 AM
source/Host/common/Host.cpp
1001 ↗(On Diff #101758)

I'm deliberately ignoring that, as we don't have a use for it yet. On linux you have to pass the a special flag to waitpid to receive those notifications, and we don't do that. Does it work the same way on netbsd? If it possible to get those during normal interaction (without WCONTINUED), then I need to add it (and probably netbsd code needs to handle it), but otherwise I propose to skip it for the time being.

krytarowski added inline comments.Jun 7 2017, 11:34 AM
source/Host/common/Host.cpp
1001 ↗(On Diff #101758)

I see, we need WCONTINUED too. We can skip it now.

krytarowski edited edge metadata.Jun 8 2017, 4:53 AM

NetBSD part looks fine.

eugene added inline comments.Jun 8 2017, 1:40 PM
source/Host/common/Host.cpp
1010 ↗(On Diff #101759)

type[WS.type] seems to be a somewhat unnecessary hack. I would use a simple switch here.

1017 ↗(On Diff #101759)

Same as above.

labath marked 2 inline comments as done.Jun 13 2017, 3:44 AM
labath added inline comments.
source/Host/common/Host.cpp
1010 ↗(On Diff #101759)

I wouldn't call it a hack. :) More like data-oriented programming... :P
I wrote it like this because fully
clang-formatted
switches
tend
to
be
loooooong
.

But I don't care about it too much.

labath updated this revision to Diff 102309.Jun 13 2017, 3:45 AM
labath marked an inline comment as done.

Use a switch instead of indexing the array with an enum value

eugene accepted this revision.Jun 15 2017, 1:10 PM
This revision is now accepted and ready to land.Jun 15 2017, 1:10 PM
This revision was automatically updated to reflect the committed changes.