Module Name: src Committed By: jmcneill Date: Tue May 15 01:41:30 UTC 2018
Modified Files: src/usr.bin/usbhidaction: usbhidaction.1 usbhidaction.c Log Message: Add an optional '-p pidfile' parameter. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/usr.bin/usbhidaction/usbhidaction.1 cvs rdiff -u -r1.28 -r1.29 src/usr.bin/usbhidaction/usbhidaction.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/usbhidaction/usbhidaction.1 diff -u src/usr.bin/usbhidaction/usbhidaction.1:1.15 src/usr.bin/usbhidaction/usbhidaction.1:1.16 --- src/usr.bin/usbhidaction/usbhidaction.1:1.15 Wed Apr 30 13:11:01 2008 +++ src/usr.bin/usbhidaction/usbhidaction.1 Tue May 15 01:41:29 2018 @@ -1,4 +1,4 @@ -.\" $NetBSD: usbhidaction.1,v 1.15 2008/04/30 13:11:01 martin Exp $ +.\" $NetBSD: usbhidaction.1,v 1.16 2018/05/15 01:41:29 jmcneill Exp $ .\" .\" Copyright (c) 2000 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd October 20, 2004 +.Dd May 14, 2018 .Dt USBHIDACTION 1 .Os .Sh NAME @@ -39,6 +39,7 @@ .Op Fl d .Op Fl i .Fl f Ar device +.Op Fl p Ar pidfile .Op Fl t Ar table .Op Fl v .Op Ar arg ... @@ -69,6 +70,14 @@ If it is a relative path, it is taken to be the name of the device under .Pa /dev . An absolute path is taken to be the literal device pathname. +.It Fl p Ar pidfile +Writes a file containing the process ID of the program. +The file name has the form +.Pa /var/run/usbhidaction.pid . +If the option is not given, +.Ar pidfile +defaults to +.Pa usbhidaction . .It Fl t Ar table Specify a path name for the HID usage table file. .It Fl v Index: src/usr.bin/usbhidaction/usbhidaction.c diff -u src/usr.bin/usbhidaction/usbhidaction.c:1.28 src/usr.bin/usbhidaction/usbhidaction.c:1.29 --- src/usr.bin/usbhidaction/usbhidaction.c:1.28 Sun Dec 10 20:38:14 2017 +++ src/usr.bin/usbhidaction/usbhidaction.c Tue May 15 01:41:29 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: usbhidaction.c,v 1.28 2017/12/10 20:38:14 bouyer Exp $ */ +/* $NetBSD: usbhidaction.c,v 1.29 2018/05/15 01:41:29 jmcneill Exp $ */ /* * Copyright (c) 2000, 2002 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: usbhidaction.c,v 1.28 2017/12/10 20:38:14 bouyer Exp $"); +__RCSID("$NetBSD: usbhidaction.c,v 1.29 2018/05/15 01:41:29 jmcneill Exp $"); #endif #include <stdio.h> @@ -95,13 +95,14 @@ main(int argc, char **argv) struct command *cmd; int reportid; const char *table = NULL; + const char *pidfn = NULL; setprogname(argv[0]); (void)setlinebuf(stdout); demon = 1; ignore = 0; - while ((ch = getopt(argc, argv, "c:df:it:v")) != -1) { + while ((ch = getopt(argc, argv, "c:df:ip:t:v")) != -1) { switch(ch) { case 'c': conf = optarg; @@ -115,6 +116,9 @@ main(int argc, char **argv) case 'f': dev = optarg; break; + case 'p': + pidfn = optarg; + break; case 't': table = optarg; break; @@ -169,7 +173,7 @@ main(int argc, char **argv) if (demon) { if (daemon(0, 0) < 0) err(EXIT_FAILURE, "daemon()"); - (void)pidfile(NULL); + (void)pidfile(pidfn); isdemon = 1; } @@ -214,7 +218,7 @@ usage(void) { (void)fprintf(stderr, "usage: %s -c config_file [-d] -f hid_dev " - "[-i] [-t table] [-v]\n", getprogname()); + "[-i] [-p pidfile] [-t table] [-v]\n", getprogname()); exit(EXIT_FAILURE); }