Fix Restarter::Watcher to support delay of 0
[catagits/Catalyst-Runtime.git] / t / lib / TestApp / Controller / Fork.pm
CommitLineData
09274aae 1#!/usr/bin/perl
2# Fork.pm
3# Copyright (c) 2006 Jonathan Rockway <jrockway@cpan.org>
4
5package TestApp::Controller::Fork;
6
7use strict;
8use warnings;
9use base 'Catalyst::Controller';
10use YAML;
11
31b71f4b 12sub system : Local {
09274aae 13 my ($self, $c, $ls) = @_;
14 my ($result, $code) = (undef, 1);
15
16 if(!-e $ls || !-x _){
17 $result = 'skip';
18 $code = 0;
19 }
20 else {
8d5f3e92 21 $result = system($ls, $ls, $ls) || $!;
09274aae 22 $code = $?;
23 }
24
25 $c->response->body(Dump({result => $result, code => $code}));
26}
27
8d5f3e92 28sub backticks : Local {
29 my ($self, $c, $ls) = @_;
30 my ($result, $code) = (undef, 1);
31
32 if(!-e $ls || !-x _){
33 $result = 'skip';
34 $code = 0;
35 }
36 else {
37 $result = `$ls $ls $ls` || $!;
38 $code = $?;
39 }
40
41 $c->response->body(Dump({result => $result, code => $code}));
42}
31b71f4b 43
44sub fork : Local {
45 my ($self, $c) = @_;
46 my $pid;
47 my $x = 0;
48
49 if($pid = fork()){
50 $x = "ok";
51 }
52 else {
53 exit(0);
54 }
55
56 waitpid $pid,0 or die;
57
58 $c->response->body(Dump({pid => $pid, result => $x}));
59}
60
09274aae 611;