Forum: Ruby-core [ruby-trunk - Feature #5945][Open] Add the ability to mark a at_exit as process-local.

Posted by Robert Gleeson (robgleeson)
on 2012-01-30 02:00
(Received via mailing list)
Issue #5945 has been reported by Robert Gleeson.

----------------------------------------
Feature #5945: Add the ability to mark a at_exit as process-local.
https://bugs.ruby-lang.org/issues/5945

Author: Robert Gleeson
Status: Open
Priority: Normal
Assignee:
Category: core
Target version: 1.9.3


I'd like to propose a enhancement to at_exit.
It would be nice if you could stop a at_exit handler from running in 
subprocesses.
You can do this manually with this code:

parent = Process.pid

at_exit do
  if parent == Process.pid
     # …
   end
end

You can also do it by bypassing handlers:

at_exit do
  # …
end

fork do
  exit!
end

But it would be nice if I could do:

at_exit(false) do
  # …
end

The first approach is kind of ugly, and the second approach isn't 
sustainable if code outside
your control can fork(…) without calling exit!.
Posted by mame (Yusuke Endoh) (Guest)
on 2012-03-31 03:21
(Received via mailing list)
Issue #5945 has been updated by mame (Yusuke Endoh).

Status changed from Open to Assigned
Assignee set to matz (Yukihiro Matsumoto)

Matz, do you think this kind of feature is needed?
I guess you'll say, the argument should be a keyword option, at least.

  at_exit(process_local: true) { ... }

--
Yusuke Endoh <mame@tsg.ne.jp>
----------------------------------------
Feature #5945: Add the ability to mark a at_exit as process-local.
https://bugs.ruby-lang.org/issues/5945#change-25493

Author: robertgleeson (Robert Gleeson)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: core
Target version: 1.9.3


I'd like to propose a enhancement to at_exit.
It would be nice if you could stop a at_exit handler from running in 
subprocesses.
You can do this manually with this code:

parent = Process.pid

at_exit do
  if parent == Process.pid
     # …
   end
end

You can also do it by bypassing handlers:

at_exit do
  # …
end

fork do
  exit!
end

But it would be nice if I could do:

at_exit(false) do
  # …
end

The first approach is kind of ugly, and the second approach isn't 
sustainable if code outside
your control can fork(…) without calling exit!.
Posted by KOSAKI Motohiro (Guest)
on 2012-03-31 10:34
(Received via mailing list)
2012/3/30 mame (Yusuke Endoh) <mame@tsg.ne.jp>:
>
> Issue #5945 has been updated by mame (Yusuke Endoh).
>
> Status changed from Open to Assigned
> Assignee set to matz (Yukihiro Matsumoto)
>
> Matz, do you think this kind of feature is needed?
> I guess you'll say, the argument should be a keyword option, at least.
>
> at_exit(process_local: true) { ... }

I don't like this name. at_exit() is always process local. He hope to
make no subprocess inheritance option.
Posted by mame (Yusuke Endoh) (Guest)
on 2012-11-24 06:16
(Received via mailing list)
Issue #5945 has been updated by mame (Yusuke Endoh).

Target version changed from 1.9.3 to next minor


----------------------------------------
Feature #5945: Add the ability to mark a at_exit as process-local.
https://bugs.ruby-lang.org/issues/5945#change-33789

Author: robertgleeson (Robert Gleeson)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: core
Target version: next minor


I'd like to propose a enhancement to at_exit.
It would be nice if you could stop a at_exit handler from running in 
subprocesses.
You can do this manually with this code:

parent = Process.pid

at_exit do
  if parent == Process.pid
     # …
   end
end

You can also do it by bypassing handlers:

at_exit do
  # …
end

fork do
  exit!
end

But it would be nice if I could do:

at_exit(false) do
  # …
end

The first approach is kind of ugly, and the second approach isn't 
sustainable if code outside
your control can fork(…) without calling exit!.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.