0

I'm been looking for an explanation for the difference between screen's -dm and -Dm options. I know that both options are used to make the screen run in the background / detach it after creation. I've read that the difference has something to do with forking, but I don't understand it.

I use screen to contain the console of my Minecraft server. When I called it directly in my simple systemd service, everything worked fine. However, when I moved the call to a script and called the script from the service, the service would exit when the script exits, stopping the Minecraft server with the ExecStop command. Some Googling revealed that I should use a forking service to prevent this, but that doesn't solve the issue, and I cannot use a oneshot service that doesn't exit, as I need the system to be able to detect if the Minecraft server is still running.

I currently call screen the following way:

screen -DmS minecraft java -jar server.jar nogui &

I use the & to fork the process and keep the screen from freezing the shell.

Since the service fails due to not forking properly, and the difference between the -Dm and -dm options has something to do with forking, I suspect that's where the problem is.

Could someone explain to me what the practical difference between these options is, and how I can use screen properly in a forking service?

Thanks in advance.

2

1 Answer 1

0

I'm just quoting the manual here:

-d -m   Start screen in "detached" mode. This creates a new session but
        doesn't attach to it. This is useful for system startup scripts.

-D -m   This  also  starts  screen  in "detached" mode, but doesn't fork a new process.
        The command exits if the session terminates.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .