// killIfStdioClosed kills the cmd if both stdin and stdout are closed.
513524
func (c *commandConn) killIfStdioClosed() error {
	c.stdioClosedMu.Lock()
	stdioClosed := c.stdoutClosed && c.stdinClosed
	c.stdioClosedMu.Unlock()
	if !stdioClosed {
		return nil
	}
	return c.kill()
}
1082814
func (ref *AsyncProducer) IsClosed() bool {
	ref.Lock()
	defer ref.Unlock()
	return ref.closed
}
1297281
func CloseWindow(args ...int32) {
	if len(args) <= 0 {
		C.close_main_window()
		return
	}

	var hwnd, isHwnd int32
	if len(args) > 0 {
		hwnd = args[0]
	}
	if len(args) > 1 {
		isHwnd = args[1]
	}

	C.close_window(C.uintptr(hwnd), C.uintptr(isHwnd))
}
1317751
func KillCommandSubtree(cmd *exec.Cmd) error {
	return syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)
}
127509
func (f *LockPIDFile) Close() (err error) {
	if f.file != nil {
		if e1 := f.file.Close(); e1 != nil {
			f.log.Warningf("Error closing pid file: %s\n", e1)
		}
		f.log.Debugf("Cleaning up pidfile %s", f.name)
		if err = os.Remove(f.name); err != nil {
			f.log.Warningf("Error removing pidfile: %s\n", err)
		}
	}
	return
}
180070
func (s *GracefulServer) BlockingClose() bool {
	result := s.Close()
	<-s.shutdownFinished
	return result
}
1192236
func (w *BatchedFileWriter) Close() error {
	if w.compressOnClose {
		return w.compressAndCloseLog()
	}

	return w.file.Close()
}
172072
func Close() {
	// we ignore errors here, because we can't really do anything about them
	Clear(0, 0)
	Flush()

	// stop event producer
	cancel_comm <- true
	set_event(interrupt)
	select {
	case <-input_comm:
	default:
	}
	<-cancel_done_comm

	set_console_screen_buffer_size(out, orig_size)
	set_console_window_info(out, &orig_window)
	set_console_cursor_info(out, &orig_cursor_info)
	set_console_cursor_position(out, coord{})
	set_console_mode(in, orig_mode)
	syscall.Close(in)
	syscall.Close(out)
	syscall.Close(interrupt)
	IsInit = false
}
814026
func (r *RLockedFile) Close() (err error) {
	r.mutex.Lock()
	defer r.mutex.Unlock()

	if r.refs == 0 {
		return os.ErrInvalid
	}

	r.refs--
	if r.refs == 0 {
		err = r.File.Close()
	}

	return err
}
388966
func (c *closeHelper) Close(cl io.Closer) {
	if err := cl.Close(); c.err == nil {
		c.err = err
	}
}
1144197
func (e *ExecIO) Close() error {
	if e.closer != nil {
		e.closer.Close()
	}
	if e.fifos != nil {
		return e.fifos.Close()
	}
	return nil
}
134507
func Exitf(format string, args ...interface{}) {
	Global.intLogf(ERROR, format, args...)
	Global.Close() // so that hopefully the messages get logged
	os.Exit(0)
}
238281
func (r *RemoveDirCloser) Close() error {
	return trace.ConvertSystemError(os.RemoveAll(r.Path))
}
1106246
func (l *FileLock) Close() error {
	fd := l.fd
	l.fd = -1
	return syscall.Close(fd)
}
1362263
func (f *KbfsReadCloseResetter) Close() error {
	return f.client.SimpleFSClose(f.ctx, f.opid)
}
40364
func (w *BatchedFileWriter) Close() error {
	// flush upload buffer
	err := w.uploadPartInput()

	w.completeMultipartUpload()

	return err
}
165645
func (f *fifo) Close() (retErr error) {
	for {
		select {
		case <-f.closed:
			f.handle.Close()
			return
		default:
			select {
			case <-f.opened:
				f.closedOnce.Do(func() {
					retErr = f.file.Close()
					f.err = retErr
					close(f.closed)
				})
			default:
				if f.flag&syscall.O_RDWR != 0 {
					runtime.Gosched()
					break
				}
				f.closingOnce.Do(func() {
					close(f.closing)
				})
				reverseMode := syscall.O_WRONLY
				if f.flag&syscall.O_WRONLY > 0 {
					reverseMode = syscall.O_RDONLY
				}
				fn, err := f.handle.Path()
				// if Close() is called concurrently(shouldn't) it may cause error
				// because handle is closed
				select {
				case <-f.closed:
				default:
					if err != nil {
						// Path has become invalid. We will leak a goroutine.
						// This case should not happen in linux.
						f.closedOnce.Do(func() {
							f.err = err
							close(f.closed)
						})
						<-f.closed
						break
					}
					f, err := os.OpenFile(fn, reverseMode|syscall.O_NONBLOCK, 0)
					if err == nil {
						f.Close()
					}
					runtime.Gosched()
				}
			}
		}
	}
}