Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'smpi-topo'
[simgrid.git] / tools / tesh / background.tesh
1
2 $ rm -rf temp_testdir_background
3 $ mkdir temp_testdir_background
4 $ cd temp_testdir_background
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 < #ifdef WIN32 
13 <   #include "windows.h"
14 < #endif
15 <                    
16 < int main() {
17 <   char buff[2048];
18 <   int got;
19 <   int in;
20
21 < #ifndef WIN32 
22 <   sleep(1);
23 < #else
24 <   Sleep(1000);
25 < #endif
26 <   in = open("tmp_fich",O_RDONLY|O_CREAT);
27 <   if (in == -1) {
28 <     perror("Cannot open tmp_fich: ");
29 <     exit(1);
30 <   }
31 <   while ((got = read(in,&buff,2048))>0) {
32 <      int w = write(1,&buff,got);
33 <      if (w<0) {
34 <        perror("Error while writing:");
35 <        exit(1);
36 <      }
37 <   }
38 <   if (got < 0) {
39 <     perror("Error while reading:");
40 <     exit(1);
41 <   }
42 <   return 0;
43 < }
44 $ mkfile delayed_cat.c
45
46 $ cc -Wall -o delayed_cat delayed_cat.c
47
48 & ./delayed_cat
49 > TOTO
50
51 < TOTO
52 $ mkfile tmp_fich
53
54 $ sleep 2
55 $ cd ..
56 $ rm -rf temp_testdir_background