I am creating named pipes in Ubuntu 18 and 16 environments in C language using gcc as compiler (
mkfifo()
and open()
). One of the things I noticed that the named pipes remain in the filesystem after the process ends. My process is a endless process that runs in a while(1)
loop because of my requirements and the only way to exit is ctrl-c or the kill
command in linux. I might add a ctrl-c signal to properly handle these situations but this is not the question.
Given that the named pipe remains in the filesystem (for example /tmp/named_pipe1
), do I need to check if the named pipe exists in the filesystem and delete it in the beginning of the process (because the file persists in the system), or is it redundant because even the file stays in the filesystem, it's buffer is deleted and I can use it like a new fresh fifo ? Because I don't want the fifo buffers to be mixed when I ctrl-c exit the previous run of the code and start the new one. I require an empty buffer when I restart the code.
**Note:** The system is not restarted between the runs of the process. Just the process is re-run.
Thanks in advance.
Asked by Max Paython
(101 rep)
Jan 25, 2020, 09:47 PM
Last activity: Apr 22, 2025, 09:05 AM
Last activity: Apr 22, 2025, 09:05 AM