Linux Debugging Questions & Answers – Internet Domain Socket System Calls

This set of Linux Debugging questions and answers focuses on Internet Domain Socket System Calls. 1. What is the output of this program? #include<stdio.h> #include<sys/types.h> #include<sys/socket.h>  int main() { struct sockaddr_in addr; int fd; fd = socket(AF_INET,SOCK_STREAM,0); printf("%d\n",fd); return 0; } a) -1 b) 3 c) error d) none of the mentioned 2. What is … Read more

advertisement

Linux Debugging Questions & Answers – Unix Domain Sockets

This set of Linux Debugging questions and answers focuses on Unix Domain Sockets. 1. What is the output of this program? #include<stdio.h>  int main() { int fd_socket; fd_socket = socket(AF_UNIX,SOCK_STREAM,0); printf("%d\n",fd_socket); return 0; } a) -1 b) 0 c) any integer value d) none of the mentioned 2. In this program, the third argument of … Read more

advertisement

Linux Debugging Questions & Answers – POSIX IPCs – Message Queues, Shared Memory and Semaphores

This set of Linux Debugging questions and answers focuses on POSIX IPCs i.e. Message Queues, Shared Memory and Semaphores. 1. What is the output of this program? #include<stdio.h> #include<stdlib.h> #include<string.h> #include<sys/types.h> #include<sys/ipc.h> #include<sys/msg.h>  struct data_st{ long int id; char buff[11]; }; int main() { int m_id; struct data_st data1, data2; m_id = msgget((key_t)181,0666|IPC_CREAT); if(m_id == … Read more

advertisement

Linux Debugging Questions & Answers – System-V IPCs – Message Queues, Shared Memory and Semaphores

This set of Linux Debugging questions and answers focuses on the System-V IPCs i.e. Message Queues, Shared Memory and Semaphores. 1. What is the output of this program? #include<stdio.h> #include<fcntl.h> #include<sys/stat.h> #include<semaphore.h>  int main() { sem_t* sem_id; sem_id = sem_open("sem_value",O_CREAT,0666,0); if(sem_id == SEM_FAILED) perror("sem_open"); sem_wait(sem_id); printf("Sanfoundry\n"); if(sem_close(sem_id) == -1) perror("sem_close"); return 0; } a) this … Read more

advertisement

Linux Debugging Questions & Answers – Named and Un-named Pipe Calls

This set of Linux Debugging questions and answers focuses on Named and Un-named Pipe Calls. 1. 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 } a) this program will print the string “Linux” b) … Read more

advertisement

Tricky and Buggy Questions & Answers on PThreads Handling

This set of Tricky and Buggy questions and answers focuses on PThreads handling. 1. What is the output of this program #include<stdio.h> #include<pthread.h>  void *fun_t(void *arg); void *fun_t(void *arg) { pthread_exit("Bye"); } int main() { pthread_t pt; void *res_t; int ret; ret = pthread_join(pt,&res_t); printf("%d\n",ret); return 0; } a) 0 b) -1 c) 2 d) … Read more

advertisement

Linux Debugging Questions & Answers – Posix Threads

This set of Linux Debugging questions and answers focuses on Posix Threads. 1. Which one of the following string will print first by this program? #include<stdio.h> #include<pthread.h>  void *fun_t(void *arg); void *fun_t(void *arg) { printf("Sanfoundry\n"); pthread_exit("Bye"); } int main() { pthread_t pt; void *res_t; if(pthread_create(&pt,NULL,fun_t,NULL) != 0) perror("pthread_create"); printf("Linux\n"); if(pthread_join(pt,&res_t) != 0) perror("pthread_join"); return 0; … Read more

advertisement

Linux Debugging Questions & Answers – Timer, User & Resource Limit System Calls

This set of Linux Debugging questions and answers focuses on Timer, User and Resource Limit System Calls. 1. 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; } a) maximum number of simultaneous processes per user id b) maximum number of child processes of the … Read more

advertisement

Linux Debugging Questions & Answers – Signal Handling System Calls

This set of Linux Debugging questions and answers focuses on signal handling System Calls. 1. What will happen as we press the “Ctrl+c” key after running this program? #include<stdio.h> #include<signal.h>  void response (int); void response (int sig_no) { printf("Linux\n"); } int main() { signal(SIGINT,response); while(1){ printf("Sanfoundry\n"); sleep(1); } return 0; } a) the string “Linux” … Read more

advertisement

Linux Debugging Questions & Answers – fork, exec and wait System Calls

This set of Linux Debugging questions and answers focuses on the fork, exec and wait System Calls. 1. What is the output of this program? #include<stdio.h>  int main() { fork(); printf("Sanfoundry\n"); return 0; } a) the string “Sanfoundry” will print 1 time b) the string “Sanfoundry” will print 2 times c) the string “Sanfoundry” will … Read more

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.