Does pipe have to write temporary file?
pipes don't store data on disk. /bin/echo foo | grep bar doesn't create any files. try
strace -f sh -c '/bin/echo foo | grep bar'
to see all the system calls made by a shell when running a pipeline.echo
is a shell builtin, so I suggested/bin/echo
to make the shell run an executable./tmp
doesn't have to be on disk. It can be mounted on tmpfs (i.e. backed by virtual memory). Note that a reboot will empty/tmp
in that case, so use/var/tmp
for anything you want to leave around.
If what you're doing is putting data into a file, then it's not using a pipe. If the file is a fifo, not a regular file, then it's just a named rendezvous, and doesn't contain data. Use ls -l to find out.
And note that if you're hoping to stop users from seeing what's going through pipes in processes they own, you are pretty much SOL, because strace
can inspect everything a process does that interacts with anything outside the process, except for reading/writing mmapped shared memory. ltrace
is even more invasive. If your program will run on systems where the local user has root, you can't stop them at all. On Unix, root can do anything, and has powerful tools for the purpose.