{
int dirfd_root = Eopen("/", O_RDONLY, 0);
int idx = 1;
+ int dirfd_cur;
if (argc>=2) {
if (strcmp(argv[1], "--help") ==0) showHelp(1, argv[0], 0);
Echroot(".");
Echdir(argv[idx]);
- int dirfd_cur = Eopen(".", O_RDONLY, 0);
+ dirfd_cur = Eopen(".", O_RDONLY, 0);
Efchdir(dirfd_root);
Echroot(".");
*/
static void test2()
{
+ int fd;
+
printf ("test2\n");
print_pwd();
mkdir ("dummy_dir",0755);
- int fd = open (".",O_RDONLY);
+ fd = open (".",O_RDONLY);
if (fd == -1){
fprintf (stderr,"Can't open current directory (%s)\n",strerror(errno));
}else if (chroot ("dummy_dir")==-1){
if (id == -1){
fprintf (stderr,"shmget failed (%s)\n",strerror(errno));
}else{
- printf ("shmget id %d\n",id);
void *pt = shmat (id,NULL,0);
+ printf ("shmget id %d\n",id);
if (pt == NULL){
fprintf (stderr,"can't shmat to id %d (%s)\n",id,strerror(errno));
}else{
+ char tmp[100];
+ int ok;
strcpy ((char*)pt,"original string");
printf ("Letting a sub-program attach to this memory\n");
- char tmp[100];
sprintf (tmp,"./testipc accessshm %d",id);
- int ok = system (tmp);
+ ok = system (tmp);
printf ("\tSub-program returned %d\n",ok);
printf ("\tThe segment now hold :%s:\n",(char*)pt);
if (id == -1){
fprintf (stderr,"semget failed (%s)\n",strerror(errno));
}else{
+ char tmp[100];
+ int ok;
printf ("semget id %d\n",id);
printf ("Letting a sub-program play with this semaphore\n");
- char tmp[100];
sprintf (tmp,"./testipc accesssem %d",id);
- int ok = system (tmp);
+ ok = system (tmp);
printf ("\tSub-program returned %d\n",ok);
printf ("A sub-program in another context can't use the semaphore\n");