On Mon, Oct 12, 2020 at 04:19:37PM +0800, Cao Xueliang wrote:
On Mon, Oct 12, 2020 at 09:47:16AM +0800, Li Yuanchao wrote:
when use system() or %x() call shell command git, there would be a new child process to do git command. And it seems the child process doesn't clear everytime when it's finished. It needs to be waited by parent process.
But it often comes out 'no child' error when wait in main thread, so I trap SIGCHLD to SIG_IGN, and the init process will handle it.
Signed-off-by: Li Yuanchao lyc163mail@163.com
lib/git_mirror.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/git_mirror.rb b/lib/git_mirror.rb index 88a94ac..0420c10 100644 --- a/lib/git_mirror.rb +++ b/lib/git_mirror.rb @@ -46,7 +46,7 @@ class GitMirror def git_fetch(mirror_dir) fetch_info = %x(git -C #{mirror_dir} fetch 2>&1) # Check whether mirror_dir is a good git repository by 3 conditions. If not, delete it.
Need change or delete the comment.
Yes, thanks
- if ($CHILD_STATUS.exitstatus == ERR_CODE) && fetch_info.include?(ERR_MESSAGE) && Dir.empty?(mirror_dir)
- if fetch_info.include?(ERR_MESSAGE) && Dir.empty?(mirror_dir) FileUtils.rmdir(mirror_dir) end return fetch_info.include? '->'
@@ -89,6 +89,7 @@ class MirrorMain connection.start channel = connection.create_channel @message_queue = channel.queue('new_refs')
- Signal.trap(:SIGCHLD, 'SIG_IGN')
We use a lot of %x() or system() in our project, should we add this in other code?
Maybe not. It seems a problem of git. I found similar problems in the internet. It seems because git command didn't finish successfully.
Thanks, Yuanchao