, , , c-.
, , INVALID, . FD = 3 , .
fd fcntl.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
int main(int argc, char ** argv) {
int fd = atoi(getenv("MY_FD"));
char buf[12];
read(fd, buf, 11);
buf[11] = '\0';
printf("fd: %d, if fd still valid: %d\n", fd, fcntl(fd, F_GETFD));
printf("strlen %d\n", (int)strlen(buf));
printf("message: %s\n", buf);
}
, MY_FD = 3 ENV, , fd 3. . fcntl (fd, F_GETFD) -1, , fd, 0.
" ".
, @dan1111 , , .
, , MY_FD = 0,
$ENV{'MY_FD'} = 0;
STDIN/OUT - , , , perl c. , .
hanle, , STDIN.