Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Signal name for signal number

Status
Not open for further replies.

feherke

Programmer
Aug 5, 2002
9,541
RO
Hi

I need to find out the signal name for a signal number. For example, for the number 15, to get the string SIGTERM.

I use [tt]Bash[/tt], and I'm interested in solutions other then using an array. ( Handmade, or generated from [tt]kill -l[/tt] or [tt]trap -l[/tt] output. )

Feherke.
 
A starting point:
signum=15
kill -l | sed -n "${signum}p"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi

Good idea in on point : the list of the [tt]kill[/tt] built-in of [tt]Bash[/tt] is different then the one of [tt]/bin/kill[/tt].

Sadly, the built-in's list is on multiple columns affected by [tt]$COLUMNS[/tt] and the standalone's list is not ordered. But anyway, both has gaps.

Feherke.
 
In bash:
signum=15
kill -l | awk '{for(i=1;i<NF;++i)if($i=="'$signum')")print $(i+1)}'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top