Start fvwm then switch to cwm, now execute the restart function.
Then fvwm is spawned. Well done.
That's because now argv[0] = fvwm.
I don't think fvwm needs to change, cwm has to.
We cannot use __progname 'cause it contains fvwm too.
My patch here is ugly, u_argv isn't portable anymore, it depends on cwm.
The fallback mechanism seems to work nevertheless.

(start twm then switch to cwm, execute restart and... it works!
I think that's because twm forks a new process each time you switch.
So if you switch 1 million times... Well, good luck with that.)

Index: util.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/util.c,v
retrieving revision 1.26
diff -u -p -u -p -r1.26 util.c
--- util.c      16 Apr 2020 17:12:49 -0000      1.26
+++ util.c      10 Dec 2022 12:53:18 -0000
@@ -94,13 +94,14 @@ u_argv(char * const *argv)
        if (argv == 0)
                return NULL;

-       for (i = 0; argv[i]; i++)
+       siz = strlen("cwm") + 1;
+       for (i = 1; argv[i]; i++)
                siz += strlen(argv[i]) + 1;
        if (siz == 0)
                return NULL;

        p = xmalloc(siz);
-       strlcpy(p, argv[0], siz);
+       strlcpy(p, "cwm", siz);
        for (i = 1; argv[i]; i++) {
                strlcat(p, " ", siz);
                strlcat(p, argv[i], siz);

Reply via email to