mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
os: fork() and wait()
This commit is contained in:
parent
48f841bb26
commit
436d7592c7
10
vlib/os/os.v
10
vlib/os/os.v
@ -652,6 +652,16 @@ pub fn signal(signum int, handler voidptr) {
|
||||
C.signal(signum, handler)
|
||||
}
|
||||
|
||||
pub fn fork() int {
|
||||
pid := C.fork()
|
||||
return pid
|
||||
}
|
||||
|
||||
pub fn wait() int {
|
||||
pid := C.wait(0)
|
||||
return pid
|
||||
}
|
||||
|
||||
pub fn file_last_mod_unix(path string) int {
|
||||
attr := C.stat{}
|
||||
//# struct stat attr;
|
||||
|
@ -33,3 +33,26 @@ fn test_write_and_read_string_to_file() {
|
||||
|
||||
os.rm(filename)
|
||||
}
|
||||
|
||||
//fn test_fork() {
|
||||
// pid := os.fork()
|
||||
// if pid == 0 {
|
||||
// println('Child')
|
||||
// }
|
||||
// else {
|
||||
// println('Parent')
|
||||
// }
|
||||
//}
|
||||
|
||||
//fn test_wait() {
|
||||
// pid := os.fork()
|
||||
// if pid == 0 {
|
||||
// println('Child')
|
||||
// exit(0)
|
||||
// }
|
||||
// else {
|
||||
// cpid := os.wait()
|
||||
// println('Parent')
|
||||
// println(cpid)
|
||||
// }
|
||||
//}
|
||||
|
Loading…
Reference in New Issue
Block a user