From 902e750f69a4c6873d9dd70a4f86cbae3f0cea25 Mon Sep 17 00:00:00 2001 From: in2 Date: Thu, 10 Apr 2003 18:05:45 +0000 Subject: sleep interval in argv[1] git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk@787 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- pttbbs/util/shmctl.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pttbbs/util/shmctl.c b/pttbbs/util/shmctl.c index 89c9069a..04f5b112 100644 --- a/pttbbs/util/shmctl.c +++ b/pttbbs/util/shmctl.c @@ -1,4 +1,4 @@ -/* $Id: shmctl.c,v 1.38 2003/04/08 09:53:21 in2 Exp $ */ +/* $Id: shmctl.c,v 1.39 2003/04/10 18:05:45 in2 Exp $ */ #include "bbs.h" #include @@ -257,11 +257,16 @@ inline void utmpsort(void) int utmpsortd(int argc, char **argv) { pid_t pid; + int interval; // sleep interval in microsecond(1/10**6) + if( fork() > 0 ){ puts("sortutmpd daemonized..."); return 0; } + if( argc != 2 || (interval = atoi(argv[1])) < 500000 ) + interval = 1000000; // default to 1 sec + while( 1 ){ if( (pid = fork()) != 0 ){ int s; @@ -276,7 +281,7 @@ int utmpsortd(int argc, char **argv) if( SHM->UTMPneedsort ) utmpsort(); - sleep(1); + usleep(interval); } } } -- cgit v1.2.3