Skip to content

Instantly share code, notes, and snippets.

@jasonrogena
Created October 2, 2017 14:42
Show Gist options
  • Save jasonrogena/880574c58d9691dd50b1ea6dad639a12 to your computer and use it in GitHub Desktop.
Save jasonrogena/880574c58d9691dd50b1ea6dad639a12 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
int main() {
int res;
res = sethostid(gethostid());
if (res != 0) {
switch (errno) {
case EACCES:
fprintf(stderr, "Error! No permission to write the"
" file used to store the host ID.\n"
"Are you root?\n");
break;
case EPERM:
fprintf(stderr, "Error! The calling process's effective"
" user or group ID is not the same as"
" its corresponding real ID.\n");
break;
default:
fprintf(stderr, "Unknown error.\n");
}
return 1;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment