unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* [PATCH] test/test_helper: only unlink redirected logs from parent
@ 2021-03-13  2:08 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2021-03-13  2:08 UTC (permalink / raw)
  To: unicorn-public

We don't want at_exit firing in child processes and never wanted
it.  This is apparently a long standing bug in the tests that
only started causing test_worker_dies_on_dead_master failures
for me.  I assume it's only showing up now for me due to kernel
scheduler changes, since I've been using the same 4-core CPU for
~11 years, now.
---
 test/test_helper.rb | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/test/test_helper.rb b/test/test_helper.rb
index 974d2f2..ba5ef16 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -42,6 +42,7 @@
 def redirect_test_io
   orig_err = STDERR.dup
   orig_out = STDOUT.dup
+  rdr_pid = $$
   new_out = File.open("test_stdout.#$$.log", "a")
   new_err = File.open("test_stderr.#$$.log", "a")
   new_out.sync = new_err.sync = true
@@ -59,8 +60,10 @@ def redirect_test_io
   STDERR.sync = STDOUT.sync = true
 
   at_exit do
-    File.unlink(new_out.path) rescue nil
-    File.unlink(new_err.path) rescue nil
+    if rdr_pid == $$
+      File.unlink(new_out.path) rescue nil
+      File.unlink(new_err.path) rescue nil
+    end
   end
 
   begin

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-13  2:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-13  2:08 [PATCH] test/test_helper: only unlink redirected logs from parent Eric Wong

unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhbt.net/unicorn-public
	git clone --mirror http://ou63pmih66umazou.onion/unicorn-public

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 unicorn-public unicorn-public/ https://yhbt.net/unicorn-public \
		unicorn-public@yhbt.net unicorn-public@bogomips.org mongrel-unicorn@rubyforge.org mongrel-unicorn-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
	public-inbox-index unicorn-public

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.unicorn
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.lang.ruby.unicorn
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	../../../unicorn.git

AGPL code for this site: git clone http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/public-inbox.git