0

How can ncat be used to spawn a process in the background? For example:

ncat -lp 2342 -c "setsid sleep 5 &"

As I understand, setsid and & will make the process run in the background but ncat does not close until sleep finishes. I can forcefully close ncat and sleep will still run. How can I make ncat close immediately while still having sleep run in the background?

Dave
  • 101
  • 1
  • Do you want ncat to close (exit) immediately after one connection? Or could you explain in more detail what you want to achieve with this? – Sebastian Oct 17 '19 at 14:47
  • Indeed, the connection currently just hangs, until sleep returns. – Dave Oct 17 '19 at 17:06

1 Answers1

0

After a lot of searching, I figured out that I could use daemon to get the functionality I was looking for.

ncat -lp 2342 -c "daemon sleep 5"
Dave
  • 101
  • 1