23.
What is the output of this program?
#include<stdio.h>
#include<fcntl.h>
 
int main()
{
    int fd, count;
    char ch;
    fd = open("demo.txt",O_RDWR|O_CREAT);
    write(fd,"s",1);
    lseek(fd,0,SEEK_SET);
    write(fd,"d",1);
    lseek(fd,0,0);
    read(fd,&ch,1);
    printf("%c\n",ch);
    return 0;
}

25.
What is the output of this program?
#include<stdio.h>
#include<fcntl.h>
#include<sys/stat.h>
#include<sys/mman.h>
 
int main()
{
    int s_id;
    int *ptr;
    s_id = shm_open("shared_mem",O_CREAT|O_RDWR,0666);
    if(s_id == -1)
        perror("shm_open");
    ptr = mmap(NULL,100,PROT_WRITE,MAP_PRIVATE,s_id,0);
    if(ptr == MAP_FAILED);
        perror("mmap");
    ptr = mmap(ptr,100,PROT_WRITE,MAP_PRIVATE,s_id,0);
    if(ptr == MAP_FAILED);
        perror("mmap");
    if(munmap(ptr,100) == -1)
        perror("munmap");
    if(shm_unlink("shared_mem") == -1)
        perror("shm_unlink");
       return 0;
   }

26.
What is the output of this program?
#include<stdio.h>
#include<string.h>
 
int main()
{
    int fd[2];
    int count;
    char buffer[6];
    if( pipe(fd) != 0)
        perror("pipe");
    memset(buffer,'\0',6);
    count=write(fd[1],"Linux",6);
    read(fd[0],buffer,6);
    printf("%s\n",buffer);
    return 0;put
}

28.
This program will print
#include<stdio.h>
#include<signal.h>
#include<unistd.h>
 
void response (int);
void response (int sig_no)
{
    printf("%s is working\n",sys_siglist[sig_no]);
}
int main()
{
    alarm(5);
    sleep(50);
    printf("Example\n");        
    signal(SIGALRM,response);
    return 0;
}

29.
What is the role of linker in the compilation process?

30.
What is the output of this program?
#include<stdio.h>
#include<stdlib.h>
 
int main()
{
    int *ptr1, *ptr2;
    ptr1 = malloc(4);
    *ptr1 = 10;
    *ptr2 = free(ptr1);
    printf("%d\n",*ptr2);
    return 0;
}

Read More Section(Linux)

Each Section contains maximum 100 MCQs question on Linux. To get more questions visit other sections.