aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/com_reload.c12
-rw-r--r--src/com_start.c3
-rw-r--r--src/com_stop.c3
-rw-r--r--src/genrc.88
-rw-r--r--src/genrc.c9
-rw-r--r--src/genrc.h1
6 files changed, 32 insertions, 4 deletions
diff --git a/src/com_reload.c b/src/com_reload.c
index fd12e7d..7a0f768 100644
--- a/src/com_reload.c
+++ b/src/com_reload.c
@@ -16,6 +16,18 @@ com_reload(void)
pidlist_init(&pids);
if (get_pid_list(genrc_pid_closure, &pids))
return 1;
+ if (genrc_verbose) {
+ printf("Reloading %s: sending %s to %s ",
+ genrc_program, strsignal(genrc_signal_reload),
+ pids.pidc > 1 ? "PIDs" : "PID");
+ printf("%lu", (unsigned long)pids.pidv[0]);
+ if (pids.pidc > 1) {
+ int i;
+ for (i = 0; i < pids.pidc; i++ )
+ printf(",%lu", (unsigned long)pids.pidv[i]);
+ }
+ putchar('\n');
+ }
pidlist_kill(&pids, genrc_signal_reload);
return 0;
}
diff --git a/src/com_start.c b/src/com_start.c
index 93c324e..65c1775 100644
--- a/src/com_start.c
+++ b/src/com_start.c
@@ -98,6 +98,9 @@ com_start(void)
}
}
+ if (genrc_verbose)
+ printf("Starting %s\n", genrc_program);
+
if ((p = getenv("GENRC_SENTINEL")) && *p == '1')
return sentinel();
diff --git a/src/com_stop.c b/src/com_stop.c
index 1cb4452..d57fa5e 100644
--- a/src/com_stop.c
+++ b/src/com_stop.c
@@ -35,6 +35,9 @@ com_stop(void)
return 1;
}
+ if (genrc_verbose)
+ printf("Stopping %s\n", genrc_program);
+
gettimeofday(&stoptime, NULL);
stoptime.tv_sec += genrc_timeout;
ratio = 1;
diff --git a/src/genrc.8 b/src/genrc.8
index 920252e..b750894 100644
--- a/src/genrc.8
+++ b/src/genrc.8
@@ -13,13 +13,13 @@
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with genrc. If not, see <http://www.gnu.org/licenses/>.
-.TH GENRC 8 "May 15, 2018" "GENRC" "Genrc User Manual"
+.TH GENRC 8 "May 17, 2018" "GENRC" "Genrc User Manual"
.SH NAME
genrc \- generic system initialization script helper
.SH SYNOPSIS
.nh
\fBgenrc\fR\
- [\fB\-h\fR]\
+ [\fB\-hv\fR]\
[\fB\-F\fR \fIPIDFILE\fR]\
[\fB\-P\fR \fISOURCE\fR]\
[\fB\-c\fR \fICOMMAND\fR]\
@@ -37,6 +37,7 @@ genrc \- generic system initialization script helper
[\fB\-\-signal\-stop=\fISIG\fR]\
[\fB\-\-timeout=\fISECONDS\fR]\
[\fB\-\-usage\fR]\
+ [\fB\-\-verbose\fR]\
{\
\fBstart\fR\
|\
@@ -193,6 +194,9 @@ Display a short usage summary.
.TP
\fB\-\-version\fR
Display program version and exit.
+.TP
+\fB\-v\fR, \fB\-\-verbose\fR
+Print verbose messages (e.g. "Starting \fIPROGNAME\fR").
.SH PID SOURCES
.TP
\fBFILE:\fIFILENAME\fR
diff --git a/src/genrc.c b/src/genrc.c
index 3f89d03..92b0fac 100644
--- a/src/genrc.c
+++ b/src/genrc.c
@@ -16,6 +16,7 @@ int genrc_signal_stop = SIGTERM;
int genrc_signal_reload = SIGHUP;
GENRC_PID_CLOSURE *genrc_pid_closure;
char *genrc_create_pidfile;
+int genrc_verbose;
enum {
@@ -41,9 +42,10 @@ struct option longopts[] = {
{ "sentinel", no_argument, 0, 'S' },
{ "create-pidfile", required_argument, 0, OPT_CREATE_PIDFILE },
{ "version", no_argument, 0, OPT_VERSION },
+ { "verbose", no_argument, 0, 'v' },
{ NULL }
};
-char shortopts[] = "c:hF:P:p:St:";
+char shortopts[] = "c:hF:P:p:St:v";
struct sigdefn {
char const *sig_name;
@@ -402,6 +404,9 @@ main(int argc, char **argv)
case OPT_SIGNAL_STOP:
setenv("GENRC_SIGNAL_STOP", optarg, 1);
break;
+ case 'v':
+ genrc_verbose++;
+ break;
default:
exit(1);
}
@@ -468,7 +473,7 @@ main(int argc, char **argv)
genrc_pid_closure = get_pid_closure(p);
free(p);
} else {
- genrc_pid_closure = get_pid_closure("PROC");
+ genrc_pid_closure = get_pid_closure(DEFAULT_PID_SOURCE);
}
argc -= optind;
diff --git a/src/genrc.h b/src/genrc.h
index 13b40d7..a6e81e8 100644
--- a/src/genrc.h
+++ b/src/genrc.h
@@ -132,6 +132,7 @@ extern int genrc_signal_reload;
extern int genrc_signal_stop;
extern GENRC_PID_CLOSURE *genrc_pid_closure;
extern char *genrc_create_pidfile;
+extern int genrc_verbose;
int sentinel(void);

Return to:

Send suggestions and report system problems to the System administrator.