|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
i want to have a program restart when its closed via the X button on the
window / terminal any ideas? -- Posted via http://www.ruby-forum.com/. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Sep 16, 2007, at 12:51 AM, Michael Linfield wrote: > i want to have a program restart when its closed via the X button > on the > window / terminal > > any ideas? > -- > Posted via http://www.ruby-forum.com/. > You're going into very platform specific territory there. Potentially malware like behavior. Normally, the paradigm a user expects is that a GUI widget functions the same as in other applications. If all you want is to have an application not quit via that GUI widget, disable that widget, and visually gray it out. If you want a restart button, make one. Don't break expected behaviors like that. If you want a daemon process, you probably don't want it running in a GUI. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Michael Linfield wrote:
> i want to have a program restart when its closed via the X button on the > window / terminal > > any ideas? A program cannot restart itself after it is closed down. I suggest a parent program that runs the one that you want to have running. Then, when the child program ends, the parent can restart it. Caveat: Make sure that there is a way to end it. You do not want it to turn into a "never-ending story." -- Posted via http://www.ruby-forum.com/. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On 9/15/07, Michael Linfield <globyy3000@hotmail.com> wrote:
> i want to have a program restart when its closed via the X button on the > window / terminal > > any ideas? > -- > Posted via http://www.ruby-forum.com/. > at_exit {exec "ruby", $0, *ARGS} Should work on all platforms, but you will not get the original flags to the ruby interpreter. You should register a signal handler to trap SIGKILL or SIGTERM and do an exit! from the handler. This will prevent the at_exit blocks from running. Blessings, TwP |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
END{
code } "Declares code to be called at the end of the program (when the interpreter quits)." Ruby In A Nutshell: page 29. I do have the first edition so could have changed. SbeckerIV On 9/16/07, Tim Pease <tim.pease@gmail.com> wrote: > On 9/15/07, Michael Linfield <globyy3000@hotmail.com> wrote: > > i want to have a program restart when its closed via the X button on the > > window / terminal > > > > any ideas? > > -- > > Posted via http://www.ruby-forum.com/. > > > > at_exit {exec "ruby", $0, *ARGS} > > Should work on all platforms, but you will not get the original flags > to the ruby interpreter. You should register a signal handler to trap > SIGKILL or SIGTERM and do an exit! from the handler. This will prevent > the at_exit blocks from running. > > Blessings, > TwP > > |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
John Joyce wrote:
> You're going into very platform specific territory there. Potentially > malware like behavior. this is true, i do see how it could be seen as malware behavior and i should probably stay away from that. Its purpose is to make sure the user cannot exit while its running its given functions, if they were to do this, it could cause some serious problems ![]() > at_exit {exec "ruby", $0, *ARGS} thanks Tim Pease ill look into that >END{ > code >} i will give that a shot as well -- Posted via http://www.ruby-forum.com/. |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
On 17.09.2007 22:12, Michael Linfield wrote:
> John Joyce wrote: > >> You're going into very platform specific territory there. Potentially >> malware like behavior. > > this is true, i do see how it could be seen as malware behavior and i > should probably stay away from that. Its purpose is to make sure the > user cannot exit while its running its given functions, if they were to > do this, it could cause some serious problems ![]() > > >> at_exit {exec "ruby", $0, *ARGS} > thanks Tim Pease ill look into that > >> END{ >> code >> } > > i will give that a shot as well Here's another mechanism: loop do Process.waitpid( fork do # your program goes here end ) end Kind regards robert |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
On 9/17/07, Robert Klemme <shortcutter@googlemail.com> wrote:
> > Here's another mechanism: > > loop do > Process.waitpid( fork do > # your program goes here > end ) > end > Windows is the fork nazi ... "No fork for you!" But clever, nonetheless. Blessings, TwP |
|
![]() |
| Outils de la discussion | |
|
|