From e5631087d3862823d0d4854a8dfc1258f91cb115 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 12 Sep 2019 08:34:20 +0000 Subject: tmpfile: give temporary files meaningful names Although we always unlink temporary files, give them a meaningful name so that we can we can still make sense of the pre-unlink name when using lsof(8) or similar tools on Linux. --- lib/PublicInbox/Git.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/PublicInbox/Git.pm') diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index d048051e..ff3838b3 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -12,6 +12,7 @@ use warnings; use POSIX qw(dup2); require IO::Handle; use PublicInbox::Spawn qw(spawn popen_rd); +use PublicInbox::Tmpfile; use base qw(Exporter); our @EXPORT_OK = qw(git_unquote git_quote); @@ -110,7 +111,8 @@ sub _bidi_pipe { qw(-c core.abbrev=40 cat-file), $batch); my $redir = { 0 => fileno($out_r), 1 => fileno($in_w) }; if ($err) { - open(my $fh, '+>', undef) or fail($self, "open.err failed: $!"); + my $id = "git.$self->{git_dir}$batch.err"; + my $fh = tmpfile($id) or fail($self, "tmpfile($id): $!"); $self->{$err} = $fh; $redir->{2} = fileno($fh); } -- cgit v1.2.3-24-ge0c7