61. Which command reads user input from the terminal and assign this value to a variable name?
62. The /sbin/sysctl command is used to
63. What happnes as the signal SIGINT hits the current process in the program?
#include<stdio.h>
#include<signal.h>
void response (int);
void response (int sig_no)
{
printf("Linux\n");
}
int main()
{
struct sigaction act;
act.sa_handler = response;
act.sa_flags = 0;
sigemptyset(&act.sa_mask);
sigaction(SIGINT,&act,0);
while(1){
printf("Example\n");
sleep(1);
}
return 0;
}
#include<stdio.h>
#include<signal.h>
void response (int);
void response (int sig_no)
{
printf("Linux\n");
}
int main()
{
struct sigaction act;
act.sa_handler = response;
act.sa_flags = 0;
sigemptyset(&act.sa_mask);
sigaction(SIGINT,&act,0);
while(1){
printf("Example\n");
sleep(1);
}
return 0;
}
64. The kset contains
65. This program will print the
#include<stdio.h>
#include<unistd.h>
int main()
{
long int value;
value = sysconf(_SC_CHILD_MAX);
printf("%ld\n",value);
return 0;
}
#include<stdio.h>
#include<unistd.h>
int main()
{
long int value;
value = sysconf(_SC_CHILD_MAX);
printf("%ld\n",value);
return 0;
}
66. Which function can be used instead of the dup2 to duplicate the file descriptor?
67. What is the output of this program?
#include<stdio.h>
#include<stdlib.h>
#include<netinet/in.h>
#include<sys/types.h>
#include<sys/socket.h>
int main()
{
int fd_server, fd_client, len, len_client;
struct sockaddr_in add_server;
fd_server = socket(AF_INET,SOCK_STREAM,0);
fd_client = accept(fd_server,(struct sockaddr*)&add_server,&len);
if(fd_client == -1)
perror("accept");
if(listen(fd_server,5) != 0)
perror("listen");
return 0;
}
#include<stdio.h>
#include<stdlib.h>
#include<netinet/in.h>
#include<sys/types.h>
#include<sys/socket.h>
int main()
{
int fd_server, fd_client, len, len_client;
struct sockaddr_in add_server;
fd_server = socket(AF_INET,SOCK_STREAM,0);
fd_client = accept(fd_server,(struct sockaddr*)&add_server,&len);
if(fd_client == -1)
perror("accept");
if(listen(fd_server,5) != 0)
perror("listen");
return 0;
}
68. If we want to execute the makefile by just giving the "make" command, makefile should be named as
69. What is the output of this program?
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *ptr1;
while(1){
ptr1 = malloc(1024*1024);
if(ptr1 == 0)
break;
sleep(1);
printf("Example\n");
free(ptr1);
}
return 0;
}
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *ptr1;
while(1){
ptr1 = malloc(1024*1024);
if(ptr1 == 0)
break;
sleep(1);
printf("Example\n");
free(ptr1);
}
return 0;
}
70. What is the output of this program?
#include<stdio.h>
#include<pthread.h>
#include<semaphore.h>
void *fun_t(void *arg);
void *fun_t(void *arg)
{
pthread_exit("Bye");
}
int main()
{
pthread_t pt;
sem_t st;
void *res_t;
if(pthread_create(&pt,NULL,fun_t,NULL) == -1)
perror("pthread_create");
if(sem_init(&st,0,0) != 0)
perror("sem_init");
if(sem_wait(&st) != 0)
perror("sem_wait");
printf("Example\n");
if(pthread_join(pt,&res_t) == -1)
perror("pthread_join");
if(sem_destroy(&st) != 0)
perror("sem_destroy");
return 0;
}
#include<stdio.h>
#include<pthread.h>
#include<semaphore.h>
void *fun_t(void *arg);
void *fun_t(void *arg)
{
pthread_exit("Bye");
}
int main()
{
pthread_t pt;
sem_t st;
void *res_t;
if(pthread_create(&pt,NULL,fun_t,NULL) == -1)
perror("pthread_create");
if(sem_init(&st,0,0) != 0)
perror("sem_init");
if(sem_wait(&st) != 0)
perror("sem_wait");
printf("Example\n");
if(pthread_join(pt,&res_t) == -1)
perror("pthread_join");
if(sem_destroy(&st) != 0)
perror("sem_destroy");
return 0;
}
Read More Section(Linux)
Each Section contains maximum 100 MCQs question on Linux. To get more questions visit other sections.