aboutsummaryrefslogtreecommitdiff
path: root/src/com_status.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/com_status.c')
-rw-r--r--src/com_status.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/com_status.c b/src/com_status.c
new file mode 100644
index 0000000..f68c6ef
--- /dev/null
+++ b/src/com_status.c
@@ -0,0 +1,38 @@
+#include "genrc.h"
+
+int
+com_status(void)
+{
+ PIDLIST pids;
+ int rc;
+
+ pidlist_init(&pids);
+ rc = get_pid_list(genrc_pid_closure, &pids);
+ if (rc == 0) {
+ if (pids.pidc == 0)
+ printf("%s is not running\n", genrc_program);
+ else {
+ printf("%s is running ", genrc_program);
+ if (pids.pidc == 1) {
+ printf("(pid %lu)",
+ (unsigned long) pids.pidv[0]);
+ } else {
+ int i;
+ int delim = ' ';
+ printf("(pids");
+ for (i = 0; i < pids.pidc; i++) {
+ printf("%c%lu", delim,
+ (unsigned long) pids.pidv[i]);
+ delim = ',';
+ }
+ putchar(')');
+ }
+ putchar('\n');
+ }
+ } else {
+ printf("status unknown\n");
+ }
+ return 0;
+}
+
+

Return to:

Send suggestions and report system problems to the System administrator.