bf54fbed126ec3d459af40ea370ffadacd31c76dJakub Hrozek/* Copyright (c) 2001-2018 Dovecot authors, see the included COPYING file */
bf54fbed126ec3d459af40ea370ffadacd31c76dJakub Hrozek/* Mainly for including the full version information in core dumps.
bf54fbed126ec3d459af40ea370ffadacd31c76dJakub Hrozek NOTE: Don't set this const - otherwise it won't end up in core dumps. */
bf54fbed126ec3d459af40ea370ffadacd31c76dJakub Hrozekstatic ARRAY(struct atexit_callback) atexit_callbacks = ARRAY_INIT;
bf54fbed126ec3d459af40ea370ffadacd31c76dJakub Hrozekint i_unlink(const char *path, const char *source_fname,
bf54fbed126ec3d459af40ea370ffadacd31c76dJakub Hrozekint i_unlink_if_exists(const char *path, const char *source_fname,
2b84054e2f9fa7301af4dbef4dcbf1cba066ecb3Lukas Slebodnik /* a) for subcommands allow -options anywhere in command line
2b84054e2f9fa7301af4dbef4dcbf1cba066ecb3Lukas Slebodnik b) this is actually required for the reset to work (glibc bug?) */
2b84054e2f9fa7301af4dbef4dcbf1cba066ecb3Lukas Slebodnikvoid lib_atexit(lib_atexit_callback_t *callback)
bf54fbed126ec3d459af40ea370ffadacd31c76dJakub Hrozekvoid lib_atexit_priority(lib_atexit_callback_t *callback, int priority)
bf54fbed126ec3d459af40ea370ffadacd31c76dJakub Hrozek /* skip if it's already added */
bf54fbed126ec3d459af40ea370ffadacd31c76dJakub Hrozek callbacks = array_get(&atexit_callbacks, &count);
bf54fbed126ec3d459af40ea370ffadacd31c76dJakub Hrozek for (i = count; i > 0; i--) {
bf54fbed126ec3d459af40ea370ffadacd31c76dJakub Hrozekstatic int atexit_callback_priority_cmp(const struct atexit_callback *cb1,
bf54fbed126ec3d459af40ea370ffadacd31c76dJakub Hrozek array_sort(&atexit_callbacks, atexit_callback_priority_cmp);
bf54fbed126ec3d459af40ea370ffadacd31c76dJakub Hrozek /* Make sure stdin, stdout and stderr fds exist. We especially rely on
bf54fbed126ec3d459af40ea370ffadacd31c76dJakub Hrozek stderr being available and a lot of code doesn't like fd being 0.
bf54fbed126ec3d459af40ea370ffadacd31c76dJakub Hrozek We'll open /dev/null as write-only also for stdin, since if any
bf54fbed126ec3d459af40ea370ffadacd31c76dJakub Hrozek reads are attempted from it we'll want them to fail. */
bf54fbed126ec3d459af40ea370ffadacd31c76dJakub Hrozek /* close the actual /dev/null fd on exec*(), but keep it in stdio fds */