processctl() PCTL_SPAWN cmd, scheduler embryo state, redirected pipes
This commit is contained in:
@ -43,12 +43,14 @@ int32_t SYSCALL5(sys_ipcpipe, pid1, pipenum1, cmd1, buffer1, len1) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
if ((ret = ipc_pipeinit(pipe)) < 0) {
|
||||
if ((ret = ipc_pipeinit(pipe, proc->pid)) < 0) {
|
||||
ret = E_NOMEMORY;
|
||||
goto done;
|
||||
}
|
||||
|
||||
spinlock_acquire(&proc->pipes_spinlock);
|
||||
proc->pipes[pipenum] = pipe;
|
||||
spinlock_release(&proc->pipes_spinlock);
|
||||
|
||||
ret = E_OK;
|
||||
} break;
|
||||
@ -64,7 +66,9 @@ int32_t SYSCALL5(sys_ipcpipe, pid1, pipenum1, cmd1, buffer1, len1) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
spinlock_acquire(&proc->pipes_spinlock);
|
||||
IpcPipe *pipe = proc->pipes[pipenum];
|
||||
spinlock_release(&proc->pipes_spinlock);
|
||||
|
||||
if (pipe == NULL) {
|
||||
ret = E_INVALIDARGUMENT;
|
||||
@ -85,7 +89,9 @@ int32_t SYSCALL5(sys_ipcpipe, pid1, pipenum1, cmd1, buffer1, len1) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
spinlock_acquire(&proc->pipes_spinlock);
|
||||
IpcPipe *pipe = proc->pipes[pipenum];
|
||||
spinlock_release(&proc->pipes_spinlock);
|
||||
|
||||
if (pipe == NULL) {
|
||||
ret = E_INVALIDARGUMENT;
|
||||
@ -100,7 +106,9 @@ int32_t SYSCALL5(sys_ipcpipe, pid1, pipenum1, cmd1, buffer1, len1) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
spinlock_acquire(&proc->pipes_spinlock);
|
||||
IpcPipe *pipe = proc->pipes[pipenum];
|
||||
spinlock_release(&proc->pipes_spinlock);
|
||||
|
||||
if (pipe == NULL) {
|
||||
ret = E_INVALIDARGUMENT;
|
||||
@ -125,6 +133,43 @@ int32_t SYSCALL5(sys_ipcpipe, pid1, pipenum1, cmd1, buffer1, len1) {
|
||||
|
||||
ret = E_OK;
|
||||
} break;
|
||||
case IPCPIPE_REPLACE: {
|
||||
if (pipenum >= PROC_PIPEHANDLES_MAX) {
|
||||
ret = E_NOMEMORY;
|
||||
goto done;
|
||||
}
|
||||
|
||||
uint64_t pid2 = buffer1;
|
||||
uint64_t pipenum2 = len1;
|
||||
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
Proc *proc2 = NULL;
|
||||
LL_FINDPROP(PROCS.procs, proc2, pid, pid2);
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
|
||||
if (proc2 == NULL) {
|
||||
ret = E_INVALIDARGUMENT;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (pipenum2 >= PROC_PIPEHANDLES_MAX) {
|
||||
ret = E_NOMEMORY;
|
||||
goto done;
|
||||
}
|
||||
|
||||
spinlock_acquire(&proc2->pipes_spinlock);
|
||||
spinlock_acquire(&proc->pipes_spinlock);
|
||||
|
||||
if (proc->pipes[pipenum] != NULL) {
|
||||
ipc_pipefree(proc->pipes[pipenum]);
|
||||
dlfree(proc->pipes[pipenum]);
|
||||
proc->pipes[pipenum] = NULL;
|
||||
}
|
||||
proc->pipes[pipenum] = proc2->pipes[pipenum2];
|
||||
|
||||
spinlock_release(&proc->pipes_spinlock);
|
||||
spinlock_release(&proc2->pipes_spinlock);
|
||||
} break;
|
||||
default: {
|
||||
ret = E_INVALIDARGUMENT;
|
||||
} break;
|
||||
|
Reference in New Issue
Block a user