2014-02-05 16:33:10 -06:00
|
|
|
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2014-08-11 18:24:19 -05:00
|
|
|
// ignore-windows
|
2013-11-11 19:37:14 -06:00
|
|
|
|
2015-03-05 20:33:58 -06:00
|
|
|
#![feature(old_io)]
|
|
|
|
#![feature(os)]
|
|
|
|
|
2015-02-16 08:04:02 -06:00
|
|
|
use std::env;
|
2015-01-22 18:31:00 -06:00
|
|
|
use std::old_io::process::{Command, ExitSignal, ExitStatus};
|
2013-11-11 19:37:14 -06:00
|
|
|
|
2014-01-03 17:30:54 -06:00
|
|
|
pub fn main() {
|
2015-02-16 08:04:02 -06:00
|
|
|
let args: Vec<String> = env::args().collect();
|
2015-02-01 20:53:25 -06:00
|
|
|
if args.len() >= 2 && args[1] == "signal" {
|
2013-11-11 19:37:14 -06:00
|
|
|
// Raise a segfault.
|
2015-03-25 19:06:52 -05:00
|
|
|
unsafe { *(0 as *mut isize) = 0; }
|
2013-11-11 19:37:14 -06:00
|
|
|
} else {
|
2015-02-01 20:53:25 -06:00
|
|
|
let status = Command::new(&args[0]).arg("signal").status().unwrap();
|
2013-11-13 11:58:19 -06:00
|
|
|
// Windows does not have signal, so we get exit status 0xC0000028 (STATUS_BAD_STACK).
|
2013-11-11 19:37:14 -06:00
|
|
|
match status {
|
2014-02-18 14:04:51 -06:00
|
|
|
ExitSignal(_) if cfg!(unix) => {},
|
|
|
|
ExitStatus(0xC0000028) if cfg!(windows) => {},
|
2014-10-09 14:17:22 -05:00
|
|
|
_ => panic!("invalid termination (was not signalled): {}", status)
|
2013-11-11 19:37:14 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|