File: open_read.c

package info (click to toggle)
dq 20251001-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,376 kB
  • sloc: ansic: 13,644; python: 651; makefile: 382; sh: 336
file content (17 lines) | stat: -rw-r--r-- 326 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include "open.h"

int open_read(const char *fn)
{
#ifdef O_CLOEXEC
  return open(fn,O_RDONLY | O_NONBLOCK | O_CLOEXEC);
#else
  int fd = open(fn,O_RDONLY | O_NONBLOCK);
  if (fd == -1) return -1;
  fcntl(fd,F_SETFD,1);
  return fd;
#endif
}