Created
December 8, 2016 03:31
-
-
Save jayeye/827a93f191b2da76aab859fa4c8bef3e to your computer and use it in GitHub Desktop.
Save buffers of a detached or otherwise inaccessible emacs process.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <err.h> | |
#include <fcntl.h> | |
#include <sys/ioctl.h> | |
#include <termios.h> | |
const char* const kJesusSaves = "\025\033xsave-buffers-kill-emacs\n"; | |
int main(int argc, char* argv[]) { | |
int fd = open(argv[1], O_WRONLY); | |
if (fd < 0) { | |
err(1, "open"); | |
} | |
for (const char* c = kJesusSaves; *c; ++c) { | |
if (ioctl(fd, TIOCSTI, c) < 0) { | |
err(1, "TIOCSTI"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment