Thread Funktion im Eltern-Prozess ansprechen?: doch per fork? (14 answers)
Opened by Froschpopo at 2005-04-07 05:23

esskar
 2005-04-07 07:26
#53499 #53499
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
Code: (dl )
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
#!/usr/bin/perl
$|++;

use strict;
use warnings;

use IO::Pipe;
use IO::Select;

my $pipe = IO::Pipe->new;

my $pid = fork();

unless($pid) {
    $pipe->writer;
    $pipe->autoflush(1);

     for (1..2) {
         $pipe->print("Text vom Kind\n");
         sleep(2);
     }

} else {
    $pipe->reader;
    $pipe->autoflush(1);

   my $select = IO::Select->new($pipe);

   while(1) {
       if(my @handles = $select->can_read(0)) {
           foreach (@handles) {
               my $line = $_->readline;
               print "Das Kind schreibt: $line\n";
           }
       }
       print "Papa arbeitet.\n";
       sleep(1);
   }
}
\n\n

<!--EDIT|esskar|1112844404-->

View full thread Funktion im Eltern-Prozess ansprechen?: doch per fork?