Skip to content

Commit

Permalink
fix(file): Fix file descriptor leak in file.sync
Browse files Browse the repository at this point in the history
Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
  • Loading branch information
zhaojh329 committed Nov 27, 2024
1 parent 3820fc5 commit 6d61110
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
-- Author: Jianhui Zhao <zhaojh329@gmail.com>

local file = require 'eco.core.file'
local sys = require 'eco.core.sys'
local time = require 'eco.time'
local sys = require 'eco.sys'

local M = {}

Expand Down Expand Up @@ -69,15 +69,13 @@ function M.flock(fd, operation, timeout)
end
end

function M.sync()
local pid, err = sys.exec('sync')
if not pid then
function M.sync(timeout)
local p, err = sys.exec('sync')
if not p then
return nil, err
end

eco.watcher(eco.CHILD, pid):wait()

return true
return p:wait(timeout)
end

local inotify_methods = {}
Expand Down

0 comments on commit 6d61110

Please sign in to comment.