http://qs321.pair.com?node_id=11128670


in reply to Semaphore puzzle

The race condition is not that the second process doesn't detect the creation. It in fact runs the check before the first process has created the semaphore, but after it checked its existence (and didn't find it). You need to create the semaphore right ahead, if the creation failed, you know you are the second one.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]