On Monday, August 4 at 01:54 PM, quoth Timo Sirainen:
On Thursday, July 24 at 03:05 AM, quoth Timo Sirainen:
- Added a new maildirlock utility for write-locking Dovecot Maildir.
Every time I attempt to use this (as root), it exits with a return code of 143 and my shell prints out "Terminated".
I'm guessing that what happens is a result of this:
/* locked - send a */ if (kill(parent_pid, SIGTERM) < 0) i_fatal("kill(parent, SIGTERM) failed: %m");
Any idea on how I can fix it?
Not really.. The parent PID should be the parent maildirlock process, which also should have caught the TERM signal. You could see what happens if you change all SIGTERMs to SIGHUPs for example. What shell do you use? Try another one?
I use bash. I tried using CSH and it does the same thing.
I tried recompiling it after replacing all instances of SIGTERM with SIGHUP, and instead of printing out "Terminated", it prints out "Hangup" (i.e. the same problem).
The issue, I think, is that maildirlock has a race condition. There is no guarantee that the parent has set up its signal handlers before the child gets around to killing it.
To demonstrate it, I modified the source to force the child to give the parent some time, like this:
if (pid != 0) {
io_loop_run(ioloop);
if (!success)
return 1;
printf("%s", dec2str(pid));
return 0;
} else {
sleep(1);
}
And that fixed the problem. Now, telling the child to sleep is obviously an unacceptable solution.
I think signals are probably a bad way of handling this inter-process communication. How about using a pipe? I've attached a patch that seems to work.
~Kyle
Time is an illusion. Lunchtime doubly so. -- Douglas Adams