Grokbase Groups Python tutor May 2005

In my first example, clamdscan should return 1 when the EICAR string is
found -- process.wait() gets 256 instead. In the second, clamdscan
returns 2 if an error occurs, such as trying to scan a non-existent
file, but 512 is returned.

No doubt there is a reason why the exit code is getting multiplied by
256... ??? My search has not enlightened me, however.

The return value of wait() packs a few values in a single integer, so you
may need to do some bit manipulation. The popen2 documentation talks
about this:

Waits for and returns the status code of the child process. The status
code encodes both the return code of the process and information about
whether it exited using the exit() system call or died due to a signal.
Functions to help interpret the status code are defined in the os module;
see section 6.1.5 for the W*() family of functions.

You can take a look near the bottom of:

for functions like os.WEXITSTATUS(), which should help you get the values
that you're expecting.

This is all definitely "not obvious" stuff, so please feel free to
continue to ask questions. Best of wishes!

Search Discussions

Discussion Posts


Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 5 of 5 | next ›
Discussion Overview
grouptutor @
postedMay 12, '05 at 5:56p
activeMay 12, '05 at 11:10p

2 users in discussion

Danny Yoo: 3 posts Jeffrey Rice: 2 posts



site design / logo © 2022 Grokbase