assert is not async-signal-safe.
In practice the effect of calling assert there is that if the
assertion fails we might get a secondary crash, or other undesirable
behaviour from stdio (which is how assert usually reports failures).
Mention in a comment in libxl__self_pipe_wakeup that it has to be
async-signal-safe.
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
int libxl__self_pipe_wakeup(int fd)
{
+ /* Called from signal handlers, so needs to be async-signal-safe */
static const char buf[1] = "";
for (;;) {
assert(r==-1);
if (errno == EINTR) continue;
if (errno == EWOULDBLOCK) return 0;
- assert(errno);
+ if (!errno) abort();
return errno;
}
}
LIBXL_LIST_FOREACH(notify, &sigchld_users, sigchld_users_entry) {
int e = libxl__self_pipe_wakeup(notify->sigchld_selfpipe[1]);
- assert(!e); /* errors are probably EBADF, very bad */
+ if (e) abort(); /* errors are probably EBADF, very bad */
}
r = pthread_mutex_unlock(&sigchld_defer_mutex);
int esave = errno;
int r = dup2(unwriteable_fd, io_fd);
- assert(r == io_fd); /* if not we can't write an xtl message because we
- * might end up interleaving on our control stream */
+ if (r != io_fd)
+ /* we can't write an xtl message because we might end up
+ * interleaving on our control stream; we can't use stdio
+ * because it's not async-signal-safe */
+ abort();
errno = esave;
}