newterm: dwm swallow compatibility
There is a compatibility issue between the dwm swallow patch and the newterm patch for st. The swallow patch identifies the terminal client to substitute by traversing the process tree checking if the new window is a descendant of a terminal client. The newterm patch for st spawns a new terminal that is a descendant of the parent st process. This can lead to situations where the swallow patch ends up replacing the wrong terminal window. Changed the forking mechanism to do a double fork and letting the first one die. This is a technique commonly used by daemons to spawn new orphan processes.
This commit is contained in:
parent
ee4cdc8d6e
commit
04a194c013
|
@ -2,6 +2,11 @@ void
|
||||||
newterm(const Arg* a)
|
newterm(const Arg* a)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
switch (fork()) {
|
||||||
|
case -1:
|
||||||
|
die("fork failed: %s\n", strerror(errno));
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
switch (fork()) {
|
switch (fork()) {
|
||||||
case -1:
|
case -1:
|
||||||
die("fork failed: %s\n", strerror(errno));
|
die("fork failed: %s\n", strerror(errno));
|
||||||
|
@ -10,6 +15,11 @@ newterm(const Arg* a)
|
||||||
res = chdir(getcwd_by_pid(pid));
|
res = chdir(getcwd_by_pid(pid));
|
||||||
execlp("st", "./st", NULL);
|
execlp("st", "./st", NULL);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
wait(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue