Walter Harms
2018-08-27 13:55:10 UTC
Hi List,
i am a happy user of pidof and i am using it in scripts often
to check for a programm running like.
pidof programm >/dev/null || nohup programm &
i am always missing the -q what is common to other programm to
silence unwanted output. see below for a patch that add the -q
option. btw: pidof supports also -h but has no check and no usage.
hope that helps
re,
wh
--- killall5.c 2018-06-19 01:25:26.000000000 +0200
+++ killall5.c.new 2018-08-27 15:43:56.000000000 +0200
@@ -943,6 +943,7 @@
#define PIDOF_SINGLE 0x01
#define PIDOF_OMIT 0x02
#define PIDOF_NETFS 0x04
+#define PIDOF_QUIET 0x08
/*
* Pidof functionality.
@@ -966,7 +967,7 @@
if ((token = getenv("PIDOF_NETFS")) && (strcmp(token,"no") != 0))
flags |= PIDOF_NETFS;
- while ((opt = getopt(argc,argv,"hco:sxn")) != EOF) switch (opt) {
+ while ((opt = getopt(argc,argv,"qhco:sxn")) != EOF) switch (opt) {
case '?':
nsyslog(LOG_ERR,"invalid options on command line!\n");
closelog();
@@ -1008,6 +1009,9 @@
case 'n':
flags |= PIDOF_NETFS;
break;
+ case 'q':
+ flags |= PIDOF_QUIET;
+ break;
default:
/* Nothing */
break;
@@ -1065,15 +1069,17 @@
continue;
}
}
- if (!first)
- printf(" ");
- printf("%d", p->pid);
+ if ( ~flags & PIDOF_QUIET) {
+ if (!first)
+ printf(" ");
+ printf("%d", p->pid);
+ }
first = 0;
}
}
}
if (!first)
- printf("\n");
+ if ( ~flags & PIDOF_QUIET) printf("\n");
clear_mnt();
i am a happy user of pidof and i am using it in scripts often
to check for a programm running like.
pidof programm >/dev/null || nohup programm &
i am always missing the -q what is common to other programm to
silence unwanted output. see below for a patch that add the -q
option. btw: pidof supports also -h but has no check and no usage.
hope that helps
re,
wh
--- killall5.c 2018-06-19 01:25:26.000000000 +0200
+++ killall5.c.new 2018-08-27 15:43:56.000000000 +0200
@@ -943,6 +943,7 @@
#define PIDOF_SINGLE 0x01
#define PIDOF_OMIT 0x02
#define PIDOF_NETFS 0x04
+#define PIDOF_QUIET 0x08
/*
* Pidof functionality.
@@ -966,7 +967,7 @@
if ((token = getenv("PIDOF_NETFS")) && (strcmp(token,"no") != 0))
flags |= PIDOF_NETFS;
- while ((opt = getopt(argc,argv,"hco:sxn")) != EOF) switch (opt) {
+ while ((opt = getopt(argc,argv,"qhco:sxn")) != EOF) switch (opt) {
case '?':
nsyslog(LOG_ERR,"invalid options on command line!\n");
closelog();
@@ -1008,6 +1009,9 @@
case 'n':
flags |= PIDOF_NETFS;
break;
+ case 'q':
+ flags |= PIDOF_QUIET;
+ break;
default:
/* Nothing */
break;
@@ -1065,15 +1069,17 @@
continue;
}
}
- if (!first)
- printf(" ");
- printf("%d", p->pid);
+ if ( ~flags & PIDOF_QUIET) {
+ if (!first)
+ printf(" ");
+ printf("%d", p->pid);
+ }
first = 0;
}
}
}
if (!first)
- printf("\n");
+ if ( ~flags & PIDOF_QUIET) printf("\n");
clear_mnt();