/*
 * Copyright (c) 2022 Alfred Morgan <alf...@54.org>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */
Index: usr.sbin/slowcgi/slowcgi.8
===================================================================
RCS file: /cvs/src/usr.sbin/slowcgi/slowcgi.8,v
retrieving revision 1.16
diff -u -p -r1.16 slowcgi.8
--- usr.sbin/slowcgi/slowcgi.8 2 Sep 2021 14:14:44 -0000 1.16
+++ usr.sbin/slowcgi/slowcgi.8 25 May 2022 04:30:18 -0000
@@ -76,6 +76,10 @@ effectively disables the chroot.
 .It Fl s Ar socket
 Create and bind to alternative local socket at
 .Ar socket .
+.It Fl t Ar timeout
+Terminate the CGI script after
+.Ar timeout
+seconds instead of the default 120 seconds.
 .It Fl U Ar user
 Change the owner of
 .Pa /var/www/run/slowcgi.sock
Index: usr.sbin/slowcgi/slowcgi.c
===================================================================
RCS file: /cvs/src/usr.sbin/slowcgi/slowcgi.c,v
retrieving revision 1.62
diff -u -p -r1.62 slowcgi.c
--- usr.sbin/slowcgi/slowcgi.c 2 Sep 2021 14:14:44 -0000 1.62
+++ usr.sbin/slowcgi/slowcgi.c 25 May 2022 04:30:18 -0000
@@ -252,7 +252,7 @@ usage(void)
 {
  extern char *__progname;
  fprintf(stderr,
-    "usage: %s [-dv] [-p path] [-s socket] [-U user] [-u user]\n",
+    "usage: %s [-dv] [-p path] [-s socket] [-t timeout] [-U user] [-u
user]\n",
     __progname);
  exit(1);
 }
@@ -275,6 +275,7 @@ main(int argc, char *argv[])
  const char *chrootpath = NULL;
  const char *sock_user = SLOWCGI_USER;
  const char *slowcgi_user = SLOWCGI_USER;
+ char *p;

  /*
  * Ensure we have fds 0-2 open so that we have no fd overlaps
@@ -293,7 +294,7 @@ main(int argc, char *argv[])
  }
  }

- while ((c = getopt(argc, argv, "dp:s:U:u:v")) != -1) {
+ while ((c = getopt(argc, argv, "dp:s:t:U:u:v")) != -1) {
  switch (c) {
  case 'd':
  debug++;
@@ -304,6 +305,11 @@ main(int argc, char *argv[])
  case 's':
  fcgi_socket = optarg;
  break;
+    case 't':
+ timeout.tv_sec = strtoll(optarg, &p, 10);
+ if (*p)
+ errx(1, "illegal timeout -- %s", optarg);
+      break;
  case 'U':
  sock_user = optarg;
  break;

Reply via email to