Prerequisite – Creating child process in Python
As there are many processes running simultaneously on the computer so it is very necessary to have proper communication between them as one process may be dependent on other processes.There are various methods to communicate between processes. Here is a simple Python program to demonstrate communication between the parent process and child process using the pipe method.
Library Used –
OS Module in Python : The OS module in Python provides a way of using operating system dependent functionality. The functions that the OS module provides allows you to interface with the underlying operating system that Python is running on; be that Windows, Mac or Linux. It can be imported as –
System Call Used –
pipe() System call : The method pipe() creates a pipe and returns a pair of file descriptors (r, w) usable for reading and writing, respectively. This method returns a pair of file descriptor.
Syntax – Following is the syntax for pipe() method –
Note – Pipe is one-way communication only i.e we can use a pipe such that One process write to the pipe, and the other process reads from the pipe.
Child writing Child writes = Hello geeks Parent reading Parent reads = Hello geeks
- Creating child process using fork() in Python
- Run Python script from Node.js using child process spawn() method
- Count all Grandparent-Parent-Child Triplets in a binary tree whose sum is greater than X
- Python | os.pipe() method
- Multiprocessing in Python | Set 2 (Communication between processes)
- PyQt5 QSpinBox - Finding child using child type
- Get parent of current directory using Python
- Python PRAW - Getting the parent ID of a comment in Reddit
- Python: Call Parent class method
- parent element method - Selenium Python
- Python - Access Parent Class Attribute
- Kill a Process by name using Python
- Python - Process images of a video using OpenCV
- Implementing Artificial Neural Network training process in Python
- PyQt5 QSpinBox - How to get the parent
- PyQt5 QCalendarWidget - Getting child using ID
- PyQt5 QSpinBox - Getting native parent widget
- PyQt5 QCalendarWidget - Moving it to the top of the parent stack
- PyQt5 QCalendarWidget - Native Parent Widget
- PyQt5 QColorDialog - Child by the type
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Akanksha_Rai