[hackers] [wmii] Added an exec command to /ctl

From: Kris Maglione <jg_AT_suckless.org>
Date: Thu Mar 15 22:41:33 2007

changeset: 2017:850990f7c859
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Thu Mar 15 17:36:21 2007 -0400
summary: Added an exec command to /ctl

diff -r 15028e842f65 -r 850990f7c859 fs.c
--- a/fs.c Thu Mar 15 15:38:18 2007 -0400
+++ b/fs.c Thu Mar 15 17:36:21 2007 -0400
@@ -236,6 +236,10 @@ message_root(char *message)
         }
         if(!strcmp(message, "quit "))
                 srv.running = 0;
+ else if(!strncmp(message, "exec ", 5)) {
+ srv.running = 0;
+ execstr = strdup(&message[5]);
+ }
         else if(!strncmp(message, "view ", 5))
                 select_view(&message[5]);
         else if(!strncmp(message, "selcolors ", 10)) {
diff -r 15028e842f65 -r 850990f7c859 main.c
--- a/main.c Thu Mar 15 15:38:18 2007 -0400
+++ b/main.c Thu Mar 15 17:36:21 2007 -0400
@@ -23,6 +23,7 @@ static int (*x_error_handler) (Display *
 static int (*x_error_handler) (Display *, XErrorEvent *);
 static char version[] = "wmiiwm - " VERSION ", (C)opyright MMVI-MMVII Kris Maglione\n";
 static struct sigaction sa;
+static int sleeperfd;
 
 static void
 usage() {
@@ -217,6 +218,7 @@ init_traps() {
                 fatal("Can't fork(): %s\n", strerror(errno));
         default:
                 close(fd[0]);
+ sleeperfd = fd[1];
                 sa.sa_flags = 0;
                 sa.sa_handler = cleanup_handler;
                 sigaction(SIGINT, &sa, nil);
@@ -507,6 +509,9 @@ main(int argc, char *argv[]) {
         cleanup();
         XCloseDisplay(blz.dpy);
         ixp_server_close(&srv);
+ close(sleeperfd);
+ if(execstr)
+ execl("/bin/sh", "sh", "-c", execstr, nil);
         if(errstr)
                 return 1;
         return 0;
diff -r 15028e842f65 -r 850990f7c859 wmii.h
--- a/wmii.h Thu Mar 15 15:38:18 2007 -0400
+++ b/wmii.h Thu Mar 15 17:36:21 2007 -0400
@@ -269,6 +269,7 @@ void (*handler[LASTEvent]) (XEvent *);
 /* Misc */
 Bool starting;
 Bool verbose;
+char *execstr;
 
 /* wm.c */
 char *message_root(char *message);
Received on Thu Mar 15 2007 - 22:41:33 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:56:18 UTC