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

Authored by labath on Wed, Jun 7, 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
labath created this revision.Wed, Jun 7, 9:36 AM
labath updated this revision to Diff 101759.Wed, Jun 7, 9:44 AM

Fix typo

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

WIFCONTINUED()?

labath added inline comments.Wed, Jun 7, 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.Wed, Jun 7, 11:34 AM
source/Host/common/Host.cpp
1001 ↗(On Diff #101758)

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

NetBSD part looks fine.

eugene added inline comments.Thu, Jun 8, 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.Tue, Jun 13, 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.Tue, Jun 13, 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.Thu, Jun 15, 1:10 PM
This revision is now accepted and ready to land.Thu, Jun 15, 1:10 PM
This revision was automatically updated to reflect the committed changes.