How to convert errno in UNIX to corresponding string?

后端 未结 6 1593
悲哀的现实
悲哀的现实 2020-12-16 08:57

Is there any function in UNIX to the convert errno to its corresponding string for e.g. EIDRM to \"EIDRM\". Its very annoying to debug to check for errors with these integer

6条回答
  •  情深已故
    2020-12-16 09:53

    If you do indeed want EIDRM and not its error string: no. However, on OpenBSD,

    man errno|egrep ' [0-9]+ E[A-Z]+'|sed 's/^ *//'|cut -d' ' -f1,2
    

    prints out a nice table of "...\n89 EIDM\n..." that you can convert further into a data structure for the programming language that you'd like to have this function in.

提交回复
热议问题