Logo AND Algorithmique Numérique Distribuée

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