summaryrefslogtreecommitdiffstats
path: root/st.c
diff options
context:
space:
mode:
Diffstat (limited to 'st.c')
-rw-r--r--st.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/st.c b/st.c
index 6195ea2..d45efa4 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);
@@ -1056,6 +1057,37 @@ tswapscreen(void)
}
void
+newterm(const Arg* a)
+{
+ int res;
+ switch (fork()) {
+ case -1:
+ die("fork failed: %s\n", strerror(errno));
+ break;
+ case 0:
+ switch (fork()) {
+ case -1:
+ die("fork failed: %s\n", strerror(errno));
+ break;
+ case 0:
+ res = chdir(getcwd_by_pid(pid));
+ execlp("st", "./st", NULL);
+ break;
+ default:
+ exit(0);
+ }
+ default:
+ wait(NULL);
+ }
+}
+
+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;