okey, this is code:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
void printpos(char *msg, int fd);
main()
{
int fd; /*file descriptor*/
int pid; /*process-id*/
char buf[10]; /*buffer to hold file data*/
if( (fd = open("date", 0_RDONLY)) < 0)
{
fatal ("open failed");
read(fd, buf, 10); /*advance file pointer*/
printpos("Before fork", fd); }
if( (pid = fork()) < 0) {
fatal("fork failed"); }
else if (pid == 0){ /*child*/
printpos("Child before read", fd);
read(fd, buf, 10);
printpos("Child after read", fd);
}else{ /*parent*/
/*wait until child finished*/
wait( (int *)0);
printpos("Parent after wait", fd);
}
int printpos(const char *str, int fd) {
off_t pos;
if (( pos = lseek(fd, 0, SEEK_CUR)) == -1) {
fatal(“lseek failed”);
}
printf(“%s:%ld\n”, str, pos);
}
void printpos( char *msg, int fd )
/* Print position in file */
{
long int pos;
if( (pos = lseek( fd, 0L, SEEK_CUR) ) < 0L )
perror(“lseek”);
printf( “%s: %ld\n”, msg, pos );
}
return 0;
}
Problem is that bold line says that:
CTRL + Q to Enable/Disable GoPhoto.it