piping
Making C code plot a graph automatically
I came across this while searching for something else regarding gnuplot. Even though it’s an old question, I thought I’d contribute some sample code. I use this for a program of mine, and I think it does a pretty tidy job. AFAIK, this PIPEing only works on Unix systems (see the edit below for Windows … Read more
Using fseek with a file pointer that points to stdin
Yes, it’s perfectly normal that fseek won’t work on stdin — it’ll normally only work on a disk file, or something reasonably similar. Though it’s really a POSIX thing, you can typically use if (isatty(fileno(myFile))) to get at least a pretty good idea of whether seeking will work in a particular file. In some cases, … Read more
Piping both stdout and stderr in bash?
(Note that &>>file appends to a file while &> would redirect and overwrite a previously existing file.) To combine stdout and stderr you would redirect the latter to the former using 1>&2. This redirects stdout (file descriptor 1) to stderr (file descriptor 2), e.g.: $ { echo “stdout”; echo “stderr” 1>&2; } | grep -v … Read more
Why piping input to “read” only works when fed into “while read …” construct? [duplicate]
How to do a loop against stdin and get result stored in a variable Under bash (and other shell also), when you pipe something to another command via |, you will implicitly create a fork, a subshell that is a child of current session. The subshell can’t affect current session’s environment. So this: TOTAL=0 printf … Read more
Piping and forking in python
The immediate problem is that your child has an infinite loop, reading num1 over and over forever (or, rather, reading it twice and then blocking forever on a third input that will never come) before doing anything. Fix that by moving more of the code into the while loop, like this: def child(pipein): while True: … Read more