categories and standard/system error codes

I have to admit to a bit of surprise at the confusion regarding <system_error> given Chris summarised exactly how it works at http://blog.think-async.com/2010/04/system-error-support-in-c0x-part-1.html and I personally find the C++ standard text above perfectly clear. But to summarise in very succinct words: If on POSIX: generic_category => POSIX standard errno space system_category => Local POSIX errno …

Read more

Delete all SYSTEM V shared memory and semaphores on UNIX-like systems

Here, save and try this script (kill_ipcs.sh) on your shell: #!/bin/bash ME=`whoami` IPCS_S=`ipcs -s | egrep “0x[0-9a-f]+ [0-9]+” | grep $ME | cut -f2 -d” “` IPCS_M=`ipcs -m | egrep “0x[0-9a-f]+ [0-9]+” | grep $ME | cut -f2 -d” “` IPCS_Q=`ipcs -q | egrep “0x[0-9a-f]+ [0-9]+” | grep $ME | cut -f2 -d” “` for …

Read more

What does WEXITSTATUS(status) return?

WEXITSTATUS(stat_val) is a macro (so in fact it does not “return” something, but “evaluates” to something). For how it works you might like to look it up in the headers (which should be #included via <sys/wait.h>) that come with the C-compiler you use. The implementation of this macro might differ from one C-implementation to the …

Read more

GCC with -std=c99 complains about not knowing struct timespec

Explicitly enabling POSIX features The timespec comes from POSIX, so you have to ‘enable’ POSIX definitions: #if __STDC_VERSION__ >= 199901L #define _XOPEN_SOURCE 600 #else #define _XOPEN_SOURCE 500 #endif /* __STDC_VERSION__ */ #include <time.h> void blah(struct timespec asdf) { } int main() { struct timespec asdf; return 0; } The stanza at the top is what …

Read more