File: fd_copy.c

package info (click to toggle)
ucspi-tcp 1%3A0.88-13
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,772 kB
  • sloc: ansic: 10,201; makefile: 2,689; python: 604; sh: 168
file content (12 lines) | stat: -rw-r--r-- 235 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
#include <fcntl.h>
#include <unistd.h>
#include "fd.h"

int fd_copy(int to,int from)
{
  if (to == from) return 0;
  if (fcntl(from,F_GETFL,0) == -1) return -1;
  close(to);
  if (fcntl(from,F_DUPFD,to) == -1) return -1;
  return 0;
}