pub fn create_pty_pair() -> File {

	match openpty(None,None) {
		Ok(result) => {

			// Set our software flow control
			let mut retcode;
			// what I'm doing here is unsafe as shit.
			unsafe {
				// Make the changes to our master terminal
				let mut pty_attr: termios = mem::zeroed();
				
				retcode = tcgetattr(result.master, &mut pty_attr);
				// Set our serial parameters. Flow control, etc.
				// Everything will be off by default to avoid weird default terminal behavior
				// (ECHO is on by default, for example)
				pty_attr.c_iflag = nix::libc::IXOFF +
								   nix::libc::IGNBRK;
				pty_attr.c_oflag = 0;
				pty_attr.c_cflag = 0;
				pty_attr.c_lflag = 0;

				
				retcode = tcsetattr(result.master, 0 ,&pty_attr);
				
				//println!("retcode: {}", retcode);

			}


			let pty_master_file: File;
			unsafe { pty_master_file = File::from_raw_fd(result.master); }
			pty_master_file
		}
		Err(e) => panic!("Failed to open pty master file: {:?}", e)
	}
}
// Get a pty pair using direct linux libc syscalls
Get a pty pair using direct linux libc syscalls
Get a pty pair using direct linux libc syscalls
pub fn create_pty_pair() -> File {
	match openpty(None,None) {
		Ok(result) => {
			// Set our software flow control
			let mut retcode;
			// what I'm doing here is unsafe as shit.
			unsafe {
				// Make the changes to our master terminal
				let mut pty_attr: termios = mem::zeroed();
				retcode = tcgetattr(result.master, &mut pty_attr);
				// Set our serial parameters. Flow control, etc.
				// Everything will be off by default to avoid weird default terminal behavior
				// (ECHO is on by default, for example)
				pty_attr.c_iflag = nix::libc::IXOFF +
								   nix::libc::IGNBRK;
				pty_attr.c_oflag = 0;
				pty_attr.c_cflag = 0;
				pty_attr.c_lflag = 0;
				retcode = tcsetattr(result.master, 0 ,&pty_attr);
				//println!("retcode: {}", retcode);
			}
			let pty_master_file: File;
			unsafe { pty_master_file = File::from_raw_fd(result.master); }
			pty_master_file
		}
		Err(e) => panic!("Failed to open pty master file: {:?}", e)
	}
}
pub fn create_pty_pair ( ) -> File { match openpty ( None , None ) { Ok ( result ) => { // Set our software flow control let mut retcode ; // what I'm doing here is unsafe as shit. unsafe { // Make the changes to our master terminal let mut pty_attr : termios = mem :: zeroed ( ) ; retcode = tcgetattr ( result . master , & mut pty_attr ) ; // Set our serial parameters. Flow control, etc. // Everything will be off by default to avoid weird default terminal behavior // (ECHO is on by default, for example) pty_attr . c_iflag = nix :: libc :: IXOFF + nix :: libc :: IGNBRK ; pty_attr . c_oflag = 0 ; pty_attr . c_cflag = 0 ; pty_attr . c_lflag = 0 ; retcode = tcsetattr ( result . master , 0 , & pty_attr ) ; //println!("retcode: {}", retcode); } let pty_master_file : File ; unsafe { pty_master_file = File :: from_raw_fd ( result . master ) ; } pty_master_file } Err ( e ) => panic ! ( " " e ) } }
Get a pty pair using direct linux libc syscalls
Get a pty pair using direct linux libc syscalls