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;
}
Answer: Option 'A'
maximum number of simultaneous processes per user id
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;
}
Answer: Option 'A'
maximum number of threads in current process
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;
}
Answer: Option 'B'
maximum length of a filename in this directory that the process is allowed to create
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;
}
Answer: Option 'A'
this program will print the maximum number of links to the file “san.c”
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;
}
Answer: Option 'C'
soft 7 hard limit of the size of the file in bytes that can be created by the process
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;
}
Answer: Option 'A'
[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;
}
Answer: Option 'B'
20
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;
}
Answer: Option 'C'
permission denied
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;
}
Answer: Option 'A'
maximum size of a core file that can be created by this process
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;
}
Answer: Option 'B'
maximum size of total available storage for this process in bytes