diff options
author | Mateja <mail@matejamaric.com> | 2021-04-08 15:50:34 +0200 |
---|---|---|
committer | Mateja <mail@matejamaric.com> | 2021-04-08 15:50:34 +0200 |
commit | dc273f41c5d548026b4bea766c919f1e4e8a04ac (patch) | |
tree | 2d4f157915a660d0f7cf6e181496e466b2a8211b /st.c | |
parent | 081aa95b38c53b5a9ea47907496e0ff043fdffe3 (diff) | |
download | st-dc273f41c5d548026b4bea766c919f1e4e8a04ac.tar.gz st-dc273f41c5d548026b4bea766c919f1e4e8a04ac.zip |
Applied `newterm` patch.v1.2.0
Diffstat (limited to 'st.c')
-rw-r--r-- | st.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -153,6 +153,7 @@ typedef struct { } STREscape; static void execsh(char *, char **); +static char *getcwd_by_pid(pid_t pid); static void stty(char **); static void sigchld(int); static void ttywriteraw(const char *, size_t); @@ -1059,6 +1060,26 @@ tswapscreen(void) } void +newterm(const Arg* a) +{ + switch (fork()) { + case -1: + die("fork failed: %s\n", strerror(errno)); + break; + case 0: + chdir(getcwd_by_pid(pid)); + execlp("st", "./st", NULL); + break; + } +} + +static char *getcwd_by_pid(pid_t pid) { + char buf[32]; + snprintf(buf, sizeof buf, "/proc/%d/cwd", pid); + return realpath(buf, NULL); +} + +void tscrolldown(int orig, int n) { int i; |