Linux - Study Mode
[#856] What is the output of the below code? void sig_handler ( int signum) {
printf(“Handled the signal
”)
}
int main() {
int pid
signal (SIGKILL, sig_handler)
pid = fork()
if (pid==0) {
kill(getppid(), SIGKILL)
exit(0)
} else {
sleep(20)
}
return 0
}
Correct Answer
(D) Parent exits without going to the signal handler
[#857] What is the output of this program? #include<stdio.h>
#include<signal.h>
void response (int)
void response (int sig_no)
{
printf("%s
",sys_siglist[sig_no])
}
int main()
{
pid_t child
int status
child = fork()
switch(child){
case -1:
perror("fork")
case 0:
break
default :
signal(SIGCHLD,response)
wait(&status)
break
}
}
Correct Answer
(B) this program will print "Child Exited"
[#858] This program will allocate the memory of . . . . . . . . bytes for pointer "ptr". #include<stdio.h>
#include<stdlib.h>
int main()
{
int *ptr
ptr = (int*)malloc(sizeof(int)*4)
ptr = realloc(ptr,sizeof(int)*2)
return 0
}
Correct Answer
(C) 8
[#859] What is the output of the program? #! /usr/bin/awk -f
BEGIN {
a[1]="example"
a[2]="example"
for(i=1
i<3
i++) {
print a[i]
}
}
Correct Answer
(A) "example" will print 2 times
[#860] This program will print the #include<stdio.h>
#include<sys/time.h>
#include<sys/resource.h>
int main()
{
struct rlimit limit
getrlimit(RLIMIT_FSIZE,&limit)
printf("%lu
",limit.rlim_cur)
printf("%lu
",limit.rlim_max)
return 0
}
Correct Answer
(C) soft 7 hard limit of the size of the file in bytes that can be created by the process