Running only one instance of the app

Bagomot bagomot at gmail.com
Thu Dec 2 14:15:14 UTC 2021


On Thursday, 2 December 2021 at 13:28:12 UTC, Steven 
Schveighoffer wrote:
> On 12/2/21 7:05 AM, Bagomot wrote:
>
>> This works for Windows. I need something similar for Linux and 
>> Macos.
>> 
>> Tell me how, if you know. Maybe the standard library D already 
>> has the required functionality? Or are there better ways to 
>> only run one instance of the app?
>
> Typically this is done using pid files.
>
> https://linux.die.net/man/3/pidfile
>
> But I don't know if MacOS has a specialized call for it, or if 
> you have to do it yourself. I think you need to lock the file 
> with `flock` to get it to work properly.
>
> -Steve

I can't use flock, because my app uses the file rename to 
auto-update in Windows. It renames itself to old.app.exe, 
downloads the new version and runs it, then exits. I haven’t 
figured out how to do this in other OSs yet.


More information about the Digitalmars-d-learn mailing list