c

[python] os.system output out-of-order using shell pipe

t.py as below:

1
2
3
4
5
import os

print "### before ps"
os.system("ps")
print "### after ps"

logical is quite simple, if we directly run it: python t.py, output as below, nothing special:

1
2
3
4
5
6
7
### before ps
  PID TTY          TIME CMD
 1619 pts/9    00:00:00 python
 1620 pts/9    00:00:00 sh
 1621 pts/9    00:00:00 ps
18701 pts/9    00:00:00 bash
### after ps