Fork: Difference between revisions

Content added Content deleted
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 63: Line 63:
This is the original process
This is the original process
</pre>
</pre>

=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==
<lang autohotkey>MsgBox, 4, Fork, Start another process?
<lang autohotkey>MsgBox, 4, Fork, Start another process?
Line 170: Line 171:
mySubroutine3: mySubroutine1 has been run
mySubroutine3: mySubroutine1 has been run
</pre>
</pre>

=={{header|C}}==
=={{header|C}}==
{{libheader|POSIX}}<lang c>#include <stdio.h>
{{libheader|POSIX}}<lang c>#include <stdio.h>
Line 195: Line 197:
child process: done
child process: done
child 3604 finished</lang>
child 3604 finished</lang>

=={{header|C sharp|C#}}==
<lang csharp>using System;
using System.Threading;

namespace Fork {
class Program {
static void Fork() {
Console.WriteLine("Spawned Thread");
}

static void Main(string[] args) {
Thread t = new Thread(new ThreadStart(Fork));
t.Start();

Console.WriteLine("Main Thread");
t.Join();

Console.ReadLine();
}
}
}</lang>


=={{header|C++}}==
=={{header|C++}}==
Line 221: Line 245:


return 0;
return 0;
}</lang>

=={{header|C#|C sharp}}==
<lang csharp>using System;
using System.Threading;

namespace Fork {
class Program {
static void Fork() {
Console.WriteLine("Spawned Thread");
}

static void Main(string[] args) {
Thread t = new Thread(new ThreadStart(Fork));
t.Start();

Console.WriteLine("Main Thread");
t.Join();

Console.ReadLine();
}
}
}</lang>
}</lang>


Line 815: Line 817:
Parent again.
Parent again.
</pre>
</pre>



=={{header|Kotlin}}==
=={{header|Kotlin}}==
Line 1,160: Line 1,161:
}
}
};</lang>
};</lang>

=={{header|Perl 6}}==
{{Works with|rakudo|2016.06}}
<lang perl6>use NativeCall;
sub fork() returns int32 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";
}</lang>
{{out}}
<pre>I am the proud parent of 17691.
I am a child. Have you seen my mommy?</pre>


=={{header|Phix}}==
=={{header|Phix}}==
Line 1,270: Line 1,256:
>>> fork() => 0
>>> fork() => 0
</pre>
</pre>

=={{header|Raku}}==
(formerly Perl 6)
{{Works with|rakudo|2016.06}}
<lang perl6>use NativeCall;
sub fork() returns int32 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";
}</lang>
{{out}}
<pre>I am the proud parent of 17691.
I am a child. Have you seen my mommy?</pre>


=={{header|REXX}}==
=={{header|REXX}}==