maildirlock.c revision 361d4380f3a6e95fc680400381ac57eb60e44367
/* Copyright (c) 2008-2009 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "lib-signals.h"
#include "ioloop.h"
#include "write-full.h"
#include "file-dotlock.h"
#include "index/maildir/maildir-uidlist.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
static struct dotlock_settings dotlock_settings = {
};
{
}
{
}
{
unsigned int timeout;
char c;
if (argc != 3) {
" - SIGTERM will release the lock.\n");
return 1;
}
parent_pid = getpid();
return 1;
}
return 1;
}
/* call lib_init() only after fork so that PID gets set correctly */
lib_init();
ioloop = io_loop_create();
if (pid != 0) {
if (ret < 0) {
i_error("read(pipe) failed: %m");
return 1;
}
if (ret != 1) {
/* locking timed out */
return 1;
}
return 0;
}
/* child process - stdout has to be closed so that caller knows when
to stop reading it. */
return 1;
/* locked - send a byte */
i_fatal("write(pipe) failed: %m");
lib_deinit();
return 0;
}