diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-02-27 17:26:06 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-02-27 17:26:06 +0000 |
commit | e1920b37dfc358ae73ce55665b36877c99db4e5b (patch) | |
tree | edc388bc9a36fc3c5d039ca3fe3647dcd8c71f88 | |
parent | b1374fdcf46709b5e014dc9dbfc78e0394e8d6aa (diff) | |
download | px4-nuttx-e1920b37dfc358ae73ce55665b36877c99db4e5b.tar.gz px4-nuttx-e1920b37dfc358ae73ce55665b36877c99db4e5b.tar.bz2 px4-nuttx-e1920b37dfc358ae73ce55665b36877c99db4e5b.zip |
Add NSH kill command
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3322 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r-- | nuttx/Documentation/NuttShell.html | 176 | ||||
-rw-r--r-- | nuttx/examples/nsh/README.txt | 24 | ||||
-rw-r--r-- | nuttx/examples/nsh/nsh.h | 5 | ||||
-rw-r--r-- | nuttx/examples/nsh/nsh_main.c | 8 | ||||
-rw-r--r-- | nuttx/examples/nsh/nsh_proccmds.c | 77 | ||||
-rw-r--r-- | nuttx/sched/sig_kill.c | 8 |
6 files changed, 208 insertions, 90 deletions
diff --git a/nuttx/Documentation/NuttShell.html b/nuttx/Documentation/NuttShell.html index 74170efee..045117b08 100644 --- a/nuttx/Documentation/NuttShell.html +++ b/nuttx/Documentation/NuttShell.html @@ -8,7 +8,7 @@ <tr align="center" bgcolor="#e4e4e4"> <td> <h1><big><font color="#3c34ec"><i>NuttShell (NSH)</i></font></big></h1> - <p>Last Updated: July 06, 2010</p> + <p>Last Updated: February 27, 2011</p> </td> </tr> </table> @@ -149,139 +149,145 @@ <tr> <td><br></td> <td> - <a href="#cmdlosetup">2.12 Setup/teardown the Loop Device (losetup)</a> + <a href="#cmdkill">2.12 Send a signal to a task (kill)</a> </td> </tr> <tr> <td><br></td> <td> - <a href="#cmdls">2.13 List Directory Contents (ls)</a> + <a href="#cmdlosetup">2.13 Setup/teardown the Loop Device (losetup)</a> </td> </tr> <tr> <td><br></td> <td> - <a href="#cmdmbhw">2.14 Access Memory (mb, mh, and mw)</a> + <a href="#cmdls">2.14 List Directory Contents (ls)</a> </td> </tr> <tr> <td><br></td> <td> - <a href="#cmdmem">2.15 Show Memory Manager Status (mem)</a> + <a href="#cmdmbhw">2.15 Access Memory (mb, mh, and mw)</a> </td> </tr> <tr> <td><br></td> <td> - <a href="#cmdps">2.16 Show Current Tasks and Threads (ps)</a> + <a href="#cmdmem">2.16 Show Memory Manager Status (mem)</a> </td> </tr> <tr> <td><br></td> <td> - <a href="#cmdmkdir">2.17 Create a Directory (mkdir)</a> + <a href="#cmdps">2.17 Show Current Tasks and Threads (ps)</a> </td> </tr> <tr> <td><br></td> <td> - <a href="#cmdmkfatfs">2.18 Create a FAT Filesystem (mkfatfs)</a> + <a href="#cmdmkdir">2.18 Create a Directory (mkdir)</a> </td> </tr> <tr> <td><br></td> <td> - <a href="#cmdmkfifo">2.19 Create a FIFO (mkfifo)</a> + <a href="#cmdmkfatfs">2.19 Create a FAT Filesystem (mkfatfs)</a> </td> </tr> <tr> <td><br></td> <td> - <a href="#cmdmkrd">2.20 Create a RAMDISK (mkrd)</a> + <a href="#cmdmkfifo">2.20 Create a FIFO (mkfifo)</a> </td> </tr> <tr> <td><br></td> <td> - <a href="#cmdmount">2.21 Mount a File System (mount)</a> + <a href="#cmdmkrd">2.21 Create a RAMDISK (mkrd)</a> </td> </tr> <tr> <td><br></td> <td> - <a href="#cmdping">2.22 Check Network Peer (ping)</a> + <a href="#cmdmount">2.22 Mount a File System (mount)</a> </td> </tr> <tr> <td><br></td> <td> - <a href="#cmdput">2.23 Send File Via TFTP (put)</a> + <a href="#cmdping">2.23 Check Network Peer (ping)</a> </td> </tr> <tr> <td><br></td> <td> - <a href="#cmdpwd">2.24 Show Current Working Directory (pwd)</a> + <a href="#cmdput">2.24 Send File Via TFTP (put)</a> </td> </tr> <tr> <td><br></td> <td> - <a href="#cmdrm">2.25 Remove a File (rm)</a> + <a href="#cmdpwd">2.25 Show Current Working Directory (pwd)</a> </td> </tr> <tr> <td><br></td> <td> - <a href="#cmdrmdir">2.26 Remove a Directory (rmdir)</a> + <a href="#cmdrm">2.26 Remove a File (rm)</a> </td> </tr> <tr> <td><br></td> <td> - <a href="#cmdset">2.27 Set an Environment Variable (set)</a> + <a href="#cmdrmdir">2.27 Remove a Directory (rmdir)</a> </td> </tr> <tr> <td><br></td> <td> - <a href="#cmdsh">2.28 Execute an NSH Script (sh)</a> + <a href="#cmdset">2.28 Set an Environment Variable (set)</a> </td> </tr> <tr> <td><br></td> <td> - <a href="#cmdsleep">2.29 Wait for Seconds (sleep)</a> + <a href="#cmdsh">2.29 Execute an NSH Script (sh)</a> </td> </tr> <tr> <td><br></td> <td> - <a href="#cmdunmount">2.30 Unmount a File System (umount)</a> + <a href="#cmdsleep">2.30 Wait for Seconds (sleep)</a> </td> </tr> <tr> <td><br></td> <td> - <a href="#cmdunset">2.31 Unset an Environment Variable (unset)</a> + <a href="#cmdunmount">2.31 Unmount a File System (umount)</a> </td> </tr> <tr> <td><br></td> <td> - <a href="#cmdusleep">2.32 Wait for Microseconds (usleep)</a> + <a href="#cmdunset">2.32 Unset an Environment Variable (unset)</a> </td> </tr> <tr> <td><br></td> <td> - <a href="#cmdwget">2.33 Get File Via HTTP (wget)</a> + <a href="#cmdusleep">2.33 Wait for Microseconds (usleep)</a> </td> </tr> <tr> <td><br></td> <td> - <a href="#cmdxd">2.34 Hexadecimal Dump (xd)</a> + <a href="#cmdwget">2.34 Get File Via HTTP (wget)</a> + </td> +</tr> +<tr> + <td><br></td> + <td> + <a href="#cmdxd">2.35 Hexadecimal Dump (xd)</a> </td> </tr> <tr> @@ -682,7 +688,7 @@ test <expression> </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> cat <code><path></code> [<code><path></code> [<code><path></code> ...]] </pre></ul> @@ -700,7 +706,7 @@ cat <code><path></code> [<code><path></code> [<code><path></co </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> cd [<dir-path>|-|~|..] </pre></ul> @@ -742,7 +748,7 @@ cd [<dir-path>|-|~|..] </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> cp <source-path> <dest-path> </pre></ul> @@ -760,7 +766,7 @@ cp <source-path> <dest-path> </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> dd if=<infile> of=<outfile> [bs=<sectsize>] [count=<sectors>] [skip=<sectors>] </pre></ul> @@ -819,7 +825,7 @@ nsh> dd if=/dev/ram0 of=/dev/null </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> echo [<string|$name> [<string|$name>...]] </pre></ul> @@ -856,7 +862,7 @@ exec <hex-address> </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> get [-b|-n] [-f <local-path>] -h <ip-address> <remote-path> </pre></ul> @@ -891,7 +897,7 @@ get [-b|-n] [-f <local-path>] -h <ip-address> <remote-path> </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> exit </pre></ul> @@ -910,7 +916,7 @@ exit </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> help </pre></ul> @@ -927,7 +933,7 @@ help </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> ifconfig </pre></ul> @@ -948,12 +954,28 @@ eth0 HWaddr 00:18:11:80:10:06 <table width ="100%"> <tr bgcolor="#e4e4e4"> <td> - <a name="cmdlosetup"><h2>2.12 Setup/teardown the Loop Device (losetup)</h2></a> + <a name="cmdkill"><h2>2.12 Send a signal to a task (kill)</h2></a> + </td> + </tr> +</table> + +<ul><pre> +kill -<signal> <pid> +</pre></ul> +<p> + <b>Synopsis</b>. + Send the <signal> to the task identified by <pid>. +</p> + +<table width ="100%"> + <tr bgcolor="#e4e4e4"> + <td> + <a name="cmdlosetup"><h2>2.13 Setup/teardown the Loop Device (losetup)</h2></a> </td> </tr> </table> -<a <p><b>Command Syntax 1:</b></p> +<p><b>Command Syntax 1:</b></p> <ul><pre> losetup [-o <offset>] [-r] <dev-path> <file-path> </pre></ul> @@ -989,7 +1011,7 @@ nsh> </pre></ul> </p> -<a <p><b>Command Syntax 2:</b></p> +<p><b>Command Syntax 2:</b></p> <ul><pre> losetup d <dev-path> </pre></ul> @@ -1001,12 +1023,12 @@ losetup d <dev-path> <table width ="100%"> <tr bgcolor="#e4e4e4"> <td> - <a name="cmdls"><h2>2.13 List Directory Contents (ls)</h2></a> + <a name="cmdls"><h2>2.14 List Directory Contents (ls)</h2></a> </td> </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> ls [-lRs] <dir-path> </pre></ul> @@ -1038,7 +1060,7 @@ ls [-lRs] <dir-path> <table width ="100%"> <tr bgcolor="#e4e4e4"> <td> - <a name="cmdmbhw"><h2>2.14 Access Memory (mb, mh, and mw)</h2></a> + <a name="cmdmbhw"><h2>2.15 Access Memory (mb, mh, and mw)</h2></a> </td> </tr> </table> @@ -1092,12 +1114,12 @@ nsh> <table width ="100%"> <tr bgcolor="#e4e4e4"> <td> - <a name="cmdmem"><h2>2.15 Show Memory Manager Status (mem)</h2></a> + <a name="cmdmem"><h2>2.16 Show Memory Manager Status (mem)</h2></a> </td> </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> mem </pre></ul> @@ -1141,12 +1163,12 @@ nsh> <table width ="100%"> <tr bgcolor="#e4e4e4"> <td> - <a name="cmdps"><h2>2.16 Show Current Tasks and Threads (ps)</h2></a> + <a name="cmdps"><h2>2.17 Show Current Tasks and Threads (ps)</h2></a> </td> </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> ps </pre></ul> @@ -1167,7 +1189,7 @@ nsh> <table width ="100%"> <tr bgcolor="#e4e4e4"> <td> - <a name="cmdmkdir"><h2>2.17 Create a Directory (mkdir)</h2></a> + <a name="cmdmkdir"><h2>2.18 Create a Directory (mkdir)</h2></a> </td> </tr> </table> @@ -1202,7 +1224,7 @@ nsh> <table width ="100%"> <tr bgcolor="#e4e4e4"> <td> - <a name="cmdmkfatfs"><h2>2.18 Create a FAT Filesystem (mkfatfs)</h2></a> + <a name="cmdmkfatfs"><h2>2.19 Create a FAT Filesystem (mkfatfs)</h2></a> </td> </tr> </table> @@ -1222,7 +1244,7 @@ mkfatfs <path> <table width ="100%"> <tr bgcolor="#e4e4e4"> <td> - <a name="cmdmkfifo"><h2>2.19 Create a FIFO (mkfifo)</h2></a> + <a name="cmdmkfifo"><h2>2.20 Create a FIFO (mkfifo)</h2></a> </td> </tr> </table> @@ -1260,7 +1282,7 @@ nsh> <table width ="100%"> <tr bgcolor="#e4e4e4"> <td> - <a name="cmdmkrd"><h2>2.20 Create a RAMDISK (mkrd)</h2></a> + <a name="cmdmkrd"><h2>2.21 Create a RAMDISK (mkrd)</h2></a> </td> </tr> </table> @@ -1311,7 +1333,7 @@ nsh> <table width ="100%"> <tr bgcolor="#e4e4e4"> <td> - <a name="cmdmount"><h2>2.21 Mount a File System (mount)</h2></a> + <a name="cmdmount"><h2>2.22 Mount a File System (mount)</h2></a> </td> </tr> </table> @@ -1378,12 +1400,12 @@ nsh> <table width ="100%"> <tr bgcolor="#e4e4e4"> <td> - <a name="cmdping"><h2>2.22 Check Network Peer (ping)</h2></a> + <a name="cmdping"><h2>2.23 Check Network Peer (ping)</h2></a> </td> </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> ping [-c <count>] [-i <interval>] <ip-address> </pre></ul> @@ -1411,12 +1433,12 @@ nsh> <table width ="100%"> <tr bgcolor="#e4e4e4"> <td> - <a name="cmdput"><h2>2.23 Send File Via TFTP (put)</h2></a> + <a name="cmdput"><h2>2.24 Send File Via TFTP (put)</h2></a> </td> </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> put [-b|-n] [-f <remote-path>] -h <ip-address> <local-path> </pre></ul> @@ -1446,12 +1468,12 @@ put [-b|-n] [-f <remote-path>] -h <ip-address> <local-path> <table width ="100%"> <tr bgcolor="#e4e4e4"> <td> - <a name="cmdpwd"><h2>2.24 Show Current Working Directory (pwd)</h2></a> + <a name="cmdpwd"><h2>2.25 Show Current Working Directory (pwd)</h2></a> </td> </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> pwd </pre></ul> @@ -1476,12 +1498,12 @@ nsh> <table width ="100%"> <tr bgcolor="#e4e4e4"> <td> - <a name="cmdrm"><h2>2.25 Remove a File (rm)</h2></a> + <a name="cmdrm"><h2>2.26 Remove a File (rm)</h2></a> </td> </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> rm <file-path> </pre></ul> @@ -1510,12 +1532,12 @@ nsh> <table width ="100%"> <tr bgcolor="#e4e4e4"> <td> - <a name="cmdrmdir"><h2>2.26 Remove a Directory (rmdir)</h2></a> + <a name="cmdrmdir"><h2>2.27 Remove a Directory (rmdir)</h2></a> </td> </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> rmdir <dir-path> </pre></ul> @@ -1545,12 +1567,12 @@ nsh> <table width ="100%"> <tr bgcolor="#e4e4e4"> <td> - <a name="cmdset"><h2>2.27 Set an Environment Variable (set)</h2></a> + <a name="cmdset"><h2>2.28 Set an Environment Variable (set)</h2></a> </td> </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> set <name> <value> </pre></ul> @@ -1571,12 +1593,12 @@ nsh> <table width ="100%"> <tr bgcolor="#e4e4e4"> <td> - <a name="cmdsh"><h2>2.28 Execute an NSH Script (sh)</h2></a> + <a name="cmdsh"><h2>2.29 Execute an NSH Script (sh)</h2></a> </td> </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> sh <script-path> </pre></ul> @@ -1589,12 +1611,12 @@ sh <script-path> <table width ="100%"> <tr bgcolor="#e4e4e4"> <td> - <a name="cmdsleep"><h2>2.29 Wait for Seconds (sleep)</h2></a> + <a name="cmdsleep"><h2>2.30 Wait for Seconds (sleep)</h2></a> </td> </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> sleep <sec> </pre></ul> @@ -1606,12 +1628,12 @@ sleep <sec> <table width ="100%"> <tr bgcolor="#e4e4e4"> <td> - <a name="cmdunmount"><h2>2.30 Unmount a File System (umount)</h2></a> + <a name="cmdunmount"><h2>2.31 Unmount a File System (umount)</h2></a> </td> </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> umount <dir-path> </pre></ul> @@ -1636,12 +1658,12 @@ nsh> <table width ="100%"> <tr bgcolor="#e4e4e4"> <td> - <a name="cmdunset"><h2>2.31 Unset an Environment Variable (unset)</h2></a> + <a name="cmdunset"><h2>2.32 Unset an Environment Variable (unset)</h2></a> </td> </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> unset <name> </pre></ul> @@ -1662,12 +1684,12 @@ nsh> <table width ="100%"> <tr bgcolor="#e4e4e4"> <td> - <a name="cmdusleep"><h2>2.32 Wait for Microseconds (usleep)</h2></a> + <a name="cmdusleep"><h2>2.33 Wait for Microseconds (usleep)</h2></a> </td> </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> usleep <usec> </pre></ul> @@ -1679,12 +1701,12 @@ usleep <usec> <table width ="100%"> <tr bgcolor="#e4e4e4"> <td> - <a name="cmdwget">2.33 Get File Via HTTP (wget)</a> + <a name="cmdwget">2.34 Get File Via HTTP (wget)</a> </td> </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> wget [-o <local-path>] <url> </pre></ul> @@ -1706,12 +1728,12 @@ wget [-o <local-path>] <url> <table width ="100%"> <tr bgcolor="#e4e4e4"> <td> - <a name="cmdxd"><h2>2.34 Hexadecimal dump (xd)</h2></a> + <a name="cmdxd"><h2>2.35 Hexadecimal dump (xd)</h2></a> </td> </tr> </table> -<a <p><b>Command Syntax:</b></p> +<p><b>Command Syntax:</b></p> <ul><pre> xd <hex-address> <byte-count> </pre></ul> @@ -1826,6 +1848,11 @@ nsh> <td><code>CONFIG_EXAMPLES_NSH_DISABLE_IFCONFIG</code></td> </tr> <tr> + <td><b><code>kill</code></b></td> + <td>!<code>CONFIG_DISABLE_SIGNALS</code></td> + <td><code>CONFIG_EXAMPLES_NSH_DISABLE_KILL</code></td> + </tr> + <tr> <td><b><code>losetup</code></b></td> <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0</td> <td><code>CONFIG_EXAMPLES_NSH_DISABLE_LOSETUP</code></td> @@ -2331,6 +2358,7 @@ nsh> <li><a href="#cmdhelp"><code>help</code></a></li> <li><a href="#conditional"><code>if-then[-else]-fi</code></a></li> <li><a href="#cmdifconfig"><code>ifconfig</code></a></li> + <li><a href="#cmdkill"><code>kill</code></a></li> <li><a href="#cmdlosetup"><code>losetup</code></a></li> <li><a href="#cmdls">ls</code></a></li> <li><a href="#cmdmbhw"><code>mb</code></a></li> diff --git a/nuttx/examples/nsh/README.txt b/nuttx/examples/nsh/README.txt index 73c281558..bbe1429d8 100644 --- a/nuttx/examples/nsh/README.txt +++ b/nuttx/examples/nsh/README.txt @@ -329,6 +329,10 @@ o ifconfig if uIP statistics are enabled (CONFIG_NET_STATISTICS), then this command will also show the detailed state of uIP. +o kill -<signal> <pid> + + Send the <signal> to the task identified by <pid>. + o losetup [-d <dev-path>] | [[-o <offset>] [-r] <ldev-path> <file-path>] Setup or teardown the loop device: @@ -769,6 +773,7 @@ Command Dependencies on Configuration Settings get CONFIG_NET && CONFIG_NET_UDP && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NET_BUFSIZE >= 558 (see note 1) help -- ifconfig CONFIG_NET + kill !CONFIG_DISABLE_SIGNALS losetup !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 ls CONFIG_NFILE_DESCRIPTORS > 0 mb,mh,mw --- @@ -812,15 +817,16 @@ also allow it to squeeze into very small memory footprints. CONFIG_EXAMPLES_NSH_DISABLE_CAT, CONFIG_EXAMPLES_NSH_DISABLE_CD, CONFIG_EXAMPLES_NSH_DISABLE_CP, CONFIG_EXAMPLES_NSH_DISABLE_DD, CONFIG_EXAMPLES_NSH_DISABLE_ECHO, CONFIG_EXAMPLES_NSH_DISABLE_EXEC, CONFIG_EXAMPLES_NSH_DISABLE_EXIT, CONFIG_EXAMPLES_NSH_DISABLE_GET, CONFIG_EXAMPLES_NSH_DISABLE_HELP, - CONFIG_EXAMPLES_NSH_DISABLE_IFCONFIG, CONFIG_EXAMPLES_NSH_DISABLE_LOSETUP, CONFIG_EXAMPLES_NSH_DISABLE_LS, - CONFIG_EXAMPLES_NSH_DISABLE_MB, CONFIG_EXAMPLES_NSH_DISABLE_MEM, CONFIG_EXAMPLES_NSH_DISABLE_MKDIR, - CONFIG_EXAMPLES_NSH_DISABLE_MKFATFS, CONFIG_EXAMPLES_NSH_DISABLE_MKFIFO, CONFIG_EXAMPLES_NSH_DISABLE_MKRD, - CONFIG_EXAMPLES_NSH_DISABLE_MH, CONFIG_EXAMPLES_NSH_DISABLE_MOUNT, CONFIG_EXAMPLES_NSH_DISABLE_MW, - CONFIG_EXAMPLES_NSH_DISABLE_PS, CONFIG_EXAMPLES_NSH_DISABLE_PING, CONFIG_EXAMPLES_NSH_DISABLE_PUT, - CONFIG_EXAMPLES_NSH_DISABLE_PWD, CONFIG_EXAMPLES_NSH_DISABLE_RM, CONFIG_EXAMPLES_NSH_DISABLE_RMDIR, - CONFIG_EXAMPLES_NSH_DISABLE_SET, CONFIG_EXAMPLES_NSH_DISABLE_SH, CONFIG_EXAMPLES_NSH_DISABLE_SLEEP, - CONFIG_EXAMPLES_NSH_DISABLE_TEST, CONFIG_EXAMPLES_NSH_DISABLE_UMOUNT, CONFIG_EXAMPLES_NSH_DISABLE_UNSET, - CONFIG_EXAMPLES_NSH_DISABLE_USLEEP, CONFIG_EXAMPLES_NSH_DISABLE_WGET, CONFIG_EXAMPLES_NSH_DISABLE_XD + CONFIG_EXAMPLES_NSH_DISABLE_IFCONFIG, CONFIG_EXAMPLES_NSH_DISABLE_KILL, CONFIG_EXAMPLES_NSH_DISABLE_LOSETUP, + CONFIG_EXAMPLES_NSH_DISABLE_LS, CONFIG_EXAMPLES_NSH_DISABLE_MB, CONFIG_EXAMPLES_NSH_DISABLE_MEM, + CONFIG_EXAMPLES_NSH_DISABLE_MKDIR, CONFIG_EXAMPLES_NSH_DISABLE_MKFATFS, CONFIG_EXAMPLES_NSH_DISABLE_MKFIFO, + CONFIG_EXAMPLES_NSH_DISABLE_MKRD, CONFIG_EXAMPLES_NSH_DISABLE_MH, CONFIG_EXAMPLES_NSH_DISABLE_MOUNT, + CONFIG_EXAMPLES_NSH_DISABLE_MW, CONFIG_EXAMPLES_NSH_DISABLE_PS, CONFIG_EXAMPLES_NSH_DISABLE_PING, + CONFIG_EXAMPLES_NSH_DISABLE_PUT, CONFIG_EXAMPLES_NSH_DISABLE_PWD, CONFIG_EXAMPLES_NSH_DISABLE_RM, + CONFIG_EXAMPLES_NSH_DISABLE_RMDIR, CONFIG_EXAMPLES_NSH_DISABLE_SET, CONFIG_EXAMPLES_NSH_DISABLE_SH, + CONFIG_EXAMPLES_NSH_DISABLE_SLEEP, CONFIG_EXAMPLES_NSH_DISABLE_TEST, CONFIG_EXAMPLES_NSH_DISABLE_UMOUNT, + CONFIG_EXAMPLES_NSH_DISABLE_UNSET, CONFIG_EXAMPLES_NSH_DISABLE_USLEEP, CONFIG_EXAMPLES_NSH_DISABLE_WGET, + CONFIG_EXAMPLES_NSH_DISABLE_XD NSH-Specific Configuration Settings ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/nuttx/examples/nsh/nsh.h b/nuttx/examples/nsh/nsh.h index c1c1a9ed8..29bd19b98 100644 --- a/nuttx/examples/nsh/nsh.h +++ b/nuttx/examples/nsh/nsh.h @@ -1,7 +1,7 @@ /**************************************************************************** * examples/nsh/nsh.h * - * Copyright (C) 2007-2010 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -474,6 +474,9 @@ extern int cmd_lbracket(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); #endif /* CONFIG_DISABLE_ENVIRON */ #ifndef CONFIG_DISABLE_SIGNALS +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_KILL + extern int cmd_kill(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# endif # ifndef CONFIG_EXAMPLES_NSH_DISABLE_SLEEP extern int cmd_sleep(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); # endif diff --git a/nuttx/examples/nsh/nsh_main.c b/nuttx/examples/nsh/nsh_main.c index 223a3537c..80a9eb8e1 100644 --- a/nuttx/examples/nsh/nsh_main.c +++ b/nuttx/examples/nsh/nsh_main.c @@ -1,7 +1,7 @@ /**************************************************************************** * examples/nsh/nsh_main.c * - * Copyright (C) 2007-2010 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -189,6 +189,12 @@ static const struct cmdmap_s g_cmdmap[] = # endif #endif +#ifndef CONFIG_DISABLE_SIGNALS +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_SLEEP + { "kill", cmd_kill, 3, 3, "kill -<signal> <pid>" }, +# endif +#endif + #if CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT) # ifndef CONFIG_EXAMPLES_NSH_DISABLE_LOSETUP { "losetup", cmd_losetup, 3, 6, "[-d <dev-path>] | [[-o <offset>] [-r] <dev-path> <file-path>]" }, diff --git a/nuttx/examples/nsh/nsh_proccmds.c b/nuttx/examples/nsh/nsh_proccmds.c index 6c0c14e37..5c3f6db60 100644 --- a/nuttx/examples/nsh/nsh_proccmds.c +++ b/nuttx/examples/nsh/nsh_proccmds.c @@ -1,7 +1,7 @@ /**************************************************************************** * examples/nsh/nsh_proccmds.c * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -43,6 +43,7 @@ #include <stdlib.h> #include <unistd.h> #include <sched.h> +#include <errno.h> #include "nsh.h" @@ -176,6 +177,80 @@ int cmd_ps(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) #endif /**************************************************************************** + * Name: cmd_kill + ****************************************************************************/ + +#ifndef CONFIG_DISABLE_SIGNALS +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_KILL +int cmd_kill(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) +{ + char *ptr; + char *endptr; + long signal; + long pid; + + /* Check incoming parameters. The first parameter should be "-<signal>" */ + + ptr = argv[1]; + if (*ptr != '-' || ptr[1] < '0' || ptr[1] > '9') + { + goto invalid_arg; + } + + /* Extract the signal number */ + + signal = strtol(&ptr[1], &endptr, 0); + + /* The second parameter should be <pid> */ + + ptr = argv[2]; + if (*ptr < '0' || *ptr > '9') + { + goto invalid_arg; + } + + /* Extract athe pid */ + + pid = strtol(ptr, &endptr, 0); + + /* Send the signal. Kill return values: + * + * EINVAL An invalid signal was specified. + * EPERM The process does not have permission to send the signal to any + * of the target processes. + * ESRCH The pid or process group does not exist. + * ENOSYS Do not support sending signals to process groups. + */ + + if (kill((pid_t)pid, (int)signal) == 0) + { + return OK; + } + + switch (errno) + { + case EINVAL: + goto invalid_arg; + + case ESRCH: + nsh_output(vtbl, g_fmtnosuch, argv[0], "task", argv[2]); + return ERROR; + + case EPERM: + case ENOSYS: + default: + nsh_output(vtbl, g_fmtcmdfailed, argv[0], "kill", NSH_ERRNO); + return ERROR; + } + +invalid_arg: + nsh_output(vtbl, g_fmtarginvalid, argv[0]); + return ERROR; +} +#endif +#endif + +/**************************************************************************** * Name: cmd_sleep ****************************************************************************/ diff --git a/nuttx/sched/sig_kill.c b/nuttx/sched/sig_kill.c index 7d36ac4b1..5e9125088 100644 --- a/nuttx/sched/sig_kill.c +++ b/nuttx/sched/sig_kill.c @@ -1,7 +1,7 @@ /************************************************************************ * sched/sig_kill.c * - * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -96,7 +96,7 @@ int kill(pid_t pid, int signo) if (pid <= 0) { - *get_errno_ptr() = ENOSYS; + errno = ENOSYS; return ERROR; } @@ -104,7 +104,7 @@ int kill(pid_t pid, int signo) if (!GOOD_SIGNO(signo)) { - *get_errno_ptr() = EINVAL; + errno = EINVAL; return ERROR; } @@ -118,7 +118,7 @@ int kill(pid_t pid, int signo) sdbg("TCB=0x%08x signo=%d\n", stcb, signo); if (!stcb) { - *get_errno_ptr() = ESRCH; + errno = ESRCH; sched_unlock(); return ERROR; } |