mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
cvsimport
* refs/heads/master: Only when mapping clients from an initial wm start or restart, query the pointer and if it matches the child window, activate it; new clients will not need to make this roundtrip to the server. 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.
This commit is contained in:
32
util.c
32
util.c
@ -31,15 +31,12 @@
|
||||
|
||||
#include "calmwm.h"
|
||||
|
||||
#define MAXARGLEN 20
|
||||
|
||||
void
|
||||
u_spawn(char *argstr)
|
||||
{
|
||||
switch (fork()) {
|
||||
case 0:
|
||||
u_exec(argstr);
|
||||
err(1, "%s", argstr);
|
||||
break;
|
||||
case -1:
|
||||
warn("fork");
|
||||
@ -51,8 +48,10 @@ u_spawn(char *argstr)
|
||||
void
|
||||
u_exec(char *argstr)
|
||||
{
|
||||
#define MAXARGLEN 20
|
||||
char *args[MAXARGLEN], **ap = args;
|
||||
char **end = &args[MAXARGLEN - 1], *tmp;
|
||||
char *s = argstr;
|
||||
|
||||
while (ap < end && (*ap = strsep(&argstr, " \t")) != NULL) {
|
||||
if (**ap == '\0')
|
||||
@ -75,8 +74,33 @@ u_exec(char *argstr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*ap = NULL;
|
||||
|
||||
(void)setsid();
|
||||
(void)execvp(args[0], args);
|
||||
err(1, "%s", s);
|
||||
}
|
||||
|
||||
char *
|
||||
u_argv(char * const *argv)
|
||||
{
|
||||
size_t siz = 0;
|
||||
int i;
|
||||
char *p;
|
||||
|
||||
if (argv == 0)
|
||||
return(NULL);
|
||||
|
||||
for (i = 0; argv[i]; i++)
|
||||
siz += strlen(argv[i]) + 1;
|
||||
if (siz == 0)
|
||||
return(NULL);
|
||||
|
||||
p = xmalloc(siz);
|
||||
strlcpy(p, argv[0], siz);
|
||||
for (i = 1; argv[i]; i++) {
|
||||
strlcat(p, " ", siz);
|
||||
strlcat(p, argv[i], siz);
|
||||
}
|
||||
return(p);
|
||||
}
|
||||
|
Reference in New Issue
Block a user