dix: Add optional terminate delay

When the command line option "-terminate" is used, it could be
interesting to give it an optional grace period to let the Xserver
running for a little longer in case a new connection occurs.

This adds an optional parameter to the "-terminate" command line option
for this purpose.

v2: Use a delay in seconds instead of milliseconds
    (Martin Peres <martin.peres@mupuf.org>)
v3: Clarify man page entry, ensure terminateDelay is always >= 0,
    simplify TimerFree(). (Peter Hutterer <peter.hutterer@who-t.net>)

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Olivier Fourdan
2021-04-28 13:33:29 +02:00
parent e167299f60
commit 6b47321bc6
5 changed files with 52 additions and 4 deletions

View File

@@ -561,7 +561,7 @@ UseMsg(void)
ErrorF("-s # screen-saver timeout (minutes)\n");
ErrorF("-seat string seat to run on\n");
ErrorF("-t # default pointer threshold (pixels/t)\n");
ErrorF("-terminate terminate at server reset\n");
ErrorF("-terminate [delay] terminate at server reset (optional delay in sec)\n");
ErrorF("-tst disable testing extensions\n");
ErrorF("ttyxx server started from init on /dev/ttyxx\n");
ErrorF("v video blanking for screen-saver\n");
@@ -917,6 +917,10 @@ ProcessCommandLine(int argc, char *argv[])
}
else if (strcmp(argv[i], "-terminate") == 0) {
dispatchExceptionAtReset = DE_TERMINATE;
terminateDelay = -1;
if ((i + 1 < argc) && (isdigit(*argv[i + 1])))
terminateDelay = atoi(argv[++i]);
terminateDelay = max(0, terminateDelay);
}
else if (strcmp(argv[i], "-tst") == 0) {
noTestExtensions = TRUE;