⟩ What is the output of this program? #include<stdio.h> #include<fcntl.h> int main() { int fd, fd2, ret; fd = open("san.c",O_RDONLY); ret = close(fd2); printf("%dn",ret); } a) 0 b) 1 c) -1 d) none of the mentioned
c) -1
Explanation:
The "close" system call closes a file descriptor but in the program "fd2″ in not a file descriptor. Hence close system call returns -1.
Output:
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
-1
[root@localhost google]#