Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Do display the output when requested to not take it into account but the child dyied...
[simgrid.git] / tools / tesh / background.tesh
1
2 $ rm -rf temp_testdir
3 $ mkdir temp_testdir
4 $ cd temp_testdir
5
6 < #include <unistd.h>
7 < #include <stdlib.h>
8 < #include <stdio.h>
9 < #include <sys/types.h>
10 < #include <sys/stat.h>
11 < #include <fcntl.h>
12 <                    
13 < int main() {
14 <   char buff[2048];
15 <   int got;
16 <   int in;
17
18 <   sleep(1);
19 <   in = open("tmp_fich",O_RDONLY|O_CREAT);
20 <   if (in == -1) {
21 <     perror("Cannot open tmp_fich: ");
22 <     exit(1);
23 <   }
24 <   while ((got = read(in,&buff,2048))>0) {
25 <      int w = write(1,&buff,got);
26 <      if (w<0) {
27 <        perror("Error while writing:");
28 <        exit(1);
29 <      }
30 <   }
31 <   if (got < 0) {
32 <     perror("Error while reading:");
33 <     exit(1);
34 <   }
35 <   return 0;
36 < }
37 $ cat > delayed_cat.c
38
39 $ gcc -Wall -o delayed_cat delayed_cat.c
40
41 & ./delayed_cat 
42 > TOTO
43
44 < TOTO
45 $ cat > tmp_fich
46
47 $ sleep 2
48 $ cd ..
49 $ rm -rf temp_testdir
50