Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Previous: Constants for Sysconf, Up: Sysconf

31.4.3 Examples of sysconf

We recommend that you first test for a macro definition for the parameter you are interested in, and call sysconf only if the macro is not defined. For example, here is how to test whether job control is supported:

     have_job_control (void)
     #ifdef _POSIX_JOB_CONTROL
       return 1;
       int value = sysconf (_SC_JOB_CONTROL);
       if (value < 0)
         /* If the system is that badly wedged,
            there's no use trying to go on.  */
         fatal (strerror (errno));
       return value;

Here is how to get the value of a numeric limit:

     get_child_max ()
     #ifdef CHILD_MAX
       return CHILD_MAX;
       int value = sysconf (_SC_CHILD_MAX);
       if (value < 0)
         fatal (strerror (errno));
       return value;

  Published under the terms of the GNU General Public License Design by Interspire