com_shell.c
来自「ngspice又一个电子CAD仿真软件代码.功能更全」· C语言 代码 · 共 64 行
C
64 行
/************** com_shell.c* $Id: com_shell.c,v 1.2 2005/05/30 20:28:30 sjborley Exp $************/#include <config.h>#include <ngspice.h>#include <wordlist.h>#include "com_shell.h"/* Fork a shell. */voidcom_shell(wordlist *wl){ char *com, *shell = NULL; shell = getenv("SHELL"); if (shell == NULL) shell = "/bin/csh"; cp_ccon(FALSE);#ifdef HAVE_VFORK_H /* XXX Needs to switch process groups. Also, worry about suspend */ /* Only bother for efficiency */ pid = vfork(); if (pid == 0) { fixdescriptors(); if (wl == NULL) { execl(shell, shell, 0); _exit(99); } else { com = wl_flatten(wl); execl("/bin/sh", "sh", "-c", com, 0); } } else { /* XXX Better have all these signals */ svint = signal(SIGINT, SIG_DFL); svquit = signal(SIGQUIT, SIG_DFL); svtstp = signal(SIGTSTP, SIG_DFL); /* XXX Sig on proc group */ do { r = wait((union wait *) NULL); } while ((r != pid) && pid != -1); signal(SIGINT, (SIGNAL_FUNCTION) svint); signal(SIGQUIT, (SIGNAL_FUNCTION) svquit); signal(SIGTSTP, (SIGNAL_FUNCTION) svtstp); }#else /* Easier to forget about changing the io descriptors. */ if (wl) { com = wl_flatten(wl); system(com); } else system(shell);#endif return;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?