Linux - Study Mode

[#836] What is stored in logfile as per below mentioned code if we execute ./a.out > logfile? int main()
{
int fd

close(1)

fd = open(“logfile”,O_RDWR, 0744)

write(fd, “Hello”, 5)

printf(“World
”)

return 0

}
Correct Answer

(B) HelloWorld

[#837] What is the output of this program? #! /usr/bin/awk -f
BEGIN {
for(i=0

i<=5

i++) {
print i
i++
}
}
Correct Answer

(A) 0,2,4 will print

[#838] This program will print the #include<stdio.h>
#include<unistd.h>

int main()
{
long int value

value = pathconf("/home/example",_PC_NAME_MAX)

printf("%ld
",value)

return 0

}
Correct Answer

(B) maximum length of a filename in this directory that the process is allowed to create

[#839] What is the output of this when the pipe is successfully created? #include<stdio.h>

int main()
{
int ret_val

int fd[2]

ret_val = pipe(fd)

printf("%d
",ret_val)

return 0

}
Correct Answer

(A) 0

[#840] By this program the soket "demo_sock" will create #include<stdio.h>
#include<sys/types.h>
#include<sys/un.h>
#include<sys/socket.h>

int main()
{
struct sockaddr_un add_server

int fd_server

fd_server = socket(AF_UNIX,SOCK_STREAM,0)

if(fd_server == -1)
perror("socket")

add_server.sun_family = AF_UNIX

strcpy(add_server.sun_path,"demo_sock")

if( bind(fd_server,(struct sockaddr*)&add_server,sizeof(add_server)) != 0)
perror("bind")

return 0

}
Correct Answer

(C) in the present working directory