Questions tagged [concurrency]

79 questions
41
votes
4 answers

How to launch a set of program inside tmux or gnome-terminal within a script?

I wanted to launch a few commands simultaneously in tmux or gnome-terminal or xfterminal , every different tab with a single command running , and close that tab when that command finishes. Any other software is welcomed as well I wanted to issue a…
daisy
  • 53,527
  • 78
  • 236
  • 383
28
votes
1 answer

cannot create regular file 'filename': File exists

I've been getting this strange error message in one of my build scripts - cp fails, returning the error "File exists". I've even tried using cp -f, which should overwrite the file if it exists, but the error still shows up. Running cp to overwrite…
lutzky
  • 881
  • 1
  • 8
  • 9
23
votes
4 answers

tee + cat: use an output several times and then concatenate results

If I call some command, for instance an echo I can use the results from that command in several other commands with tee. Example: echo "Hello world!" | tee >(command1) >(command2) >(command3) With cat I can collect the results of several commands.…
Trylks
  • 383
  • 1
  • 2
  • 9
22
votes
1 answer

Is using rsync while source is being updated safe?

Is it safe to use rsync when the source filesystem is mounted and writeable, assuming that it may very well be modified while rsync is running? I presume that under race conditions I may not get the latest modifications, but is there any risk of…
brianmearns
  • 654
  • 1
  • 8
  • 16
17
votes
2 answers

How do you make a cross-process locking in Linux (C/C++)?

I need to make sure one process executes only in one instance at a time. On Windows you could use named mutex. But I have no idea what to use on Linux. I think I've seen an approach were app creates an exclusive file, but I can't find it anymore. Do…
Coder
  • 457
  • 2
  • 6
  • 10
14
votes
4 answers

How to atomically allocate a loop device?

I am writing some shell scripts to handle some disk image stuff, and I need to use loop devices to access some disk images. However, I am not sure how to properly allocate a loop device without exposing my program to a race condition. I know that I…
AJMansfield
  • 834
  • 1
  • 10
  • 20
13
votes
2 answers

communication between multiple processes

I have a bash script, which runs manager() function as a separate process for x-times. How is it possible to forward messages to all manager() processes from within the script? I've read about anonymous pipes but I have no idea how to share the…
all jazz
  • 255
  • 3
  • 6
12
votes
2 answers

Concurrent writing to a log file from many processes

In mimicing MacOS's terminal's open command or Window's terminal's start, the comments of this answer suggest appending stdout and stderr to ~/.xsession-errors, something like (bash): alias open='&>>~/.xsession-errors xdg-open' The issue I forsee…
Tom Hale
  • 28,728
  • 32
  • 139
  • 229
11
votes
3 answers

Why do package managers need lock files?

dpkg uses a lock file (/var/lib/dpkg/lock), when in use. Why are these lockfiles needed? Why are multiple instances not possible?
acisoal
  • 111
  • 3
10
votes
2 answers

How bash treats "> >()"

While experimenting with output redirection and process substitution I stumbled upon the following command and its resulting output: me@elem:~$ echo foo > >(cat); echo bar bar me@elem:~$ foo (Yes, that empty newline at the end is…
Stanley Yu
  • 613
  • 1
  • 5
  • 14
10
votes
1 answer

Moving a file to a file that is being read

When a file is moved and the destination file already exists and is currently being read, will the operation succeed? Will it depend on how long the reading operation on the destination file lasts?
Desmond Hume
  • 2,718
  • 5
  • 21
  • 21
8
votes
2 answers

How to run multiple processes and exit if any of them exits or fails

I am running multiple processes and want to exit with the appropriate exit code (this means error on failure, success otherwise) if any of them fails or exists. Additionally if any child process exits or fails, any other child processes should also…
Olivenbaum
  • 181
  • 1
  • 3
7
votes
1 answer

What's the use dirsync option for mount?

Today I stumbled upon this mount's option: dirsync All directory updates within the filesystem should be done synchronously. This affects the following system calls: creat, link, unlink, symlink, mkdir, rmdir, mknod and rename. What are…
Petr
  • 1,624
  • 2
  • 19
  • 35
7
votes
1 answer

Multiple appenders writing to the same file on NFS share

If I have 100 servers execute a command, and each redirects their output to the same file on an NFS share, will the resultant file be interleaved neatly or can it become corrupt? For example, if this command was executed on 100 servers: find / type…
Fidel
  • 405
  • 6
  • 14
7
votes
2 answers

Delete file while it is in use

I have a process that receives a video file (RAW) and transcodes it with FFMPEG generating three (different resolutions) resultant files. I'm using a distributed task queue system (Celery) to process every process from FFMPEG in a different…
Mauro Baraldi
  • 213
  • 2
  • 3
  • 6
1
2 3 4 5 6