71. Which command can create environment variable?
72. What is a context switch?
73. When we install a new package in linux system, then
74. What is the output of this program?
#include<stdio.h>
#include<fcntl.h>
int main()
{
pid_t fd;
char ch;
int count;
fd = open("demo.c",O_RDONLY);
do{
count = read(fd,&ch,1);
printf("%c",ch);
}while(count);
return 0;
}
#include<stdio.h>
#include<fcntl.h>
int main()
{
pid_t fd;
char ch;
int count;
fd = open("demo.c",O_RDONLY);
do{
count = read(fd,&ch,1);
printf("%c",ch);
}while(count);
return 0;
}
75. What is the output of this program?
#include<stdio.h>
#include<signal.h>
#include<stdlib.h>
void response (int);
void response (int sig_no)
{
printf("%s\n",sys_siglist[sig_no]);
printf("This is singal handler\n");
}
int main()
{
pid_t child;
int status;
child = fork();
switch (child){
case -1 :
perror("fork");
exit (1);
case 0 :
kill(getppid(),SIGKILL);
printf("I am an orphan process because my parent has been killed by me\n");
printf("Handler failed\n");
break;
default :
signal(SIGKILL,response);
wait(&status);
printf("The parent process is still alive\n");
break;
}
return 0;
}
#include<stdio.h>
#include<signal.h>
#include<stdlib.h>
void response (int);
void response (int sig_no)
{
printf("%s\n",sys_siglist[sig_no]);
printf("This is singal handler\n");
}
int main()
{
pid_t child;
int status;
child = fork();
switch (child){
case -1 :
perror("fork");
exit (1);
case 0 :
kill(getppid(),SIGKILL);
printf("I am an orphan process because my parent has been killed by me\n");
printf("Handler failed\n");
break;
default :
signal(SIGKILL,response);
wait(&status);
printf("The parent process is still alive\n");
break;
}
return 0;
}
76. The connection between the device file and device driver is based on the
77. What is the output of second program if we run the demo1 first and after that we run demo2 in the different terminal?
/*This is demo1.c*/
#include<stdio.h>
#include<sys/ipc.h>
#include<sys/shm.h>
#include<string.h>
int main()
{
int shm_id;
char *addr;
struct shmid_ds ds;
shm_id = shmget((key_t)1234,10,0666|IPC_CREAT);
if(shm_id == -1){
perror("shmget");
}
addr = (char*)shmat(shm_id,NULL,SHM_RND);
if(addr == (char *)-1){
perror("shmat");
}
strcpy(addr,"Example");
if (shmdt(addr) != 0){
perror("shmdt");
}
if( shmctl(shm_id,IPC_RMID,0) == -1){
perror("shmctl");
}
return 0;
}
/*This is demo2.c*/
#include<stdio.h>
#include<sys/ipc.h>
#include<sys/shm.h>
int main()
{
int shm_id;
char *addr;
struct shmid_ds ds;
shm_id = shmget((key_t)1234,10,0666|IPC_CREAT);
if(shm_id == -1){
perror("shmget");
}
addr = (char*)shmat(shm_id,NULL,SHM_RND);
if(addr == (char *)-1){
perror("shmat");
}
printf("%s\n",addr);
if (shmdt(addr) != 0){
perror("shmdt");
}
return 0;
}
/*This is demo1.c*/
#include<stdio.h>
#include<sys/ipc.h>
#include<sys/shm.h>
#include<string.h>
int main()
{
int shm_id;
char *addr;
struct shmid_ds ds;
shm_id = shmget((key_t)1234,10,0666|IPC_CREAT);
if(shm_id == -1){
perror("shmget");
}
addr = (char*)shmat(shm_id,NULL,SHM_RND);
if(addr == (char *)-1){
perror("shmat");
}
strcpy(addr,"Example");
if (shmdt(addr) != 0){
perror("shmdt");
}
if( shmctl(shm_id,IPC_RMID,0) == -1){
perror("shmctl");
}
return 0;
}
/*This is demo2.c*/
#include<stdio.h>
#include<sys/ipc.h>
#include<sys/shm.h>
int main()
{
int shm_id;
char *addr;
struct shmid_ds ds;
shm_id = shmget((key_t)1234,10,0666|IPC_CREAT);
if(shm_id == -1){
perror("shmget");
}
addr = (char*)shmat(shm_id,NULL,SHM_RND);
if(addr == (char *)-1){
perror("shmat");
}
printf("%s\n",addr);
if (shmdt(addr) != 0){
perror("shmdt");
}
return 0;
}
78. A server which is handling many clients at a time is called as
79. What is the output of this program?
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
int main()
{
int fd, count;
char ch, *buff;
buff = (char *)malloc(sizeof(char)*10);
fd = open("demo.c",O_RDONLY);
count = read(fd,buff,5);
printf("%d\n",count);
return 0;
}
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
int main()
{
int fd, count;
char ch, *buff;
buff = (char *)malloc(sizeof(char)*10);
fd = open("demo.c",O_RDONLY);
count = read(fd,buff,5);
printf("%d\n",count);
return 0;
}
80. The minor number range should be
Read More Section(Linux)
Each Section contains maximum 100 MCQs question on Linux. To get more questions visit other sections.