Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can use pipe without fork?

Tags:

c

linux

fork

posix

Can I use pipe between two process without using fork and share file descriptors with for example socket ? I don't need another solution, I need pipe between two process that not forked.

like image 208
ltt Avatar asked Nov 13 '12 08:11

ltt


People also ask

What is fork and pipe?

Syntax: fork(); // It does not take any parameter, it returns // integer values. It may return negative, // positive or zero integer values. pipe(): It is used for inter-process communication in Linux. It is a system function. (

What does pipe () do in C?

pipe() is a Linux system function. The pipe() system function is used to open file descriptors, which are used to communicate between different Linux processes. In short, the pipe() function is used for inter-process communication in Linux.

What is unnamed pipe in OS?

An unnamed pipe is a direct connection between two commands running in the same terminal. If we want to send output from a command in one terminal to another command in a different terminal, we can use a named pipe, or FIFO. FIFO stands for first in, first out. This is a pipe that exists in the file system.

What does pipe function do in Linux?

A pipe is a form of redirection (transfer of standard output to some other destination) that is used in Linux and other Unix-like operating systems to send the output of one command/program/process to another command/program/process for further processing.


1 Answers

You could use a named pipe (FIFO):

if you do mkfifo <common path>, you an use this path in both processes, one for reading and one for writing. Then you have the same behaviour as with a normal pipe.

like image 89
glglgl Avatar answered Sep 23 '22 16:09

glglgl