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 current process
c) minimum number of simultaneous processes per user id
d) none of the mentioned
View Answer
Explanation: None.
Output:
[root@localhost sanfoundry]# gcc -o san san.c
[root@localhost sanfoundry]# ./san
1024
[root@localhost sanfoundry]#
2. This program will print the
#include<stdio.h>
#include<unistd.h>
int main()
{
long int value;
value = sysconf(_SC_OPEN_MAX);
printf("%ld\n",value);
return 0;
}
a) maximum number of threads in current process
b) maximum number of files that a process can have open at a time
c) segmentation fault
d) none of the mentioned
View Answer
Explanation: None.
Output:
[root@localhost sanfoundry]# gcc -o san san.c
[root@localhost sanfoundry]# ./san
1024
[root@localhost sanfoundry]#
3. This program will print the
#include<stdio.h>
#include<unistd.h>
int main()
{
long int value;
value = pathconf("/home/sanfoundry",_PC_NAME_MAX);
printf("%ld\n",value);
return 0;
}
a) maximum numbers of the file that can store in this directory
b) maximum length of a filename in this directory that the process is allowed to create
c) segmentation fault
d) none of the mentioned
View Answer
Explanation: None.
Output:
[root@localhost sanfoundry]# gcc -o san san.c
[root@localhost sanfoundry]# ./san
255
[root@localhost sanfoundry]#
4. What is the output of this program?
#include<stdio.h>
#include<unistd.h>
#include<fcntl.h>
int main()
{
long int value;
int fd;
fd = open("/home/sanfoundry/san.c",O_RDONLY);
value = fpathconf(fd,_PC_LINK_MAX);
printf("%ld\n",value);
return 0;
}
a) this program will print the maximum number of links to the file “san.c”
b) this program will print nothing
c) this program will give an error
d) none of the mentioned
View Answer
Explanation: None.
Output:
[root@localhost sanfoundry]# gcc -o san san.c
[root@localhost sanfoundry]# ./san
65000
[root@localhost sanfoundry]#
5. 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\n",limit.rlim_cur);
printf("%lu\n",limit.rlim_max);
return 0;
}
a) soft limit of the size of the file in bytes that can be created by the process
b) hard limit of the size of the file in bytes that can be created by the process
c) soft 7 hard limit of the size of the file in bytes that can be created by the process
d) none of the mentioned
View Answer
Explanation: The rlim_cur member specifies the soft limit and rlim_max specifies the hard limit of the resource.
Output:
[root@localhost sanfoundry]# gcc -o san san.c
[root@localhost sanfoundry]# ./san
4294967295
4294967295
[root@localhost sanfoundry]#
6. What is the output of this program?
#include<stdio.h>
#include<sys/time.h>
#include<sys/resource.h>
int main()
{
struct rlimit limit;
if(getrlimit(RLIMIT_NOFILE,&limit) != 0)
perror("getrlimit");
printf("%lu\n",limit.rlim_max);
return 0;
}
a) this program will print the maximum numbers of the file descriptors that can be opened by a process
b) this program will print the maximum numbers of the child processes of the current process
c) this program will give an error because RLIMIT_NOFILE does not exist
d) none of the mentioned
View Answer
Explanation: None.
Output:
[root@localhost sanfoundry]# gcc -o san san.c
[root@localhost sanfoundry]# ./san
4096
[root@localhost sanfoundry]#
7. The hard limit of the file descriptors that can be opened by this process will become
#include<stdio.h>
#include<sys/time.h>
#include<sys/resource.h>
int main()
{
struct rlimit limit;
limit.rlim_cur = 10;
limit.rlim_max = 20;
if(setrlimit(RLIMIT_NOFILE,&limit) != 0)
perror("setrlimit");
if(getrlimit(RLIMIT_NOFILE,&limit) != 0)
perror("getrlimit");
printf("%lu\n",limit.rlim_cur);
printf("%lu\n",limit.rlim_max);
return 0;
}
a) 10
b) 20
c) permisssion denied
d) none of the mentioned
View Answer
Explanation: None.
8. What is the output of this program?
#include<stdio.h>
#include<sys/time.h>
#include<sys/resource.h>
int main()
{
struct rlimit limit;
limit.rlim_cur = 10;
if(setrlimit(RLIMIT_NOFILE,&limit) != 0)
perror("setrlimit");
return 0;
}
a) the soft limit of the file decriptors that can be opened by this process will become 10
b) the hard limit of the file decriptors that can be opened by this process will become 10
c) permission denied
d) none of the mentioned
View Answer
Explanation: None.
Output:
[root@localhost sanfoundry]# gcc -o san san.c
[root@localhost sanfoundry]# ./san
setrlimit: Operation not permitted
[root@localhost sanfoundry]#
9. What is the output of this program?
#include<stdio.h>
#include<sys/time.h>
#include<sys/resource.h>
int main()
{
struct rlimit limit;
if(getrlimit(RLIMIT_CORE,&limit) != 0)
perror("getrlimit");
printf("%lu\n",limit.rlim_max);
return 0;
}
a) maximum size of a core file that can be created by this process
b) maximum number of core files that can be created by this process
c) segmentaion fault
d) none of the mentioned
View Answer
Explanation: None.
Output:
[root@localhost sanfoundry]# gcc -o san san.c
[root@localhost sanfoundry]# ./san
4294967295
[root@localhost sanfoundry]#
10. What is the output of this program?
#include<stdio.h>
#include<sys/time.h>
#include<sys/resource.h>
int main()
{
struct rlimit limit;
if(getrlimit(RLIMIT_DATA,&limit) != 0)
perror("getrlimit");
printf("%lu\n",limit.rlim_max);
return 0;
}
a) maximum size of data segment of this process in bytes
b) maximum size of total available storage for this process in bytes
c) segmentaion fault
d) none of the mentioned
View Answer
Explanation: None.
Output:
[root@localhost sanfoundry]# gcc -o san san.c
[root@localhost sanfoundry]# ./san
4294967295
[root@localhost sanfoundry]#
Sanfoundry Global Education & Learning Series – Linux Administration & Programming.
Here’s the list of Best Books in Linux Commands & Shell Programming.
Here’s the list of Best Books in Linux Kernel, Device-Drivers & System Programming.
To practice all questions on Linux Administration & Programming, here is complete set of 1000+ Multiple Choice Questions and Answers on Linux.
- Apply for Programming Internship
- Practice Programming MCQs
- Check Linux Books
- Check Information Technology Books