Index: /EcnlProtoTool/trunk/ntshell/src/main.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/src/main.c	(revision 430)
+++ /EcnlProtoTool/trunk/ntshell/src/main.c	(revision 431)
@@ -79,4 +79,20 @@
 char command[NTOPT_TEXT_MAXLEN];
 ntstdio_t ntstdio;
+ntshell_t ntshell;
+
+unsigned char ntstdio_xi(struct ntstdio_t *handle)
+{
+	char buf[1];
+	if(serial_rea_dat(SIO_PORTID, buf, 1) != 1)
+		return -EIO;
+	return buf[0];
+}
+
+void ntstdio_xo(struct ntstdio_t *handle, unsigned char c)
+{
+	char buf[1];
+	buf[0] = c;
+	serial_wri_dat(SIO_PORTID, buf, 1);
+}
 
 const uint8_t mac_addr[6] = {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC};
@@ -90,6 +106,9 @@
 };
 
-static void netif_link_callback(T_IFNET *ether);
-extern int execute_command(int wait);
+int shell_uname(struct utsname *uts)
+{
+	memcpy(uts, &host_name, sizeof(host_name));
+	return 0;
+}
 
 enum main_state_t {
@@ -98,5 +117,5 @@
 };
 
-struct main_t {
+struct main_obj_t {
 	TMO timer;
 	enum main_state_t state;
@@ -106,10 +125,18 @@
 	WS_FBS_ID sndmsg;
 };
-struct main_t main_obj;
-
+struct main_obj_t main_obj;
+
+static void netif_link_callback(T_IFNET *ether);
 static void main_initialize();
 static TMO main_get_timer();
 static void main_progress(TMO interval);
 static void main_timeout();
+extern int execute_command(int wait);
+static int usrcmd_ntopt_callback(long *args, void *extobj);
+
+int shellcmd_exit_code;
+volatile int shellcmd_state;
+typedef void (*PowerOn_Reset_t)(long *args);
+jmp_buf shellcmd_exit;
 
 int uart_read(char *buf, int cnt, void *extobj)
@@ -225,21 +252,19 @@
 }
 
-unsigned char ntstdio_xi(struct ntstdio_t *handle)
-{
-	char buf[1];
-	if(serial_rea_dat(SIO_PORTID, buf, 1) != 1)
-		return -EIO;
-	return buf[0];
-}
-
-void ntstdio_xo(struct ntstdio_t *handle, unsigned char c)
-{
-	char buf[1];
-	buf[0] = c;
-	serial_wri_dat(SIO_PORTID, buf, 1);
-}
-
-ntshell_t ntshell;
-static int cmd_execute(const char *text, void *extobj);
+static int cmd_execute(const char *text, void *extobj)
+{
+	if (text != NULL) {
+		ntlibc_strlcpy(command, text, sizeof(command));
+	}
+	ER ret;
+	ID tskid = 0;
+
+	ret = get_tid(&tskid);
+	if (ret != E_OK) {
+		syslog(LOG_ERROR, "get_tid %d", ret);
+	}
+
+	return execute_command(tskid == MAIN_TASK);
+}
 
 /*
@@ -363,5 +388,5 @@
 	ER ret;
 
-	ret = ref_tsk(MRUBY_TASK, &rtsk);
+	ret = ref_tsk(SHELLCMD_TASK, &rtsk);
 	if ((ret != E_OK) || (rtsk.tskstat == TTS_DMT))
 		return;
@@ -372,23 +397,12 @@
 }
 
-int shell_uname(struct utsname *uts)
-{
-	return memcpy(uts, &host_name, sizeof(host_name));
-}
-
-static int usrcmd_ntopt_callback(long *args, void *extobj);
-int mruby_exit_code;
-volatile int mruby_state;
-typedef void (*PowerOn_Reset_t)(long *args);
-jmp_buf process_exit;
-
 /*
- *  mruby実行タスク
+ *  shellcmdタスク
  */
-void mruby_task(intptr_t exinf)
-{
-	mruby_state = 1;
-	mruby_exit_code = ntopt_parse(command, usrcmd_ntopt_callback, NULL);
-	mruby_state = 2;
+void shellcmd_task(intptr_t exinf)
+{
+	shellcmd_state = 1;
+	shellcmd_exit_code = ntopt_parse(command, usrcmd_ntopt_callback, NULL);
+	shellcmd_state = 2;
 }
 
@@ -424,5 +438,5 @@
 		p++;
 	}
