Commit 55c090a6 authored by Steffen Michels's avatar Steffen Michels

added Process.closeProcess & Process.closeProcessIO for Linux & Mac

parent 7b3e5923
......@@ -50,6 +50,7 @@ ioctl :: !Int !Int !Pointer !*w -> (!Int, !*w)
read :: !Int !Pointer !Int !*w -> (!Int, !*w)
write :: !Int !{#Char} !Int !*w -> (!Int, !*w)
select_ :: !Int !Pointer !Pointer !Pointer !Pointer !*w -> (!Int, !*w)
kill :: !Int !Int !*w -> (!Int, !*w)
//Memory (impure)
malloc :: !Int -> Pointer
......
......@@ -112,6 +112,11 @@ select_ nfds readfds writefds exceptfds timeout world = code {
ccall select "Ipppp:I:A"
}
kill :: !Int !Int !*w -> (!Int, !*w)
kill pid sig world = code {
ccall kill "II:I:A"
}
malloc :: !Int -> Pointer
malloc num = code {
ccall malloc "p:p"
......
......@@ -49,6 +49,7 @@ ioctl :: !Int !Int !Pointer !*w -> (!Int, !*w)
read :: !Int !Pointer !Int !*w -> (!Int, !*w)
write :: !Int !{#Char} !Int !*w -> (!Int, !*w)
select_ :: !Int !Pointer !Pointer !Pointer !Pointer !*w -> (!Int, !*w)
kill :: !Int !Int !*w -> (!Int, !*w)
//Memory (impure)
malloc :: !Int -> Pointer
......
......@@ -111,6 +111,12 @@ select_ nfds readfds writefds exceptfds timeout world = code {
ccall select "Ipppp:I:A"
}
kill :: !Int !Int !*w -> (!Int, !*w)
kill pid sig world = code {
ccall kill "II:I:A"
}
malloc :: !Int -> Pointer
malloc num = code {
ccall malloc "p:p"
......
......@@ -95,3 +95,17 @@ readPipeBlockingMulti :: ![ReadPipe] !*World -> (!MaybeOSError [String], !*World
*/
writePipe :: !String !WritePipe !*World -> (!MaybeOSError (), !*World)
/**
* kills the process if it is still running and releases the process handle resources.
* @param the process handle.
* @return ()
*/
closeProcess :: !ProcessHandle !*World -> (!MaybeOSError (), !*World)
/**
* closes the IO channels of the process.
* @param the io channels
* @return ()
*/
closeProcessIO :: !ProcessIO !*World -> (!MaybeOSError (), !*World)
......@@ -274,3 +274,19 @@ writePipe str (WritePipe fd) world
| res == -1 = getLastOSError world
= (Ok (), world)
closeProcess :: !ProcessHandle !*World -> (!MaybeOSError (), !*World)
closeProcess {pid} world
# (res, world) = kill pid 15 world // Termination signal
| res == -1 = getLastOSError world
= (Ok (), world)
closeProcessIO :: !ProcessIO !*World -> (!MaybeOSError (), !*World)
closeProcessIO {stdIn = WritePipe fdStdIn, stdOut = ReadPipe fdStdOut, stdErr = ReadPipe fdStdErr} world
# (res, world) = close fdStdIn world
| res == -1 = getLastOSError world
# (res, world) = close fdStdOut world
| res == -1 = getLastOSError world
# (res, world) = close fdStdErr world
| res == -1 = getLastOSError world
= (Ok (), world)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment