mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 06:18:47 +02:00
Add --max-execution-time option
This commit is contained in:
17
src/init.c
17
src/init.c
@@ -30,6 +30,7 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <termios.h>
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef HAVE_INITGROUPS
|
||||
#include <grp.h>
|
||||
@@ -1013,14 +1014,30 @@ AddTrustedUser(char const *username)
|
||||
TrustedUsers[NumTrustedUsers] = pwent->pw_uid;
|
||||
NumTrustedUsers++;
|
||||
}
|
||||
static void
|
||||
sigalarm(int)
|
||||
{
|
||||
write(STDOUT_FILENO, "\nExecution time exceeded.\n", 26);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void
|
||||
ProcessLongOption(char const *arg)
|
||||
{
|
||||
int t;
|
||||
if (!strcmp(arg, "version")) {
|
||||
printf("%s\n", VERSION);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
if (sscanf(arg, "max-execution-time=%d", &t) == 1) {
|
||||
if (t <= 0) {
|
||||
fprintf(ErrFp, "%s: Value of --max-execution-time must be positive\n", ArgV[0]);
|
||||
return;
|
||||
}
|
||||
signal(SIGALRM, sigalarm);
|
||||
alarm(t);
|
||||
return;
|
||||
}
|
||||
fprintf(ErrFp, "%s: Unknown long option --%s\n", ArgV[0], arg);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user