hi
@rosti ja , alles gut blockiert aber trotzdem .
ich befürchte fast das das problem in kombination mit dem
Proc::Daemon zu suchen ist.
Habe mal heute die Kombination IPC::Run mit Fokr probiert das gleiche
problem.
Der Fork wird gemacht , das child Programm startet und dann block,
sprich die while schleife des Parent Programm laeuft nicht weiter
und wartet bis der dieser externe child fertig ist.
wobei ein einfaches Shell script ( echo und sleep ) da funktioniert der
Ablauf wie er soll , bei einem script bei dem ein rsync aufgerufen
wird steht er bis der rsync fertig ist.
kann das ein Problem der Ausgabe nach STDOUT sein ?
also folgende kombis zeigen die gleichen Probleme:
Proc::Daemon -> Fork -> IPC::Open3
Proc::Daemon -> Fork -> IPC::Run3
Proc::Daemon -> Fork -> system
anbei der teil der den Fork macht und dann das externe Programm startet.
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
sub _run_run3 {
my ( $self,$xargs,$type ) = @_;
$self->{'logger'}(DEBUG,"_run_run3 (parent) have pid $PID");
if ( _get_runnings() > $self->{'cfg'}->{'max_run'} ) {
$self->{'logger'}(2,'max count of running jobs reach, skip current new job');
$self->_cleanup_process_list();
return ;
}
my $idx = _get_index_name ( $type,$xargs );
$self->{'logger'}(0,"_run_run3 type $type $xargs->{$type . '_name'}");
if ( defined $self->_is_running($idx) ) {
$self->{'logger'}(0,"_run_run3 skip $type $xargs->{$type . '_name'} , still running");
return 2;
}
my @run = ("$xargs->{'run'}");
if ( defined $xargs->{'arguments'} ) {
push @run,$xargs->{'arguments'};
}
my $kpid = $daemon->Fork();
if ( not defined $kpid ) {
croak "can\'t fork(run3), $ERRNO";
} elsif ( $kpid > 0 ) {
# parent
# Register PID
$STARTEDCHILD{$kpid} = $idx;
$self->{'logger'}(DEBUG,"_run_run3 (parent) have pid $PID");
$self->{'logger'}(0,"_run_run3 type $type $xargs->{$type . '_name'} forking child PID $kpid") ;
} else {
# child
my ($run3_exit_code,$eval_run3_err);
if ( defined $xargs->{'catch'} ) {
$self->{'logger'}(DEBUG,"_run_run3 (child) have pid $PID");
$self->{'logger'}(DEBUG,'_run_run3 catch option active');
$eval_run3_err = eval { run3(\@run,undef,\*STDOUT,\*STDERR) ;
$run3_exit_code = $CHILD_ERROR ; };
} else {
run3(\@run,undef,\*STDOUT,\*STDERR);
$run3_exit_code = $CHILD_ERROR ;
}
$self->{'logger'}(1,"_run_run3 $PID $xargs->{$type . '_name'} process done, with code $run3_exit_code");
exit $run3_exit_code;
}
my $xpid = waitpid FALSE, WNOHANG;
if ($xpid > 0) {
my $exit_code = $CHILD_ERROR ; # /SHIFTERR;
my $worker_id = $STARTEDCHILD{$xpid};
if ( defined $worker_id ) {
$self->{'logger'}(1,"_run_run3 child process $worker_id finish with exit $exit_code" );
} else {
$self->{'logger'}(1,"_run_run3 child process $xargs->{$type . '_name'} finish with exit $exit_code" );
}
return $exit_code;
}
return;
}