<commit_before>// Copyright (c) 2019 <NAME>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package sys

import (
	"fmt"
	"os"
	"syscall"
)

func SocketFilePair(flags int) (f1, f2 *os.File, err error) {
	p, err := syscall.Socketpair(syscall.AF_UNIX, syscall.SOCK_STREAM|syscall.SOCK_CLOEXEC|flags, 0)
	if err != nil {
		err = fmt.Errorf("socketpair: %v", err)
		return
	}

	err = syscall.SetNonblock(p[1], true)
	if err != nil {
		err = fmt.Errorf("set nonblock: %v", err)
		return
	}

	f1 = os.NewFile(uintptr(p[0]), "unix")
	f2 = os.NewFile(uintptr(p[1]), "unix")
	return
}
<commit_msg>sys: SocketFilePair non-blocking documentation<commit_after>// Copyright (c) 2019 <NAME>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package sys

import (
	"fmt"
	"os"
	"syscall"
)

// SocketFilePair returns a blocking (f1) and a pollable (f2) file.
func SocketFilePair(flags int) (f1, f2 *os.File, err error) {
	p, err := syscall.Socketpair(syscall.AF_UNIX, syscall.SOCK_STREAM|syscall.SOCK_CLOEXEC|flags, 0)
	if err != nil {
		err = fmt.Errorf("socketpair: %v", err)
		return
	}

	err = syscall.SetNonblock(p[1], true)
	if err != nil {
		err = fmt.Errorf("set nonblock: %v", err)
		return
	}

	f1 = os.NewFile(uintptr(p[0]), "unix")
	f2 = os.NewFile(uintptr(p[1]), "unix")
	return
}

{'fraction_non_alphanumeric': 0.14982578397212543, 'fraction_numerical': 0.018118466898954706, 'mean_word_length': 3.9347079037800685, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4129799', 'n_tokens_mistral': 596, 'n_tokens_neox': 546, 'n_words': 159}