Update: I tried printing out what $0 is after I'd defined the Schedule::Cron object and added an entry, but before I ran the cron. It must be somewhere in the run method in the module that it redefines what $0 is, or at least what the process name is, as when I print the value of $0, it still shows the name of the script. So, even if I reassigned the contents of $0, it wouldn't change what shows up in the process table.
Hm, I see what you're saying. But since $0 is by default the name of the script (which is what I want), and thus what a lot apps depend on, is it bad to change that? I guess maybe this is a question for the author of Schedule::Cron .... I mean, it is nice to see module name and the next time it will run, but for maintainability, I need the name of the script in there, too.
| [reply] |
You're right - $0 is set in Schedule::Cron's run method. And, unfortunately for you, that method is a behemoth method which does not give you a lot of flexibility to change anything about it. For example, if you were to derive your own package from S::C, you'd have to pretty much copy and paste the entire method to your own module, minus the one line that sets $0. And then, if a new version of S::C came out with a fix, you'd have to notice and merge the fix manually. That's kinda annoying.
Instead, what I would suggest you do is take the S::C module, change the line that says $0 = ... to say $self->set_process_title(), add a new method called set_process_title that all it contains is the old $0-setting line, take a diff between what you have and the original, and submit it back to the author of S::C as a patch.
Once you have that, then you can create your own Schedule::Cron::NoProcessTitleChange, which @ISA Schedule::Cron, and overrides set_process_title with an empty function (i.e., it does nothing). Then you'll get what you are looking for.
Assuming, of course, that the author likes the patch... though, since we're not actually changing real behaviour, s/he should be fine with, I hope.
| [reply] [d/l] [select] |
Thanks, that hack worked.
| [reply] |