diff options
| author | Douglas B. Rumbaugh <doug@douglasrumbaugh.com> | 2022-12-31 17:21:08 -0500 |
|---|---|---|
| committer | Douglas B. Rumbaugh <doug@douglasrumbaugh.com> | 2022-12-31 17:21:08 -0500 |
| commit | b1df89ed947503c74a61f36a1b3a92f5f424352e (patch) | |
| tree | d3a529698171143929554aca7f150da242f52130 /st.c | |
| parent | 655ba6883b219befcc8aefdd6f50a4f678a7af98 (diff) | |
| download | st-b1df89ed947503c74a61f36a1b3a92f5f424352e.tar.gz | |
Applied plumber patch
Diffstat (limited to 'st.c')
| -rw-r--r-- | st.c | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -27,6 +27,9 @@ #elif defined(__FreeBSD__) || defined(__DragonFly__) #include <libutil.h> #endif +#if defined(__OpenBSD__) + #include <sys/sysctl.h> +#endif /* Arbitrary sizes */ #define UTF_INVALID 0xFFFD @@ -232,6 +235,22 @@ static const uchar utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8}; static const Rune utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000}; static const Rune utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF}; +int +subprocwd(char *path) +{ +#if defined(__linux) + if (snprintf(path, PATH_MAX, "/proc/%d/cwd", pid) < 0) + return -1; + return 0; +#elif defined(__OpenBSD__) + size_t sz = PATH_MAX; + int name[3] = {CTL_KERN, KERN_PROC_CWD, pid}; + if (sysctl(name, 3, path, &sz, 0, 0) == -1) + return -1; + return 0; +#endif +} + ssize_t xwrite(int fd, const char *s, size_t len) { @@ -803,7 +822,7 @@ ttynew(const char *line, char *cmd, const char *out, char **args) break; default: #ifdef __OpenBSD__ - if (pledge("stdio rpath tty proc", NULL) == -1) + if (pledge("stdio rpath tty proc ps exec", NULL) == -1) die("pledge\n"); #endif close(s); |