Advertisement
Guest User

File.open

a guest
Aug 19th, 2016
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.22 KB | None | 0 0
  1. begin
  2. File.open(PID_FILE, ::File::CREAT | ::File::EXCL | ::File::WRONLY){|f| f.write("#{Process.pid}") }
  3. at_exit { File.delete(PID_FILE) if File.exists?(PID_FILE) }
  4. rescue Errno::EEXIST
  5. check_pid
  6. retry
  7. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement