0

I know very universal solution to create come file of FS that indicate that app is working. But is there any better solution?

I need to prevent running of multiple copy of my app. Is there any D-ish way?

Dmitry Bubnenkov
  • 9,415
  • 19
  • 85
  • 145
  • 1
    https://stackoverflow.com/questions/171213/how-to-block-running-two-instances-of-the-same-program – Piotr Reszke Dec 10 '17 at 18:28
  • Possible duplicate of [How to block running two instances of the same program?](https://stackoverflow.com/questions/171213/how-to-block-running-two-instances-of-the-same-program) – WebFreak001 Dec 10 '17 at 18:57
  • C++ is good, but I am looking for any D solutions\examples... – Dmitry Bubnenkov Dec 10 '17 at 19:00
  • 2
    Why do you need to do it? If it is because of some shared resource, you can check a lock on that resource, for example. But yeah translating the C++ answers to D is usually trivial and is what I'd suggest... well, if you REALLY must do this at all. I loathe and despise programs that don't let me run multiple copies without very good reason. – Adam D. Ruppe Dec 10 '17 at 19:28
  • I want to do app that connect to DB and load some data to it by cron. But when first app still is working second copy maybe run. I want to prevent it. – Dmitry Bubnenkov Dec 18 '17 at 08:00
  • In addition to what @AdamD.Ruppe said, you can even manage this outside your program, and use things like the `flock` utility to make sure CRON itself doesn't run two of the same process http://www.tutorialspoint.com/unix_commands/flock.htm – Lee Avital Dec 25 '17 at 17:21

0 Answers0