summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralbert <>2006-06-24 21:17:51 +0000
committeralbert <>2006-06-24 21:17:51 +0000
commita791f8034f1d70572c0f2cf13881078bebcb0643 (patch)
tree4f4bbb289ade2c5fbb3812d02f4df009087ad193
parent47d33e7ed4e4d4f8a6910f796b776f9617a2e93a (diff)
downloadprocps-ng-a791f8034f1d70572c0f2cf13881078bebcb0643.tar.gz
sysctl: use - for stdin
-rw-r--r--NEWS3
-rw-r--r--sysctl.81
-rw-r--r--sysctl.c7
3 files changed, 9 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 665e277..b3cd29a 100644
--- a/NEWS
+++ b/NEWS
@@ -11,7 +11,8 @@ pwdx: buffer overflow fixed -- thanks Ulf Harnhammar
procps.spec needed a slash -- thanks Jesse Brandeburg
w: stale utmp entries snuck in via uninitialized var -- thanks Robert A Basch
pgrep/pkill: fix some realloc-related crashes #353894
-pgrep/pkill: g is criteria (secret PLD Linux patch)
+pgrep/pkill: g is criteria (PLD Linux, patch found in locked filing cabinet)
+sysctl: use - for stdin (PLD Linux: beware of the leopard)
procps-3.2.5 --> procps-3.2.6
diff --git a/sysctl.8 b/sysctl.8
index e8e44cf..e26c4fb 100644
--- a/sysctl.8
+++ b/sysctl.8
@@ -57,6 +57,7 @@ Use this option when you want to change a sysctl setting.
.TP
.B "-p"
Load in sysctl settings from the file specified or /etc/sysctl.conf if none given.
+Specifying \- as filename means reading data from standard input.
.TP
.B "-a"
Display all values currently available.
diff --git a/sysctl.c b/sysctl.c
index e25aeb9..0c0e73a 100644
--- a/sysctl.c
+++ b/sysctl.c
@@ -365,7 +365,12 @@ static int Preload(const char *restrict const filename) {
int rc = 0;
char *name, *value;
- if (!filename || ((fp = fopen(filename, "r")) == NULL)) {
+ fp = (filename[0]=='-' && !filename[1])
+ ? stdin
+ : fopen(filename, "r")
+ ;
+
+ if (!fp) {
fprintf(stderr, ERR_PRELOAD_FILE, filename);
return -1;
}