kopia lustrzana https://github.com/micropython/micropython-lib
os: Add fork()/pipe() test.
rodzic
c0ab28571b
commit
8e3ce63a8d
|
@ -0,0 +1,17 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
r, w = os.pipe()
|
||||||
|
print(r, w)
|
||||||
|
|
||||||
|
pid = os.fork()
|
||||||
|
print("hello", pid)
|
||||||
|
|
||||||
|
if not pid:
|
||||||
|
print("pid:", os.getpid())
|
||||||
|
os.close(r)
|
||||||
|
os.write(w, "from child")
|
||||||
|
os._exit(0)
|
||||||
|
else:
|
||||||
|
os.close(w)
|
||||||
|
print(os.read(r, 100))
|
||||||
|
print(os.waitpid(pid, 0))
|
Ładowanie…
Reference in New Issue