Enlico
Enlico

Reputation: 28490

Why does launching socat with some arguments result in two processes?

Open 3 terminals, which I'll call A, B, and C, and execute the following:

  1. socat TCP-LISTEN:12345,fork - in A,
  2. pidof socat in B,
  3. socat TCP-CONNECT:localhost:12345 - in C,
  4. pidof socat again in B.

Step 2 will print 1 PID, whereas step 4 will print 3 PIDs, meaning that step 3 spawned 2 processes (whereas step 1 definitely spawned only 1).

Why is that? Is it an (uniteresting?) implementation detail of socat? Or is it necessary for socat to work?

Upvotes: -2

Views: 53

Answers (1)

artisignal
artisignal

Reputation: 401

It's no surprise socat listener spawns an extra process as it is literally instructed to do so by option fork.

Removing fork results in just two PIDs printed by step 4.

Upvotes: 2

Related Questions