Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
L ldpl
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 8
    • Issues 8
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Lartu
  • ldpl
  • Merge requests
  • !102

Merged
Created May 17, 2019 by Lartu@lartu🐕Maintainer

Fix exit code on BSD/Mac

  • Overview 7
  • Commits 3
  • Changes 1

Created by: dvkt

Continuing the conversation from 3f5325a6...

Currently on master, the exit code for EXECUTE - AND STORE EXIT CODE IN is always 0. I did some digging and it looks like BSD has a different WEXITSTATUS() macro than Linux:

OpenBSD's implementation of WEXITSTATUS uses the address-of operator (unary &) on its argument, effectively requiring that its argument have storage. You are calling it with the return value of a function, which doesn't have storage, so the compiler complains. - https://stackoverflow.com/a/13674801

Here's BSD/Mac's:

https://github.com/apple/darwin-xnu/blob/0a798f6738bc1db01281fc08ae024145e84df927/bsd/sys/wait.h#L144

Which uses the _W_INT macro:

https://github.com/apple/darwin-xnu/blob/0a798f6738bc1db01281fc08ae024145e84df927/bsd/sys/wait.h#L128

And glibc's, which doesn't:

https://github.com/bminor/glibc/blob/7628a1b05adb1e4c6857b87c6f8b71a1d0b1d72c/posix/sys/wait.h#L54

https://github.com/bminor/glibc/blob/7628a1b05adb1e4c6857b87c6f8b71a1d0b1d72c/bits/waitstatus.h#L28

I tried a few things but I suspect the most portable would just be to overwrite _W_INT if it exists to do what we want. Sounds like only really old code expects wait() to return a union on BSDs, anyway.

I also added the explicit (int) cast which my Linux machines needed, for some reason.

Assignee
Assign to
Reviewer
Request review from
None
Milestone
None
Assign milestone
Time tracking
Source branch: github/fork/dvkt/bsd-exit