-1

When inetd makes several programs run as services, does inetd require the programs necessarily written as daemons (e.g. not having a controlling terminal, no interactive input, ...)?

Or caninetd daemonize nondaemon processes, similar to what setid can do?

By the way, same questions for nc, given that https://unix.stackexchange.com/a/500646/674

Thanks.

Tim
  • 98,580
  • 191
  • 570
  • 977
  • At least `nc` can't required that, because it i s not able to check the code of the program. It simply run that program in a new process with the connection socket as stdin and stdout. Does this mean daemonized? That depends on your definition of daemon. – 炸鱼薯条德里克 Feb 14 '19 at 15:11
  • Daemonize In a way similar to `setsid`? – Tim Feb 14 '19 at 15:14
  • I'm pretty sure `nc` don't call `setsid` or anything special in that new process, you might want to `strace` it. – 炸鱼薯条德里克 Feb 14 '19 at 15:35
  • 2
    Typically, applications designed to be executed by `inetd` should _not_ try to make themselves into daemons. `inetd` will execute the command when an incoming connection is made, the process will run as a child of inetd, and when the session is over then it can terminate. If 2 connections are made then `inetd` will run two copies of the program. – Stephen Harris Feb 14 '19 at 16:07

1 Answers1

1

Typically, applications designed to be executed by inetd should not try to make themselves into daemons. inetd will execute the command when an incoming connection is made, the process will run as a child of inetd, and when the session is over then it can terminate.

So, for example, you can run sshd via inetd, but you need to pass the -D flag to sshd prevent it from becoming a daemon.

If 2 connections are made then inetd will run two copies of the program.

Stephen Harris
  • 42,369
  • 5
  • 94
  • 123