--- ansh/src/utils.c 2011/10/14 09:04:04 1.1.1.1.2.10 +++ ansh/src/utils.c 2011/10/14 12:03:10 1.1.1.1.2.11 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ - * $Id: utils.c,v 1.1.1.1.2.10 2011/10/14 09:04:04 misho Exp $ + * $Id: utils.c,v 1.1.1.1.2.11 2011/10/14 12:03:10 misho Exp $ * ************************************************************************* The ELWIX and AITNET software is distributed under the following @@ -120,10 +120,8 @@ PrepareL2(const char *psDev, int *bpflen) return -1; } - /* n = fcntl(h, F_GETFL); fcntl(h, F_SETFL, n | O_NONBLOCK); - */ VERB(3) LOG("Openned device handle %d with bpf buflen %d", h, *bpflen); return h; @@ -513,4 +511,30 @@ cryptBuffer(u_char *buf, int rlen, u_int ctr) return NULL; return str; +} + +int +stopProcess(sched_root_task_t * __restrict root, proc_head_t * __restrict h, pid_t pid, sched_task_func_t func) +{ + struct tagProc *p; + + FTRACE(3); + + SLIST_FOREACH(p, h, proc_next) + if (p->proc_pid == pid) { + break; + } + if (!p) + return 1; + + ioFreePTY(p->proc_pty, p->proc_ttyname); + schedCancelby(root, NULL, CRITERIA_FD, (void*) ((intptr_t) p->proc_pty), NULL); + + p->proc_pid = 0; + p->proc_seq = 0; + p->proc_flg = ANSH_FLG_EOF; + p->proc_rlen_[FD2NET] = 0; + + schedCallOnce(root, func, p, p->proc_sock); + return 0; }