| 1 |
/*********************************************************************** |
| 2 |
* Code listing from "Advanced Linux Programming," by CodeSourcery LLC * |
| 3 |
* Copyright (C) 2001 by New Riders Publishing * |
| 4 |
* See COPYRIGHT for license information. * |
| 5 |
***********************************************************************/ |
| 6 |
|
| 7 |
#include <fcntl.h> |
| 8 |
#include <stdio.h> |
| 9 |
#include <sys/stat.h> |
| 10 |
#include <sys/types.h> |
| 11 |
#include <unistd.h> |
| 12 |
|
| 13 |
int main (int argc, char* argv[]) |
| 14 |
{ |
| 15 |
const char* const filename = argv[1]; |
| 16 |
int fd = open (filename, O_RDONLY); |
| 17 |
printf ("in process %d, file descriptor %d is open to %s\n", |
| 18 |
(int) getpid (), (int) fd, filename); |
| 19 |
while (1); |
| 20 |
return 0; |
| 21 |
} |