1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * Copyright (c) 2020 FUJITSU LIMITED. All rights reserved. 4 * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com 5 */ 6 #include <stdio.h> 7 #include <stdlib.h> 8 #include <string.h> 9 #include <errno.h> 10 #include <fcntl.h> 11 main(int argc,char ** argv)12int main(int argc, char **argv) 13 { 14 int fd; 15 16 if (argc != 2) { 17 fprintf(stderr, "Only two arguments: %s <fd>\n", argv[0]); 18 exit(1); 19 } 20 21 fd = atoi(argv[1]); 22 if (fcntl(fd, F_GETFL) < 0 && errno == EBADF) 23 return 0; 24 25 return 1; 26 } 27