Ignore stderr and use return code
Chris Angelico
rosuav at gmail.com
Mon Oct 26 22:31:38 EDT 2015
On Mon, Oct 26, 2015 at 3:34 PM, Cameron Simpson <cs at zip.com.au> wrote:
> No. Mount should have a zero status if it succeeds and anon-zero exit status
> if it fails. There is no grey area here.
This is the general case. For specific programs, you can often check
their man pages; for the mount(8) on my system, it's bitwise:
1 incorrect invocation or permissions
2 system error (out of memory, cannot fork, no more loop devices)
4 internal mount bug
8 user interrupt
16 problems writing or locking /etc/mtab
32 mount failure
64 some mount succeeded
It's also theoretically possible to get a return value of 127,
indicating that the 'mount' command was itself not found. That might
not seem likely, but if someone has a restricted $PATH, you might run
into that. Likewise 126 might indicate that "mount" exists but is
non-executable - again, unlikely in the case of mount, but possible.
In any case, you can generally depend on a non-zero exit status
indicating failure and zero being reserved for success.
ChrisA
More information about the Python-list
mailing list