Interviewer And Interviewee Guide

Linux Debugging Interview Question:

What is the output of this program no 1?
#include<stdio.h>
#include<pthread.h>

void *fun_t(void *arg);
void *fun_t(void *arg)
{
printf("googlen");
pthread_exit("Bye");
}
int main()
{
pthread_t pt;
void *res_t;
if(pthread_create(&pt,NULL,fun_t,NULL) != 0)
perror("pthread_create");
return 0;
}
a) this program will print the string "google"
b) this program will print nothing
c) segmentation fault
d) run time error

Submitted by: Murtaza
b) this program will print nothing
Explanation:The pthread_join() function waits for the thread to terminate.
Output:
[root@localhost google]# gcc -o san san.c -lpthread
[root@localhost google]# ./san
[root@localhost google]#
Submitted by: Murtaza

Read Online Linux Debugging Job Interview Questions And Answers
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.