File: Win32.pm

package info (click to toggle)
libcatalyst-devel-perl 1.42-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 360 kB
  • sloc: perl: 727; makefile: 2
file content (65 lines) | stat: -rw-r--r-- 1,266 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package Catalyst::Restarter::Win32;

use Moose;
use Proc::Background;

extends 'Catalyst::Restarter';

has _child => (
    is  => 'rw',
    isa => 'Proc::Background',
);


sub _fork_and_start {
    my $self = shift;

    # This is totally hack-tastic, and is probably much slower, but it
    # does seem to work.
    my @command = ( $^X, map("-I$_", @INC), $0, grep { ! /^\-r/ } @{ $self->argv } );

    my $child = Proc::Background->new(@command);

    $self->_child($child);
}

sub _kill_child {
    my $self = shift;

    return unless $self->_child;

    $self->_child->die;
}

__PACKAGE__->meta->make_immutable;

1;

__END__

=head1 NAME

Catalyst::Restarter::Win32 - Uses Proc::Background to manage process restarts

=head1 DESCRIPTION

This class uses L<Proc::Background>, which in turn uses
L<Win32::Process>. The new process is run using the same command-line
as the original script, but without any restart-based options.

This is a big hack, but using forks just does not work on Windows.

=head1 SEE ALSO

L<Catalyst::Restarter>, L<Catalyst>, <File::ChangeNotify>

=head1 AUTHORS

Catalyst Contributors, see Catalyst.pm

=head1 COPYRIGHT

This program is free software, you can redistribute it and/or modify
it under the same terms as Perl itself.

=cut