summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrew Pimlott <pimlott@idiomtech.com>2004-07-12 17:06:01 -0400
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2004-07-13 08:53:46 +0000
commitca28b541c9845a7610e3eca36472b9ee994eb64c (patch)
tree34de9b6c59075f562ab1073253cc0dbfdaed99ba /lib
parentd2397f31c862eda39e662addb6f45fa6fe0550fe (diff)
downloadperl-ca28b541c9845a7610e3eca36472b9ee994eb64c.tar.gz
Re: debugger 'R'estart and open database connections
Message-ID: <20040713010601.GF8232@pimlott.net> p4raw-id: //depot/perl@23089
Diffstat (limited to 'lib')
-rw-r--r--lib/perl5db.pl18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/perl5db.pl b/lib/perl5db.pl
index 4944e5c2cd..7b443febb3 100644
--- a/lib/perl5db.pl
+++ b/lib/perl5db.pl
@@ -3185,6 +3185,24 @@ Return to any given position in the B<true>-history list
$cmd =~ /^(R|rerun\s*(.*))$/ && do {
my @args = ($1 eq 'R' ? restart() : rerun($2));
+ # Close all non-system fds for a clean restart. A more
+ # correct method would be to close all fds that were not
+ # open when the process started, but this seems to be
+ # hard. See "debugger 'R'estart and open database
+ # connections" on p5p.
+
+ my $max_fd;
+ if (eval { require POSIX }) {
+ $max_fd = POSIX::sysconf(POSIX::_SC_OPEN_MAX());
+ }
+
+ if (defined $max_fd) {
+ foreach ($^F+1 .. $max_fd-1) {
+ next unless open FD_TO_CLOSE, "<&=$_";
+ close(FD_TO_CLOSE);
+ }
+ }
+
# And run Perl again. We use exec() to keep the
# PID stable (and that way $ini_pids is still valid).
exec(@args) || print $OUT "exec failed: $!\n";