npc(1): adds pledge(2) support
This commit is contained in:
parent
851f729ebd
commit
72ef8d00bc
20
src/npc.c
20
src/npc.c
@ -19,8 +19,13 @@
|
||||
|
||||
#include <stdio.h> /* fprintf(3), fputs(3), getc(3), perror(3), putc(3), stdin,
|
||||
* stdout, EOF */
|
||||
#include <sysexits.h> /* EX_IOERR, EX_OK, EX_USAGE */
|
||||
#include <unistd.h> /* getopt(3) */
|
||||
#include <sysexits.h> /* EX_IOERR, EX_OK, EX_OSERR, EX_USAGE */
|
||||
#include <unistd.h> /* pledge(2), getopt(3) */
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
# include <errno.h> /* errno */
|
||||
# include <string.h> /* strerror(3) */
|
||||
#endif
|
||||
|
||||
char *program_name = "npc";
|
||||
|
||||
@ -39,13 +44,22 @@ usage(char *argv0) {
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
#ifdef __OpenBSD__
|
||||
program_name = argv[0] == NULL ? program_name : argv[0];
|
||||
|
||||
if (pledge("stdio", NULL) == -1) {
|
||||
(void)fprintf(stderr, "%s: %s\n", program_name, strerror(errno));
|
||||
return EX_OSERR;
|
||||
}
|
||||
#endif
|
||||
int c;
|
||||
char showend = 0; /* print a dollar sign before each newline */
|
||||
char showtab = 0; /* prints tab characters in caret notation */
|
||||
|
||||
if (argc > 0) {
|
||||
#ifndef __OpenBSD__
|
||||
program_name = argv[0];
|
||||
|
||||
#endif
|
||||
while ((c = getopt(argc, argv, "et")) != -1) {
|
||||
switch (c){
|
||||
case 'e': showend = 1; break;
|
||||
|
Loading…
Reference in New Issue
Block a user