Switch to real standard, fix daemonization on real standard
This commit is contained in:
parent
da3f9558d9
commit
2db2d10cce
15 changed files with 55 additions and 45 deletions
|
@ -3,7 +3,6 @@ extern crate syscall;
|
|||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
use std::str;
|
||||
use std::thread;
|
||||
|
||||
use syscall::{Packet, Result, Scheme};
|
||||
|
||||
|
@ -25,7 +24,8 @@ impl Scheme for ExampleScheme {
|
|||
}
|
||||
|
||||
fn main(){
|
||||
thread::spawn(move || {
|
||||
// Daemonize
|
||||
if unsafe { syscall::clone(0).unwrap() } == 0 {
|
||||
let mut socket = File::create(":example").expect("example: failed to create example scheme");
|
||||
let scheme = ExampleScheme;
|
||||
loop {
|
||||
|
@ -35,5 +35,5 @@ fn main(){
|
|||
scheme.handle(&mut packet);
|
||||
socket.write(&packet).expect("example: failed to write responses to example scheme");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue