John Doe
John Doe

Reputation: 145

How to communicate properly between child process in other network namespace and parent process?

I am using Popen from subprocess to spawn a new process in a network namespace. I need to exchange data between the parent process and the newly spawned child process.

Currently, I am doing this by simply parsing from stdout, meaning that in my child process I simply print everything I need to transmit to the parent process and then parse it from the parent. Although this approach works, it seems extremely hacky and moreover, does not support a bidirectional data exchange (child -> parent and parent -> child).

I think creating a socket to communicate between the two processes does not work in my case, since the parent process is in a different network namespace.

How can I realize IPC between two separate network namespaces?

Upvotes: 0

Views: 495

Answers (1)

Hannu
Hannu

Reputation: 12205

A socket from AF_INET family would not be able to connect unless there was routing between your namespaces, but you could use unix domain sockets (socket.AF_UNIX). They do not use network namespace for anything as the socket is a "file" on your file system.

Upvotes: 1

Related Questions