Archive

Archive for May, 2007

Listing out the sysconf() values

Ever wondered how you could list out the defined sysconf() arguments constants and the sysconf() values for them. Well here is a simple bash script that worked for me:

#!/bin/bash

rm -f test.c

echo “#include <unistd.h>” >> test.c
echo “#include <stdio.h>” >> test.c
echo “main()” >> test.c
echo “{” >> test.c

for x in `echo “#include <unistd.h>” | cpp | grep _SC_ | cut -d ‘,’ -f 1 | awk ‘{print $1}’`
do
echo “printf(\”$x : %d\\n\”, sysconf($x));” >> test.c
done

echo “}” >> test.c

gcc test.c -o test

./test

rm -f test{,.c}

Categories: Programming
Follow

Get every new post delivered to your Inbox.