Python version (running under Fedora Core 2 Linux):
Python 2.3.3 (#1, May 7 2004, 10:31:40)
[GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)] on linux2
---------------------------------------------------------------------------
I found a problem while executing the 'ulimit -f' bash
command within the 'os.system' function. According to
the documentation this function should behave exactly
like the stdlib function 'system'. However it does not
happen as illustrated by the minimal Python and C
examples: testsystem.py and testsystem.c (see attached
zipped file).
In these examples 'largefile' is a compiled C program
which writes an endless file into the stdout (also
attached). The C program testsystem.c works as expected
and prints the following output:
command: ulimit -f 10; largefile > xxx;
result = 153
The Python program testsystem.py **does not stop**; if
interrupted by Ctrl-C it prints:
command: ulimit -f 10; largefile > xxx;
result = 0
In both cases the output file 'xxx' has 10240 bytes,
ie, 10 blocks as limited by 'ulimit'.
It is interesting though that the command 'ulimit -t 1'
(CPU time) produces correct results under both Python
and C versions, ie, interrupts the execution and prints:
command: ulimit -t 1; largefile > xxx;
result = 137
|