-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
RFE: please propagate documented error codes from /usr/bin/swapoff in swapoff failed due to OOM #1050
Comments
The current code hides details about reason why swapoff(8) and swapoff(2) failed. For example ENOMEM from swapoff(2) is important as it indicates OOM. The patch also clean ups --all return codes to be more compatible for example with [u]mount --all, etc. Addresses: #1050 Signed-off-by: Karel Zak <kzak@redhat.com>
Implemented. The magic exit status you look for is "2" (for ENOMEM). The rest is (copy & past from man page):
We need also clean up swapon(8) to keep it consistent, but tomorrow ;-) |
What did the tool return previously on failure? always 1? if so, for compat reasons, wouldn't it make sense to change the table above, and map OOM to 2 and "failed for another reason" to 1? That way, systemd could check for error code 2, and on new swapoff it's a clear indication for OOM, and on old OOM it would never happen. But with your current work we couldn't distuingish the case "old swapoff" from "new swapoff and oom", if you follow what i mean? |
The old version returns 255 on all swapoff(2) errors and 1 for non-swaoff() and for EPERM errors. Maybe avoid 1 at all would be the best thing. It means use 0, 2, 4, 8, 16, 32, and 64. |
Yes, that would make sense! For the systemd case we are primarily interested in having a recognizable error for the OOM case that wasn't previously used otherwise. |
The make sure we are not in collision with old versions. Addresses: #1050 Signed-off-by: Karel Zak <kzak@redhat.com>
Released in util-linux v2.36. |
IIUC the kernel swapoff() syscall returns ENOMEM if there's not enough RAM to place the swapped out data into. It would be great if the swapoff binary would propagate that error code in some documented way through its exit status, so that systemd and similar systems can react to that condition in some way.
The text was updated successfully, but these errors were encountered: