sysctl: use - for stdin

This commit is contained in:
albert 2006-06-24 21:17:51 +00:00
parent 47d33e7ed4
commit a791f8034f
3 changed files with 9 additions and 2 deletions

3
NEWS
View File

@ -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

View File

@ -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.

View File

@ -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;
}