-2

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?

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Darn! I've been entering that line in the command line so many times I've become blind to it :'D

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.