langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
6
Task/Fork/OCaml/fork.ocaml
Normal file
6
Task/Fork/OCaml/fork.ocaml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#load "unix.cma";;
|
||||
let pid = Unix.fork ();;
|
||||
if pid > 0 then
|
||||
print_endline "This is the original process"
|
||||
else
|
||||
print_endline "This is the new process";;
|
||||
30
Task/Fork/Oz/fork.oz
Normal file
30
Task/Fork/Oz/fork.oz
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
declare
|
||||
ParentVar1 = "parent data"
|
||||
ParentVar2
|
||||
|
||||
functor RemoteCode
|
||||
export
|
||||
result:Result
|
||||
import QTk at 'x-oz://system/wp/QTk.ozf'
|
||||
define
|
||||
Result
|
||||
%% Show a simple window. When it is closed by the user, set Result.
|
||||
Window =
|
||||
{QTk.build
|
||||
td(action:proc {$} Result = 42 end %% on close
|
||||
label(text:"In child process: "#ParentVar1))} %% read parent process variable
|
||||
{Window show}
|
||||
!ParentVar2 = childData %% write to parent process variable
|
||||
{Wait Result}
|
||||
end
|
||||
|
||||
%% create a new process on the same machine
|
||||
RM = {New Remote.manager init(host:localhost)}
|
||||
%% execute the code encapsulated in the given functor
|
||||
RemoteModule = {RM apply(RemoteCode $)}
|
||||
in
|
||||
%% retrieve data from child process
|
||||
{Show RemoteModule.result} %% prints 42
|
||||
%% exit child process
|
||||
{RM close}
|
||||
{Show ParentVar2} %% print "childData"
|
||||
8
Task/Fork/PARI-GP/fork.pari
Normal file
8
Task/Fork/PARI-GP/fork.pari
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
void
|
||||
foo()
|
||||
{
|
||||
if (pari_daemon())
|
||||
pari_printf("Original\n");
|
||||
else
|
||||
pari_printf("Fork\n");
|
||||
}
|
||||
1
Task/Fork/PL-I/fork.pli
Normal file
1
Task/Fork/PL-I/fork.pli
Normal file
|
|
@ -0,0 +1 @@
|
|||
ATTACH SOLVE (X) THREAD (T5);
|
||||
9
Task/Fork/Perl-6/fork.pl6
Normal file
9
Task/Fork/Perl-6/fork.pl6
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
use NativeCall;
|
||||
sub fork() returns Int is native { ... }
|
||||
|
||||
if fork() -> $pid {
|
||||
print "I am the proud parent of $pid.\n";
|
||||
}
|
||||
else {
|
||||
print "I am a child. Have you seen my mommy?\n";
|
||||
}
|
||||
7
Task/Fork/Pop11/fork.pop11
Normal file
7
Task/Fork/Pop11/fork.pop11
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
lvars ress;
|
||||
if sys_fork(false) ->> ress then
|
||||
;;; parent
|
||||
printf(ress, 'Child pid = %p\n');
|
||||
else
|
||||
printf('In child\n');
|
||||
endif;
|
||||
7
Task/Fork/Run-BASIC/fork.run
Normal file
7
Task/Fork/Run-BASIC/fork.run
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
run "someProgram.bas",#handle
|
||||
render #handle ' this runs the program until it waits
|
||||
' both the parent and child are running
|
||||
' --------------------------------------------------------
|
||||
' You can also call a function in the someProgram.bas program.
|
||||
' For example if it had a DisplayBanner Funciton.
|
||||
#handle DisplayBanner("Welcome!")
|
||||
6
Task/Fork/Slate/fork.slate
Normal file
6
Task/Fork/Slate/fork.slate
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
p@(Process traits) forkAndDo: b
|
||||
[| ret |
|
||||
(ret := lobby cloneSystem)
|
||||
first ifTrue: [p pipes addLast: ret second. ret second]
|
||||
ifFalse: [[p pipes clear. p pipes addLast: ret second. b applyWith: ret second] ensure: [lobby quit]]
|
||||
].
|
||||
3
Task/Fork/Standard-ML/fork.ml
Normal file
3
Task/Fork/Standard-ML/fork.ml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
case Posix.Process.fork () of
|
||||
SOME pid => print "This is the original process\n"
|
||||
| NONE => print "This is the new process\n";
|
||||
3
Task/Fork/Toka/fork.toka
Normal file
3
Task/Fork/Toka/fork.toka
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
needs shell
|
||||
getpid is-data PID
|
||||
[ fork getpid PID = [ ." Child PID: " . cr ] [ ." In child\n" ] ifTrueFalse ] invoke
|
||||
11
Task/Fork/UNIX-Shell/fork-1.sh
Normal file
11
Task/Fork/UNIX-Shell/fork-1.sh
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
i=0
|
||||
(while test $i -lt 10; do
|
||||
sleep 1
|
||||
echo "Child process"
|
||||
i=`expr $i + 1`
|
||||
done) &
|
||||
while test $i -lt 5; do
|
||||
sleep 2
|
||||
echo "Parent process"
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
5
Task/Fork/UNIX-Shell/fork-2.sh
Normal file
5
Task/Fork/UNIX-Shell/fork-2.sh
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(for ((i=0;i<10;i++)); do sleep 1; echo "Child process"; done) &
|
||||
for ((i=0;i<5;i++)); do
|
||||
sleep 2
|
||||
echo "Parent process"
|
||||
done
|
||||
1
Task/Fork/UnixPipes/fork.unixpipes
Normal file
1
Task/Fork/UnixPipes/fork.unixpipes
Normal file
|
|
@ -0,0 +1 @@
|
|||
(echo "Process 1" >&2 ;sleep 5; echo "1 done" ) | (echo "Process 2";cat;echo "2 done")
|
||||
32
Task/Fork/X86-Assembly/fork.x86
Normal file
32
Task/Fork/X86-Assembly/fork.x86
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
extern fork
|
||||
extern printf
|
||||
|
||||
section .text
|
||||
global _start
|
||||
|
||||
_start:
|
||||
call fork
|
||||
cmp eax, 0
|
||||
je _child
|
||||
jg _parent
|
||||
jmp _exit
|
||||
|
||||
_parent:
|
||||
push p_msg
|
||||
call printf
|
||||
jmp _exit
|
||||
_child:
|
||||
push c_msg
|
||||
call printf
|
||||
jmp _exit
|
||||
|
||||
_exit:
|
||||
push 0x1
|
||||
mov eax, 1
|
||||
push eax
|
||||
int 0x80
|
||||
ret
|
||||
|
||||
section .data
|
||||
c_msg db "Printed from Child process",13,10,0
|
||||
p_msg db "Printed from Parent process",13,10,0
|
||||
Loading…
Add table
Add a link
Reference in a new issue