How to convert signal name (string) to signal code?

Not sure if that is what you are loking for, but: strerror() converts a error code to the error message, similar strsignal() converts a signal to the signal message.

Not sure if that is what you are loking for, but: strerror() converts a error code to the error message, similar strsignal() converts a signal to the signal message. Fprintf(stdout, "signal 9: %s\n", strsignal(9)); fprintf(stdout, "errno 60: %s\n", strerror(60)); Output: signal 9: Killed errno 60: Device not a stream.

Ah well I just re-read your question and your converting from string to nr, so my answer will not be helpful :) – Chris Aug 9 at 0:35 But it can be helpful - just combine it with OP's map. Instead of filling in the map manually, use a for ( n=1; n Instead of SIGTERM it returns TERMINATE (in my Linux, at least). – atzz Aug 9 at 7:42 @Chris...thanks for letting me know of strsignal() function.

Thats interesting. – blu3bird Aug 9 at 17:32.

You can use a command line like this kill -l \ | sed 's/0-9*)//g' \ | xargs -n1 echo \ | awk '{ print "signal_map\"" $0 "\" = " $0 ";" }' It will write your map for you.

Using C++0x you can use initializer lists to make this more simple: const std::map signal_map{ {"SIGSTOP", SIGSTOP }, {"SIGKILL", SIGKILL }, ... }; This get's you the map at less code to write. If you want to you could also some preprocessor magic to get the code even simpler and avoid writing the name multiple times. But most often abusing the preprocessor just leads to less usable code not better code.(Note that preprocessor magic can still be used if you decide not to use C++0x and keep your way).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions