diff --git a/kernel/syscall/ipcpipe.c b/kernel/syscall/ipcpipe.c index b8dc6de..7617528 100644 --- a/kernel/syscall/ipcpipe.c +++ b/kernel/syscall/ipcpipe.c @@ -49,6 +49,13 @@ int32_t SYSCALL5(sys_ipcpipe, pid1, pipenum1, cmd1, buffer1, len1) { } spinlock_acquire(&proc->pipes_spinlock); + if (proc->pipes[pipenum] != NULL) { + spinlock_release(&proc->pipes_spinlock); + ipc_pipefree(pipe); + dlfree(pipe); + ret = E_RESOURCEAVAIL; + goto done; + } proc->pipes[pipenum] = pipe; spinlock_release(&proc->pipes_spinlock);