aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
Diffstat (limited to 'st.c')
-rw-r--r--st.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/st.c b/st.c
index 248728f..46e9f32 100644
--- a/st.c
+++ b/st.c
@@ -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;