Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

lab2

.c
Скачиваний:
3
Добавлен:
06.02.2018
Размер:
689 б
Скачать
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>

int main()
{
	int fhandle1, nhandle, fhandle2, len;	
	char buf[100];
	
	fhandle1 = open("out.txt", O_RDONLY, 0400);
	nhandle = dup(fhandle1);
	fhandle2 = open("out.txt", O_RDONLY, 0400);
	
	lseek(fhandle1, 10, SEEK_SET);
	printf("handle 1: %d\n", fhandle1); 
	printf("handle 2: %d\n", nhandle); 
	printf("handle 3: %d\n", fhandle2); 
			
	len = read(fhandle1, buf, 7);
	write(1, buf, len);
	printf("\n");  
	len = read(nhandle, buf, 7);
	write(1, buf, len);
 	printf("\n"); 
	len = read(fhandle2, buf, 7);
	write(1, buf, len);
	printf("\n");  

	close(fhandle1);
	close(nhandle);
	close(fhandle2);
	return 0;
}
Соседние файлы в предмете Операционные системы