Index: xpriv.c ================================================================== --- xpriv.c +++ xpriv.c @@ -271,12 +271,11 @@ if (!(tmp = getenv("XDG_RUNTIME_DIR"))) if (!(tmp = getenv("TMPDIR"))) tmp = "/tmp"; size_t tmpsz = strlen(tmp); - char sockn[tmpsz + 1 + sizeof "ssh." - + 11]; + char* sockn = malloc(tmpsz + 1 + sizeof "ssh." + 11); strcpy(sockn, tmp); sockn[tmpsz] = '/'; strcpy(sockn+tmpsz+1,"ssh."); // first, gen a random identifier so we have the ability @@ -341,22 +340,23 @@ return ok; } enum res activate_window(Window w) { Display* dpy = XOpenDisplay(NULL); - XEvent ev; long mask = SubstructureRedirectMask | SubstructureNotifyMask; - ev.xclient.type = ClientMessage; - ev.xclient.serial = 0; - ev.xclient.send_event = True; - ev.xclient.message_type = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False); - ev.xclient.display = dpy; - ev.xclient.window = w; - ev.xclient.format = 32; - ev.xclient.data.l[0] = 2; - ev.xclient.data.l[1] = CurrentTime; - ev.xclient.data.l[2] = 0; + XEvent ev = { + .xclient.type = ClientMessage, + .xclient.serial = 0, + .xclient.send_event = True, + .xclient.message_type = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False), + .xclient.display = dpy, + .xclient.window = w, + .xclient.format = 32, + .xclient.data.l[0] = 2, + .xclient.data.l[1] = CurrentTime, + .xclient.data.l[2] = 0, + }; if(!XSendEvent(dpy, DefaultRootWindow(dpy), False, mask, &ev)) return fail_x11; XSync(dpy,false); return ok; @@ -426,16 +426,10 @@ args[argsz - 2] = init_named; } execvp("urxvtc", (char* const*)args); } else { - struct signal*s = shmlinux( - mmap(0, sizeof(struct signal), PROT_READ | PROT_WRITE, MAP_SHARED, shm, 0) - ) shmsysv ( - shmat(shm, 0, 0) - ); - struct shmid_ds stat; shmctl(shm, IPC_STAT, &stat); if (stat.shm_nattch == 0) { /* if the shm segment is not attached to any * process, it's a relic that needs to be @@ -444,10 +438,16 @@ * persistence mechanisms for shared mem, but * alas, as you already know, POSIX */ shmctl(shm, IPC_RMID, &stat); goto tryagain; } + + struct signal*s = shmlinux( + mmap(0, sizeof(struct signal), PROT_READ | PROT_WRITE, MAP_SHARED, shm, 0) + ) shmsysv ( + shmat(shm, 0, 0) + ); if (s == shmlinux(MAP_FAILED) shmsysv((void*)-1)) return bad(fail_mem); return bad(activate_window(s->wid)); }