Skip to content

Commit 6d61110

Browse files
committed
fix(file): Fix file descriptor leak in file.sync
Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
1 parent 3820fc5 commit 6d61110

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

file.lua

+5-7
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
-- Author: Jianhui Zhao <zhaojh329@gmail.com>
33

44
local file = require 'eco.core.file'
5-
local sys = require 'eco.core.sys'
65
local time = require 'eco.time'
6+
local sys = require 'eco.sys'
77

88
local M = {}
99

@@ -69,15 +69,13 @@ function M.flock(fd, operation, timeout)
6969
end
7070
end
7171

72-
function M.sync()
73-
local pid, err = sys.exec('sync')
74-
if not pid then
72+
function M.sync(timeout)
73+
local p, err = sys.exec('sync')
74+
if not p then
7575
return nil, err
7676
end
7777

78-
eco.watcher(eco.CHILD, pid):wait()
79-
80-
return true
78+
return p:wait(timeout)
8179
end
8280

8381
local inotify_methods = {}

0 commit comments

Comments
 (0)