[Midnightbsd-cvs] src [8786] trunk/usr.sbin/newsyslog/newsyslog.c: fix newsyslog -n printing.

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sun Sep 25 23:13:38 EDT 2016


Revision: 8786
          http://svnweb.midnightbsd.org/src/?rev=8786
Author:   laffer1
Date:     2016-09-25 23:13:38 -0400 (Sun, 25 Sep 2016)
Log Message:
-----------
fix newsyslog -n printing. init things with R flag

Modified Paths:
--------------
    trunk/usr.sbin/newsyslog/newsyslog.c

Modified: trunk/usr.sbin/newsyslog/newsyslog.c
===================================================================
--- trunk/usr.sbin/newsyslog/newsyslog.c	2016-09-26 03:11:51 UTC (rev 8785)
+++ trunk/usr.sbin/newsyslog/newsyslog.c	2016-09-26 03:13:38 UTC (rev 8786)
@@ -179,7 +179,7 @@
 	int	 sw_pidok;		/* true if pid value is valid */
 	pid_t	 sw_pid;		/* the process id from the PID file */
 	const char *sw_pidtype;		/* "daemon" or "process group" */
-	int	 run_cmd;		/* run command or send PID to signal */
+	int	 sw_runcmd;		/* run command or send PID to signal */
 	char	 sw_fname[1];		/* file the PID was read from or shell cmd */
 };
 
@@ -1864,7 +1864,7 @@
 	int kres, secs;
 	char *tmp;
 
-	if (!(swork->sw_pidok) || swork->sw_pid == 0)
+	if (swork->sw_runcmd == 0 && (!(swork->sw_pidok) || swork->sw_pid == 0))
 		return;			/* no work to do... */
 
 	/*
@@ -1898,14 +1898,19 @@
 	}
 
 	if (noaction) {
-		printf("\tkill -%d %d \t\t# %s\n", swork->sw_signum,
-		    (int)swork->sw_pid, swork->sw_fname);
-		if (secs > 0)
-			printf("\tsleep %d\n", secs);
+		if (swork->sw_runcmd)
+			printf("\tsh -c '%s %d'\n", swork->sw_fname,
+			    swork->sw_signum);
+		else {
+			printf("\tkill -%d %d \t\t# %s\n", swork->sw_signum,
+			    (int)swork->sw_pid, swork->sw_fname);
+			if (secs > 0)
+				printf("\tsleep %d\n", secs);
+		}
 		return;
 	}
 
-	if (swork->run_cmd) {
+	if (swork->sw_runcmd) {
 		asprintf(&tmp, "%s %d", swork->sw_fname, swork->sw_signum);
 		if (tmp == NULL) {
 			warn("can't allocate memory to run %s",
@@ -1981,7 +1986,7 @@
 	else
 		pgm_name++;
 
-	if (zwork->zw_swork != NULL && zwork->zw_swork->run_cmd == 0 &&
+	if (zwork->zw_swork != NULL && zwork->zw_swork->sw_runcmd == 0 &&
 	    zwork->zw_swork->sw_pidok <= 0) {
 		warnx(
 		    "log %s not compressed because daemon(s) not notified",
@@ -2073,10 +2078,12 @@
 	tmpsiz = sizeof(struct sigwork_entry) + strlen(ent->pid_cmd_file) + 1;
 	stmp = malloc(tmpsiz);
 	
-	stmp->run_cmd = 0;
+	stmp->sw_runcmd = 0;
 	/* If this is a command to run we just set the flag and run command */
 	if (ent->flags & CE_PID2CMD) {
-		stmp->run_cmd = 1;
+		stmp->sw_pid = -1;
+		stmp->sw_pidok = 0;
+		stmp->sw_runcmd = 1;
 	} else {
 		set_swpid(stmp, ent);
 	}



More information about the Midnightbsd-cvs mailing list