Inter-process locking for log rotation

This pull request is actually addressing the same issue with https://github.com/ruby/ruby/pull/354. 

Current ruby's standard logger errors when we use it with log shifting in multi-process environments. Following is a code snippet to re-produce this problem. 

```ruby
require 'logger'
require 'parallel'

logger = Logger.new("/tmp/test.log", 3, 1024 * 10)
Parallel.map(['a', 'b'], :in_processes => 2) do |letter|
  300000.times do
    logger.info letter * 5000
  end
end
```

By executing this, logger errors like
```
log writing failed. closed stream
log shifting failed. closed stream
log writing failed. closed stream
log shifting failed. closed stream
...
```

Please read [my blog post](http://blog.livedoor.jp/sonots/archives/32645828.html) (Japanese) which I wrote before for more details.

This patch is to fix the issue using inter-process locking (flock). 

FYI: This patch is a port from ServerEngine's [DaemonLogger](https://github.com/frsyuki/serverengine/blob/master/lib/serverengine/daemon_logger.rb) which we worked for Fluentd. Please see https://github.com/frsyuki/serverengine/issues/9 about discussions on it. 

I also issued on bug the tracker https://bugs.ruby-lang.org/issues/9046