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

/*
Package util/sig is simple sig trap closer
*/

package sig

import (
	"net"
	"os"
	"os/signal"
	"syscall"

	"github.com/simonz05/util/log"
)

type Cleanup func() error

func sigTrapCloser(l net.Listener, cleanups ...Cleanup) {
	c := make(chan os.Signal, 1)
	signal.Notify(c, syscall.SIGINT, syscall.SIGKILL, syscall.SIGTERM, syscall.SIGHUP)

	go func() {
		for _ = range c {
			for _, cb := range cleanups {
				if err := cb(); err != nil {
					log.Error(err)
				}
			}<commit_msg>sig: sigTrapCloser -> TrapCloser<commit_after>// Copyright 2014 <NAME>. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

/*
Package util/sig is simple sig trap closer
*/

package sig

import (
	"net"
	"os"
	"os/signal"
	"syscall"

	"github.com/simonz05/util/log"
)

type Cleanup func() error

func TrapCloser(l net.Listener, cleanups ...Cleanup) {
	c := make(chan os.Signal, 1)
	signal.Notify(c, syscall.SIGINT, syscall.SIGKILL, syscall.SIGTERM, syscall.SIGHUP)

	go func() {
		for _ = range c {
			for _, cb := range cleanups {
				if err := cb(); err != nil {
					log.Error(err)
				}
			}
{'fraction_non_alphanumeric': 0.132375189107413, 'fraction_numerical': 0.01059001512859304, 'mean_word_length': 3.121495327102804, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '3649558', 'n_tokens_mistral': 535, 'n_tokens_neox': 465, 'n_words': 150}