ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC.pm (file contents):
Revision 1.123 by root, Mon Oct 9 01:06:36 2006 UTC vs.
Revision 1.124 by root, Wed Oct 11 23:34:24 2006 UTC

77 my ($fh_r, $fh_w) = CFPlus::socketpipe; 77 my ($fh_r, $fh_w) = CFPlus::socketpipe;
78 78
79 my $pid = fork; 79 my $pid = fork;
80 80
81 if (defined $pid && !$pid) { 81 if (defined $pid && !$pid) {
82 $SIG{__DIE__} = sub { 82 local $SIG{__DIE__};
83 my $msg = $_[0];
84 $msg =~ s/\n+/\n/;
85 warn "FATAL: $msg";
86 CFPlus::_exit 99;
87 };
88 83
89 open STDOUT, ">&", $fh_w; 84 open STDOUT, ">&", $fh_w;
90 open STDERR, ">&", $fh_w; 85 open STDERR, ">&", $fh_w;
91 close $fh_r; 86 close $fh_r;
92 close $fh_w; 87 close $fh_w;
93 88
94 $| = 1; 89 $| = 1;
95 90
96 $cb->(); 91 eval { $cb->() };
92
93 if ($@) {
94 my $msg = $@;
95 $msg =~ s/\n+/\n/;
96 warn "FATAL: $msg";
97 CFPlus::_exit 1;
98 }
97 99
98 # win32 is fucked up, of course. exit will clean stuff up, 100 # win32 is fucked up, of course. exit will clean stuff up,
99 # which destroys our database etc. _exit will exit ALL 101 # which destroys our database etc. _exit will exit ALL
100 # forked processes, because of the dreaded fork emulation. 102 # forked processes, because of the dreaded fork emulation.
101 CFPlus::_exit 0; 103 CFPlus::_exit 0;
102 } 104 }
103 105
104 close $fh_w; 106 close $fh_w;
105 107
106 my $buffer; 108 my $buffer;
111 $buffer .= "done\n"; 113 $buffer .= "done\n";
112 } 114 }
113 115
114 while ($buffer =~ s/^(.*)\n//) { 116 while ($buffer =~ s/^(.*)\n//) {
115 my $line = $1; 117 my $line = $1;
118 $line =~ s/\s+$//;
116 utf8::decode $line; 119 utf8::decode $line;
117 ::message ({ 120 ::message ({
118 markup => "editor($pid): " . CFPlus::asxml $line, 121 markup => "editor($pid): " . CFPlus::asxml $line,
119 }); 122 });
120 } 123 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines