else
{
// SIGWINSZ to client
- Threads_SignalGroup(PTY->ControllingProcGroup, SIGWINCH);
+ if( PTY->ControllingProcGroup > 0 )
+ Threads_SignalGroup(PTY->ControllingProcGroup, SIGWINCH);
}
LOG("PTY %p dims set to %ix%i", PTY, Dims->W, Dims->H);
PTY->Dims = *Dims;
{
case 3: // INTR - ^C
// Send SIGINT
- Threads_SignalGroup(PTY->ControllingProcGroup, SIGINT);
+ if( PTY->ControllingProcGroup > 0 )
+ Threads_SignalGroup(PTY->ControllingProcGroup, SIGINT);
print = 0;
break;
case 4: // EOF - ^D
if(Flags & CLONE_VM) {
tProcess *newproc, *oldproc;
oldproc = cur->Process;
- new->Process = malloc( sizeof(struct sProcess) );
+ new->Process = calloc( sizeof(struct sProcess), 1 );
newproc = new->Process;
newproc->PID = new->TID;
if( Flags & CLONE_PGID )
#include "header.h"\r
#include <readline.h>\r
#include <errno.h>\r
+#include <acess/devices/pty.h>\r
\r
#define _stdin 0\r
#define _stdout 1\r
\r
// Create new process\r
int fds[] = {0, 1, 2};\r
+ int status;\r
pid = _SysSpawn(sTmpBuffer, (const char **)Args, (const char **)gasEnvironment, 3, fds, NULL);\r
if(pid <= 0) {\r
printf("Unable to create process: `%s'\n", sTmpBuffer); // Error Message\r
+ status = 0;\r
}\r
else {\r
- int status;\r
+ _SysIOCtl(0, PTY_IOCTL_SETPGRP, &pid);\r
_SysWaitTID(pid, &status);\r
}\r
+ \r
+ // Return terminal to a sane state\r
+ {\r
+ int zero = 0;\r
+ _SysIOCtl(0, PTY_IOCTL_SETPGRP, &zero);\r
+ printf("\x1b[0m");\r
+ }\r
+ // Print a status message if termination was non-clean\r
+ if( status )\r
+ {\r
+ printf("[%i] exited %i\n", pid, status);\r
+ }\r
}\r
\r
/**\r