This is a pretty n00b question as I am still learning how the bash shell works. However, google did not yield any results that I could get. Let us say I have .c.c file and corresponding executable (let us say foo) that takes in some input from stdin and then makes a sys call to /bin/sh/bin/sh. I feedFeeding input to this executable as followslike following:
python -c "<some script to feed input>" | ./foo I observed that the shell invoked by foo closes immediately and foo terminates. However, someone on IRC recommended that I feed in inputexecuting like this:
(python -c "<some script to feed input>"; cat) | ./foo I observed thatkeeps the subshell invoked by ./foo persists./foo still running. I would like to know what is going on here.
My Speculation: For the first case, Does the stdout of the python script close as soon as it's done thus sending EOF to the stdin of the process ./foo./foo terminating ./foo./foo? But that does not make sense to me as the sys call should be a blocking one leading to ./foo./foo not terminating. I would appreciate help and a pointer to resources to fix erroneous understanding. Thanks!