Created
January 26, 2010 00:07
-
-
Save silverjam/286405 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import errno | |
import ctypes | |
try: | |
libc = ctypes.CDLL('libc.dylib') | |
except OSError: | |
libc = ctypes.CDLL('/lib/libc.so.6') | |
errorcode = int(sys.argv[1]) | |
errmsg = ctypes.c_char_p(libc.strerror(errorcode)).value | |
print "%s (%d): %s" % (errno.errorcode[errorcode], errorcode, errmsg,) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> ./errnolookup.py 1 | |
EPERM (1): Operation not permitted | |
> ./errnolookup.py 2 | |
ENOENT (2): No such file or directory | |
> ./errnolookup.py 3 | |
ESRCH (3): No such process | |
> ./errnolookup.py 42 | |
ENOMSG (42): No message of desired type |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment