diff options
author | 2017-11-29 14:34:17 +0000 | |
---|---|---|
committer | 2017-11-29 14:34:17 +0000 | |
commit | e351538e709c2f56c32d960961dc8c139157f80f (patch) | |
tree | 2cf14f59019e5fa809a94aaeac7c23290a3760a6 | |
parent | fix decl of main (diff) | |
download | wireguard-openbsd-e351538e709c2f56c32d960961dc8c139157f80f.tar.xz wireguard-openbsd-e351538e709c2f56c32d960961dc8c139157f80f.zip |
Pledge can be done earlier; from kshe
-rw-r--r-- | usr.bin/dc/dc.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.bin/dc/dc.c b/usr.bin/dc/dc.c index 38887007669..e2c5461b9d4 100644 --- a/usr.bin/dc/dc.c +++ b/usr.bin/dc/dc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dc.c,v 1.18 2016/07/17 17:30:47 otto Exp $ */ +/* $OpenBSD: dc.c,v 1.19 2017/11/29 14:34:17 otto Exp $ */ /* * Copyright (c) 2003, Otto Moerbeek <otto@drijf.net> @@ -72,6 +72,11 @@ dc_main(int argc, char *argv[]) argc -= optind; argv += optind; + if (argc == 0) { + if (pledge("stdio", NULL) == -1) + err(1, "pledge"); + } + init_bmachine(extended_regs); (void)setvbuf(stdout, NULL, _IOLBF, 0); (void)setvbuf(stderr, NULL, _IOLBF, 0); @@ -109,9 +114,6 @@ dc_main(int argc, char *argv[]) return (0); } - if (pledge("stdio", NULL) == -1) - err(1, "pledge"); - src_setstream(&src, stdin); reset_bmachine(&src); eval(); |