package pty

import (
	
	
	
)

// Start assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout,
// and c.Stderr, calls c.Start, and returns the File of the tty's
// corresponding pty.
//
// Starts the process in a new session and sets the controlling terminal.
func ( *exec.Cmd) (*os.File, error) {
	return StartWithSize(, nil)
}

// StartWithAttrs assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout,
// and c.Stderr, calls c.Start, and returns the File of the tty's
// corresponding pty.
//
// This will resize the pty to the specified size before starting the command if a size is provided.
// The `attrs` parameter overrides the one set in c.SysProcAttr.
//
// This should generally not be needed. Used in some edge cases where it is needed to create a pty
// without a controlling terminal.
func ( *exec.Cmd,  *Winsize,  *syscall.SysProcAttr) (*os.File, error) {
	, ,  := Open()
	if  != nil {
		return nil, 
	}
	defer func() { _ = .Close() }() // Best effort.

	if  != nil {
		if  := Setsize(, );  != nil {
			_ = .Close() // Best effort.
			return nil, 
		}
	}
	if .Stdout == nil {
		.Stdout = 
	}
	if .Stderr == nil {
		.Stderr = 
	}
	if .Stdin == nil {
		.Stdin = 
	}

	.SysProcAttr = 

	if  := .Start();  != nil {
		_ = .Close() // Best effort.
		return nil, 
	}
	return , 
}