0

I have imapfilter on a cronjob. Since the relevant Exchange server supports IDLE, I write a PID file on launch. The config file checks if the process is alive, and if it is quits, otherwise it updates the PID file.

I now want to make imapfilter restart on configuration changes. All I need to do is checksum the current configuration file every once in a while, and if it changes... well, what then?

I could just quit and wait for cron to bring the process back up, but that doesn't help me when tweaking the rules.

I'd rather use something like exec(3), but it is most likely that I cannot do the necessary cleanup from a mere configuration file. Also I have no idea how to actually call exec from Lua; all Google searches point to os.execute(), which waits for the child process to quit.

Is there a saner approach to cause the process to restart? Portability is not a concern, sorry.

Community
  • 1
  • 1
badp
  • 11,409
  • 3
  • 61
  • 89
  • Your question is very specific to the mentioned software "imapfilter". It heavily depends on how well imapfilter handles system interrupts and what scripts it installs, which distribution you use, etc. – dualed Mar 04 '16 at 10:40
  • @dualed yes, I think that's fair to say. So? :) the so-called configuration files still are actual lua code. – badp Mar 04 '16 at 16:53
  • But we know nothing about the implementation details, which Lua version, what modules are available, the internal API of imapfilter, still nothing about the distro, or whether imapfilter even supports IDLE. What I mean is that you're better off asking the developer – dualed Mar 05 '16 at 23:05
  • If the environment matters so much — it's my first experience with lua — it's whatever you get when you `sudo apt install imapfilter` on Ubuntu 15.10 – badp Mar 05 '16 at 23:10

0 Answers0