I do not know D, but I use the mutex file to complete the task. Here is some pseudo code that might come in handy:
do {
mutex = create_file_for_writing('lock_file');
} while (mutex == null);
log_file = open_file_for_reading('the_log_file');
write(log_file, data);
close_file(log_file);
close_file(mutex);
delete_file(mutex);
So, all processes will try to create a mutex file, but only the one who wins will be able to continue. When you write your output, close and delete the mutexes so that other processes can do the same.
source
share