-	if (setjmp(process_exit) == 0) {
+	if (setjmp(shellcmd_exit) == 0) {
 		(*((PowerOn_Reset_t *)0x18220000))(args);
 	}
@@ -447,11 +461,11 @@
 {
 	/* メインタスクの優先度より高くする */
-	chg_pri(MRUBY_PRIORITY, MAIN_PRIORITY + 1);
+	chg_pri(SHELLCMD_PRIORITY, MAIN_PRIORITY + 1);
 }
 
 void shellif_outof()
 {
-	/* mruby実行タスクの優先度に戻す */
-	chg_pri(MRUBY_PRIORITY, MRUBY_PRIORITY);
+	/* shellcmdタスクの優先度に戻す */
+	chg_pri(SHELLCMD_PRIORITY, SHELLCMD_PRIORITY);
 }
 
@@ -460,18 +474,18 @@
 	asm("bkpt #0");
 
-	mruby_exit_code = -1;
-	longjmp(process_exit, 1);
+	shellcmd_exit_code = -1;
+	longjmp(shellcmd_exit, 1);
 }
 
 void shell_exit(int exitcd)
 {
-	mruby_exit_code = exitcd;
-	longjmp(process_exit, 1);
+	shellcmd_exit_code = exitcd;
+	longjmp(shellcmd_exit, 1);
 }
 
 void shell_exit_group(int exitcd)
 {
-	mruby_exit_code = exitcd;
-	longjmp(process_exit, 1);
+	shellcmd_exit_code = exitcd;
+	longjmp(shellcmd_exit, 1);
 }
 
@@ -480,5 +494,5 @@
 	ER ret;
 
