commit 840c16f685ca8f617270f33af0525ae7bff5adc1 from: Alexander Arkhipov date: Tue May 30 10:25:24 2023 UTC pledge after XOpenDisplay commit - 703f0cd0ff2254a2ef0cce93f5e372eb21f40870 commit + 840c16f685ca8f617270f33af0525ae7bff5adc1 blob - f67a5b0a6cc854b0d52a66c6a1fcef8c199648d4 blob + a280019360db62b26e5dc841f132285d69717351 --- xitems.c +++ xitems.c @@ -31,7 +31,24 @@ usage(void) /* die -- print formatted string, and exit with the status eval. */ static void die(int eval, const char *fmt, ...) +{ + fputs(PROGNAME ": ", stderr); + if (fmt) { + va_list argp; + va_start(argp, fmt); + vfprintf(stderr, fmt, argp); + va_end(argp); + } + fputc('\n', stderr); + exit(eval); +} + +/* edie -- same as die(), but also output a message via strerror(). */ +static void +edie(int eval, const char *fmt, ...) { + int xerrno = errno; + fputs(PROGNAME ": ", stderr); if (fmt) { va_list argp; @@ -39,6 +56,8 @@ die(int eval, const char *fmt, ...) vfprintf(stderr, fmt, argp); va_end(argp); } + fprintf(stderr, ": %s", strerror(xerrno)); + fputc('\n', stderr); exit(eval); } @@ -707,6 +726,13 @@ main(int argc, char *argv[]) if (!(dpy = XOpenDisplay(NULL))) die(1, "couldn't open display"); + +#ifdef __OpenBSD__ + /* Xlib needs rpath at runtime. */ + if (pledge("stdio rpath", NULL) == -1) + edie(1, "pledge"); +#endif + screen = DefaultScreen(dpy); if (!o_bg)