Issue #3013 has been updated by Markus Roberts.

> Why was exit replaced with exit!? 

Because calling exit calls any (parental) at_exit routines in the child process 
when the child exits; this can cause all manner of confusion.  This is one of 
the ones that I caught in testing.  Forked children should always use exit! in 
ruby.

> Previously, the use of exit! caused a bug where the output from 
> the "puts detail" was lost because stdout was not flushed with exit!. 
> I mentioned a case where this previously showed up in comment 11 on 
> ticket #2731. As a simpler example, the below program gives 
> no output on my machine.
>
> #!/usr/bin/ruby
> print 'Flushed.'
> #exit
> exit!

Ah.  That explains why the change was made.  Looking into that was on my 
things-to-do list for this afternoon.

The correct solution is to do a

    $stdout.flush

before the exit, as that's all we're really wanting out of the at_exit code.

> Also, the second exit after the begin block should probably be exit(1), or 
> maybe even 
> something akin to assert(false) in ruby, since things are definitely not 
> right if 
> execution gets past that block (in fact, is it even possible at all)?

That was an artifact of my trying to untangle what was going on with the 
multiple execution of the at_exit code from a problem with the trapping of 
Errno:XXXX errors.  It should be removed and the rescue clause above replaced 
with:

    rescue Object => detail

> One last thing - the += in the /proc/mounts code should probably be 
> changed to <<, since that doesn't create a new string for each 
> iteration of the loop.

I suppose, yes, although the memory allocation patterns aren't significantly 
different IIRC--you save the object header but most of the turnover is in the 
buffer, and that's still going to go through roughly the same allocation/GC 
process.

I'll make sure these changes are in the patch; what systems did you manage to 
test on, and did you find anything else?


----------------------------------------
Bug #3013: util.rb:execute broken on Ruby <1.8.3
http://projects.reductivelabs.com/issues/3013

Author: Ricky Zhou
Status: Ready for Testing
Priority: Urgent
Assigned to: Markus Roberts
Category: exec
Target version: 0.25.3
Affected version: 0.25.2
Keywords: 
Branch: http://github.com/MarkusQ/puppet/tree/ticket/0.25.x/3013


Apparently the patch in ticket #2731 introduced one more issue by using 
readpartial, which isn't available until ruby 1.8.3 (RHEL4 at least is 
affected).  I'm not sure how this is normally handled in ruby, but if the 
readpartial function is not available, the code should fall back to sysread 
(along with some code for handling EINTR).

Anybody with better ruby knowledge know how this should be done?


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://reductivelabs.com/redmine/my/account
--
You received this message because you are subscribed to the Google Groups "Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to