commit - 8064b84908439d34f2d8c11f09107d7e226d3809
commit + ea080950069d12713bf146472e18750210c4a24f
blob - 8a803f10ae2871a1068d20eb8d286357f2740cac
blob + c49aada1867eade200f189c326cbc652fdde5370
--- fs.c
+++ fs.c
static char lockfile_path[PATH_MAX];
static char bookmark_file[PATH_MAX];
static char known_hosts_file[PATH_MAX], known_hosts_tmp[PATH_MAX];
+static char crashed_file[PATH_MAX];
char session_file[PATH_MAX];
handle_dispatch_imsg(int fd, short ev, void *d)
{
struct imsgev *iev = d;
- dispatch_imsg(iev, ev, handlers, sizeof(handlers));
+ int e;
+
+ if (dispatch_imsg(iev, ev, handlers, sizeof(handlers)) == -1) {
+ /*
+ * This should leave a ~/.telescope/crashed file to
+ * trigger about:crash on next run. Unfortunately, if
+ * the main process dies the fs sticks around and
+ * doesn't notice that the fd was closed. Why EV_READ
+ * is not triggered when a fd is closed on the other end?
+ */
+ e = errno;
+ if ((fd = open(crashed_file, O_CREAT|O_TRUNC|O_WRONLY, 0600))
+ == -1)
+ err(1, "open");
+ close(fd);
+ errx(1, "connection closed: %s", strerror(e));
+ }
}
static int
strlcpy(session_file, getenv("HOME"), sizeof(session_file));
strlcat(session_file, "/.telescope/session", sizeof(session_file));
+ strlcpy(crashed_file, getenv("HOME"), sizeof(crashed_file));
+ strlcat(crashed_file, "/.telescope/crashed", sizeof(crashed_file));
+
return 1;
}
blob - e42024b1ac845d80b1ff160f43770ad712f73b9a
blob + 165dfe5ff526750c3ca47b1ab1d4f6b2ca5d1034
--- gemini.c
+++ gemini.c
handle_dispatch_imsg(int fd, short ev, void *d)
{
struct imsgev *iev = d;
- dispatch_imsg(iev, ev, handlers, sizeof(handlers));
+
+ if (dispatch_imsg(iev, ev, handlers, sizeof(handlers)) == -1)
+ err(1, "connection closed");
}
static int
blob - 06045f111b22cb336a414b93ebc84d74c367ccd0
blob + e01b03d74d63d9fee1f99ba2c2cfec45d0ec49fc
--- telescope.c
+++ telescope.c
handle_dispatch_imsg(int fd, short ev, void *d)
{
struct imsgev *iev = d;
- dispatch_imsg(iev, ev, handlers, sizeof(handlers));
+
+ if (dispatch_imsg(iev, ev, handlers, sizeof(handlers)) == -1)
+ err(1, "connection closed");
}
static void
blob - 0da6cb218cdd79482477250ca15f821435846658
blob + 3824cee6e40bdc431ec84e473727dc570b4738bb
--- telescope.h
+++ telescope.h
int has_prefix(const char*, const char*);
int unicode_isspace(uint32_t);
int unicode_isgraph(uint32_t);
-void dispatch_imsg(struct imsgev*, short, imsg_handlerfn**, size_t);
+int dispatch_imsg(struct imsgev *, short, imsg_handlerfn **, size_t);
int imsg_compose_event(struct imsgev *, uint16_t, uint32_t, pid_t, int, const void *, uint16_t);
/* wrap.c */
blob - 9d51f36474be436c2bd10eae4ecd1f741a37ebd8
blob + 6db63f66abf8ca343e535fd83df530d61fa67243
--- util.c
+++ util.c
event_add(&iev->ev, NULL);
}
-void
+int
dispatch_imsg(struct imsgev *iev, short event, imsg_handlerfn **handlers,
size_t size)
{
if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN)
err(1, "imsg_read error");
if (n == 0)
- err(1, "connection closed");
+ return -1;
}
if (event & EV_WRITE) {
if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
err(1, "msgbuf_write");
if (n == 0)
- err(1, "connection closed");
+ return -1;
}
for (;;) {
}
imsg_event_add(iev);
+ return 0;
}
int