-	ret = ter_tsk(MRUBY_TASK);
+	ret = ter_tsk(SHELLCMD_TASK);
 	if ((ret != E_OK) && (ret != E_OBJ)) {
 		syslog(LOG_ERROR, "ter_tsk => %d", ret);
@@ -489,6 +503,6 @@
 	clean_fd();
 
-	mruby_state = 0;
-	ret = act_tsk(MRUBY_TASK);
+	shellcmd_state = 0;
+	ret = act_tsk(SHELLCMD_TASK);
 	if (ret != E_OK) {
 		syslog(LOG_ERROR, "act_tsk => %d", ret);
@@ -500,13 +514,112 @@
 	do {
 		tslp_tsk(100000);
-	} while(mruby_state == 1);
-
-	return mruby_exit_code;
-}
-
-static int cmd_execute(const char *text, void *extobj)
-{
-	ntlibc_strlcpy(command, text, sizeof(command));
-	return execute_command(1);
+	} while(shellcmd_state == 1);
+
+	return shellcmd_exit_code;
+}
+
+int shell_clock_getres(clockid_t clk_id, struct timespec *res)
+{
+	if (clk_id != CLOCK_REALTIME)
+		return -EINVAL;
+
+	memset(&res->tv_sec, 0xFF, sizeof(res->tv_sec));
+	res->tv_nsec = 0;
+
+	return 0;
+}
+
+int shell_clock_gettime(clockid_t clk_id, struct timespec *tp)
+{
+	SYSTIM now = 0;
+
+	if (clk_id != CLOCK_REALTIME)
+		return -EINVAL;
+
+	get_tim(&now);
+	tp->tv_sec = now / 1000000;
+	tp->tv_nsec = (now % 1000000) * 1000;
+
+	return 0;
+}
+
+int shell_clock_settime(clockid_t clk_id, const struct timespec *tp)
+{
+	if (clk_id != CLOCK_REALTIME)
+		return -EINVAL;
+
+	rtc_write(tp->tv_sec);
+
+	return 0;
+}
+
+sigset_t g_sigmask;
+
+int shell_sigprocmask(int how, const sigset_t *restrict set, sigset_t *restrict old)
+{
+	if (old != NULL)
+		memcpy(old, &g_sigmask, sizeof(sigset_t));
+
+	switch (how) {
+	case SIG_BLOCK:
+		for (int i = 0; i < sizeof(g_sigmask.__bits) / sizeof(g_sigmask.__bits[0]); i++) {
+			g_sigmask.__bits[i] |= set->__bits[i];
+		}
+		break;
+	case SIG_UNBLOCK:
+		for (int i = 0; i < sizeof(g_sigmask.__bits) / sizeof(g_sigmask.__bits[0]); i++) {
+			g_sigmask.__bits[i] &= ~set->__bits[i];
+		}
+		break;
+	case SIG_SETMASK:
+		memcpy(&g_sigmask, set, sizeof(sigset_t));
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+struct sigaction sigtable[6];
+
+int shell_sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old)
+{
+	struct sigaction *sat;
+
+	switch(sig){
+	case SIGALRM:
+		sat = &sigtable[0];
+		break;
+	case SIGFPE:
+		sat = &sigtable[1];
+		break;
+	case SIGILL:
+		sat = &sigtable[2];
+		break;
+	case SIGSEGV:
+		sat = &sigtable[3];
+		break;
+	case SIGBUS:
+		sat = &sigtable[4];
+		break;
+	case SIGABRT:
+		sat = &sigtable[5];
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	if (old != NULL)
+		memcpy(old, sat, sizeof(struct sigaction));
+
+	memcpy(sat, sa, sizeof(struct sigaction));
+
+	return 0;
+}
+
+int shell_madvise(void *a, size_t b, int c)
+{
+	return 0;
 }
 
@@ -590,107 +703,2 @@
 }
 
-int shell_clock_getres(clockid_t clk_id, struct timespec *res)
-{
-	if (clk_id != CLOCK_REALTIME)
-		return -EINVAL;
-
-	memset(&res->tv_sec, 0xFF, sizeof(res->tv_sec));
-	res->tv_nsec = 0;
-
-	return 0;
-}
-
-int shell_clock_gettime(clockid_t clk_id, struct timespec *tp)
-{
-	SYSTIM now = 0;
-
-	if (clk_id != CLOCK_REALTIME)
-		return -EINVAL;
-
-	get_tim(&now);
-	tp->tv_sec = now / 1000000;
-	tp->tv_nsec = (now % 1000000) * 1000;
-
-	return 0;
-}
-
-int shell_clock_settime(clockid_t clk_id, const struct timespec *tp)
-{
-	if (clk_id != CLOCK_REALTIME)
-		return -EINVAL;
-
-	rtc_write(tp->tv_sec);
-
-	return 0;
-}
-
-sigset_t g_sigmask;
-
-int shell_sigprocmask(int how, const sigset_t *restrict set, sigset_t *restrict old)
-{
-	if (old != NULL)
-		memcpy(old, &g_sigmask, sizeof(sigset_t));
-
-	switch (how) {
-	case SIG_BLOCK:
-		for (int i = 0; i < sizeof(g_sigmask.__bits) / sizeof(g_sigmask.__bits[0]); i++) {
-			g_sigmask.__bits[i] |= set->__bits[i];
-		}
-		break;
-	case SIG_UNBLOCK:
-		for (int i = 0; i < sizeof(g_sigmask.__bits) / sizeof(g_sigmask.__bits[0]); i++) {
-			g_sigmask.__bits[i] &= ~set->__bits[i];
-		}
-		break;
-	case SIG_SETMASK:
-		memcpy(&g_sigmask, set, sizeof(sigset_t));
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-struct sigaction sigtable[6];
-
-int shell_sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old)
-{
-	struct sigaction *sat;
-
-	switch(sig){
-	case SIGALRM:
-		sat = &sigtable[0];
-		break;
-	case SIGFPE:
-		sat = &sigtable[1];
-		break;
-	case SIGILL:
-		sat = &sigtable[2];
-		break;
-	case SIGSEGV:
-		sat = &sigtable[3];
-		break;
-	case SIGBUS:
-		sat = &sigtable[4];
-		break;
-	case SIGABRT:
-		sat = &sigtable[5];
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	if (old != NULL)
-		memcpy(old, sat, sizeof(struct sigaction));
-
-	memcpy(sat, sa, sizeof(struct sigaction));
-
-	return 0;
-}
-
-int shell_madvise(void *a, size_t b, int c)
-{
-	return 0;
-}
-
Index: /EcnlProtoTool/trunk/ntshell/src/main.cfg
===================================================================
--- /EcnlProtoTool/trunk/ntshell/src/main.cfg	(revision 430)
+++ /EcnlProtoTool/trunk/ntshell/src/main.cfg	(revision 431)
@@ -61,4 +61,4 @@
 CRE_SEM(SEM_FILESYSTEM, { TA_TPRI, 1, 1 });
 
-CRE_TSK(MRUBY_TASK, { TA_NULL, 0, mruby_task, MRUBY_PRIORITY, MRUBY_STACK_SIZE, (void *)0x20100000 });
+CRE_TSK(SHELLCMD_TASK, { TA_NULL, 0, shellcmd_task, SHELLCMD_PRIORITY, SHELLCMD_STACK_SIZE, (void *)0x20100000 });
 CRE_FLG(FLG_SELECT_WAIT, { TA_WMUL, 0x00 });
Index: /EcnlProtoTool/trunk/ntshell/src/main.h
===================================================================
--- /EcnlProtoTool/trunk/ntshell/src/main.h	(revision 430)
+++ /EcnlProtoTool/trunk/ntshell/src/main.h	(revision 431)
@@ -53,11 +53,11 @@
 
 #define MAIN_PRIORITY	5		/* メインタスクの優先度 */
-#define MRUBY_PRIORITY	4		/* mruby実行タスクの優先度 */
+#define SHELLCMD_PRIORITY	4		/* shellcmdタスクの優先度 */
 
 #define MAIN_STACK_SIZE		2048	/* メインタスクのスタック領域のサイズ */
-#define MRUBY_STACK_SIZE	0x00800000	/* mruby実行タスクのスタック領域のサイズ */
+#define SHELLCMD_STACK_SIZE	0x00800000	/* shellcmdタスクのスタック領域のサイズ */
 
 #define NUM_MAIN_DATAQUEUE	1	/* メインタスクで待ち受けているデータキューのサイズ */
-#define NUM_MRUBY_DATAQUEUE	1	/* mruby実行タスクで待ち受けているデータキューのサイズ */
+#define NUM_SHELLCMD_DATAQUEUE	1	/* shellcmdタスクで待ち受けているデータキューのサイズ */
 
 /*
@@ -69,6 +69,6 @@
 extern void main_task(intptr_t exinf);
 
-/* mruby実行タスク */
-extern void mruby_task(intptr_t exinf);
+/* shellcmdタスク */
+extern void shellcmd_task(intptr_t exinf);
 
 /* 
