I'm having trouble with sending shutdown -h 0 to a lxc Debian container (i.e. executing this command in the lxc) with with the python pexpect module (in a python script). In this module the user can expect (= wait for process output) a certain substring, amongst others EOF, which leads me to the question in order to be able to debug further why EOF isn't recognized in the output. I need to know what I can expect after termination of the process in order to wait for the process to end. I can't simply wait for the process because the pexpect module hides non-blocking functions for that.The pexpect module (see http://www.bx.psu.edu/~nate/pexpect/pexpect.html#pexpect.spawn.expect for details) wraps the reception of EOF in the read system call in a (duck)type and makes it usable in pexpect.expect (an encapsulation of possible output/feedback of a process).I've been wondering that because some processes like ls are expected to terminate with EOF, i.e. the pexpect sense of EOF (example at http://pexpect.sourceforge.net/pexpect.html).
Do all Linux processes write EOF to stdout when they are terminating/have finished terminating?
linux;process;python;lxc;output
EOF indicates that no further input is to be expected on a resource which possibly provides an endless amount of data (e.g. a stream). This situation is often expressed by writing a single character on the stream (to be defined by the underlying system (likely a OS or runtime environment )).As processes use streams for inter-process communication they need to indicate the limits of their output and sending processes need to inidicate the limits of their input using EOF. The underlying system will very certainly forward this input and output to its own process handling mechanisms making EOF avaialble for evaluation in the program/on the system.Note about pexpect use case in the question: shutil.pexpect doesn't seem to be suitable to copy files of a lxc container. It got stuck and the time offset of the pexpect output causes the confusion.