Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
6838a013b3028c2992535d15ffe81eafafb5f05d
[simgrid.git] / tools / tesh2 / examples / 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 < #ifdef __MINGW32__
14 < #define sleep _sleep
15 < #endif
16 <                    
17 < int main() {
18 <   char buff[2048];
19 <   int got;
20 <   int in;
21
22 <   sleep(1);
23 <   in = open("tmp_fich",O_RDONLY|O_CREAT);
24 <   if (in == -1) {
25 <     perror("Cannot open tmp_fich: ");
26 <     exit(1);
27 <   }
28 <   while ((got = read(in,&buff,2048))>0) {
29 <      int w = write(1,&buff,got);
30 <      if (w<0) {
31 <        perror("Error while writing:");
32 <        exit(1);
33 <      }
34 <   }
35 <   if (got < 0) {
36 <     perror("Error while reading:");
37 <     exit(1);
38 <   }
39 <   return 0;
40 < }
41 $ cat > delayed_cat.c
42
43 $ gcc -Wall -o delayed_cat delayed_cat.c
44
45 & ./delayed_cat 
46 > TOTO
47
48 < TOTO
49 $ cat > tmp_fich
50
51 $ sleep 2
52 $ cd ..
53 $ rm -rf temp_testdir
54