socat with EXEC:script spawns 5 processes/sec

248 Views Asked by At

I'm using socat to run a script that cat's the output of a file. The script looks like this:

while true
  do
    echo hello
    sleep 1
  done

The socat command looks like this:

socat -v -d -d -d EXEC:"bash script" TCP4-listen:4444,reuseaddr,fork

While this works well, I noticed that my pid numbers were really high. This is caused by socat. Notice time stamps:

20:45:42 0 $ echo $$
9693

21:02:36 0 $ echo $$
14767

So in ~17 minutes, 5074 processes have been created. Thats about 5 every second.

  • Why does socat spawn so many processes?
  • Is there a better way to run this command? Better socat command and/or better script?

I don't think high pid's affects the system, but it seems a bit overkill for such a simple scheme.

Thanks.

0

There are 0 best solutions below