// Running another program and waiting for its exit status.
import std.io.println;
import std.text.number;
import std.process.child;
def main(): int {
let program: string = "/bin/sh";
let arguments: vector string = ["-c", "exit 7"];
match run_and_wait(&program, &arguments) with
// Patterns use the canonical variant names; English variant aliases are
// accepted in expressions but not yet in patterns.
| result.ok(حالة_إنهاء.خرج(code)) -> { println(int_to_text(code)); }
| result.ok(_) -> { println("stopped by a signal"); }
| result.err(_) -> { println("could not start"); return 1; };
return 0;
}// تشغيل برنامج آخر وانتظار حالة خروجه.
استورد std.io.println;
استورد std.text.number;
استورد std.process.child;
عرف الرئيسية(): عدد {
دع البرنامج: نص = "/bin/sh";
دع الوسائط: متجه نص = ["-c", "exit 7"];
طابق شغل_وانتظر(&البرنامج, &الوسائط) مع
| نتيجة.نجح(حالة_إنهاء.خرج(الرمز)) -> { اطبع_سطر(عدد_إلى_نص(الرمز)); }
| نتيجة.نجح(_) -> { اطبع_سطر("أُوقف بإشارة"); }
| نتيجة.خطأ(_) -> { اطبع_سطر("تعذر التشغيل"); أرجع 1; };
أرجع 0;
}
Run it
With the interpreter, without compiling:
./build/sultanc run examples/en/process/child_process.snOr compile it to an executable:
./build/sultanc examples/en/process/child_process.sn -o build/example && ./build/example