summary refs log tree commit diff
path: root/calmwm.c
diff options
context:
space:
mode:
authorokan <okan>2015-09-16 17:58:25 +0000
committerokan <okan>2015-09-16 17:58:25 +0000
commit0fdcf3f3dfd336e7593482286dff49cd8be6ce44 (patch)
tree93ef81d5c129af3aeae6650297f0276300882818 /calmwm.c
parent47a10cc05549b0a94e3606ca7be9fe626754d12d (diff)
downloadcwm-0fdcf3f3dfd336e7593482286dff49cd8be6ce44.tar.gz
cwm-0fdcf3f3dfd336e7593482286dff49cd8be6ce44.tar.xz
cwm-0fdcf3f3dfd336e7593482286dff49cd8be6ce44.zip
On execwm, we should properly release resources before exec'ing into a
new window manager; so allow CWM_EXEC_WM to assign new wm to wm_argv and
pass through cwm_status (now EXECWM) so that x_teardown() gets called
before exec'ing the new window manager.  Removes the need for a separate
x_restart() now, using new wm_argv; and consolidates errno for execvp.
Diffstat (limited to 'calmwm.c')
-rw-r--r--calmwm.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/calmwm.c b/calmwm.c
index 2fc0a4f..0166c06 100644
--- a/calmwm.c
+++ b/calmwm.c
@@ -46,12 +46,12 @@ struct screen_ctx_q		 Screenq = TAILQ_HEAD_INITIALIZER(Screenq);
 int				 HasRandr, Randr_ev;
 struct conf			 Conf;
 const char			*homedir;
+char				*wm_argv;
 volatile sig_atomic_t		 cwm_status;
 
 static void	sighdlr(int);
 static int	x_errorhandler(Display *, XErrorEvent *);
 static void	x_init(const char *);
-static void	x_restart(char **);
 static void	x_teardown(void);
 static int	x_wmerrorhandler(Display *, XErrorEvent *);
 
@@ -60,7 +60,6 @@ main(int argc, char **argv)
 {
 	const char	*conf_file = NULL;
 	char		*conf_path, *display_name = NULL;
-	char		**cwm_argv;
 	int		 ch;
 	struct passwd	*pw;
 
@@ -68,7 +67,7 @@ main(int argc, char **argv)
 		warnx("no locale support");
 	mbtowc(NULL, NULL, MB_CUR_MAX);
 
-	cwm_argv = argv;
+	wm_argv = u_argv(argv);
 	while ((ch = getopt(argc, argv, "c:d:")) != -1) {
 		switch (ch) {
 		case 'c':
@@ -117,8 +116,8 @@ main(int argc, char **argv)
 	while (cwm_status == CWM_RUNNING)
 		xev_process();
 	x_teardown();
-	if (cwm_status == CWM_RESTART)
-		x_restart(cwm_argv);
+	if (cwm_status == CWM_EXECWM)
+		u_exec(wm_argv);
 
 	return(0);
 }
@@ -146,13 +145,6 @@ x_init(const char *dpyname)
 }
 
 static void
-x_restart(char **args)
-{
-	(void)setsid();
-	(void)execvp(args[0], args);
-}
-
-static void
 x_teardown(void)
 {
 	struct screen_ctx	*sc;