// Detach from the process being debugged, optionally killing it.
960974
func (dbp *Process) Detach(kill bool) (err error) {
	if dbp.exited {
		return nil
	}
	if kill && dbp.childProcess {
		err := dbp.kill()
		if err != nil {
			return err
		}
		dbp.bi.Close()
		return nil
	}
	if !kill {
		// Clean up any breakpoints we've set.
		for _, bp := range dbp.breakpoints.M {
			if bp != nil {
				_, err := dbp.ClearBreakpoint(bp.Addr)
				if err != nil {
					return err
				}
			}
		}
	}
	dbp.execPtraceFunc(func() {
		err = dbp.detach(kill)
		if err != nil {
			return
		}
		if kill {
			err = killProcess(dbp.pid)
		}
	})
	dbp.detached = true
	dbp.postExit()
	return
}
1064468
func (b *IrcBot) Disconnect() {
	log.Debugln("disconnection...")
	for _, ch := range b.channels {
		log.WithField("channel", ch).Debugln("leaving")
		b.Say(ch, "See you soon...")
	}
	b.writer.PrintfLine("QUIT")
	b.conn.Close()
	log.Debugln("connection close")
	// b.Exit <- true
}
749563
func (m *MockVolumeDriver) Detach(arg0 string, arg1 map[string]string) error {
	ret := m.ctrl.Call(m, "Detach", arg0, arg1)
	ret0, _ := ret[0].(error)
	return ret0
}
127636
func (d *ImpatientDebugDumper) Shutdown() {
	if d.shutdownFunc != nil {
		d.shutdownFunc()
		<-d.shutdownDoneCh
	}
}
818464
func DetachLoopDevice(loopDevice ...string) error {
	args := append([]string{"--detach"}, loopDevice...)
	_, err := losetup(args...)
	return err
}
1245538
func (s *VolumeServer) Detach(
	ctx context.Context,
	req *api.SdkVolumeDetachRequest,
) (*api.SdkVolumeDetachResponse, error) {
	if s.cluster() == nil || s.driver(ctx) == nil {
		return nil, status.Error(codes.Unavailable, "Resource has not been initialized")
	}

	if len(req.GetVolumeId()) == 0 {
		return nil, status.Error(codes.InvalidArgument, "Must supply volume id")
	}

	// Get access rights
	err := s.checkAccessForVolumeId(ctx, req.GetVolumeId(), api.Ownership_Write)
	if err != nil && !IsErrorNotFound(err) {
		return nil, err
	}

	// Check options
	options := req.GetDriverOptions()
	if options == nil {
		options = make(map[string]string)
	}
	options[mountattachoptions.OptionsRedirectDetach] = "true"
	if req.GetOptions() != nil {
		options[mountattachoptions.OptionsForceDetach] = fmt.Sprint(req.GetOptions().GetForce())
		options[mountattachoptions.OptionsUnmountBeforeDetach] = fmt.Sprint(req.GetOptions().GetUnmountBeforeDetach())
	}

	err = s.driver(ctx).Detach(req.GetVolumeId(), options)
	if err != nil && !IsErrorNotFound(err) {
		return nil, status.Errorf(
			codes.Internal,
			"Failed to detach volume %s: %v",
			req.GetVolumeId(),
			err)
	}

	return &api.SdkVolumeDetachResponse{}, nil
}
670821
func (ec2i *FakeEC2Impl) DetachVolume(request *ec2.DetachVolumeInput) (resp *ec2.VolumeAttachment, err error) {
	panic("Not implemented")
}
992309
func (p *PoliciesClient) Detach(ctx context.Context, attachmentID *identity.ID) error {
	return p.client.RoundTrip(ctx, "DELETE", "/policy-attachments/"+attachmentID.String(), nil, nil, nil)
}
1352368
func (nbd *NBD) Disconnect() {
	nbd.mutex.Lock()
	defer nbd.mutex.Unlock()

	logrus.Infof("Disconnecting device %v...", nbd.devicePath)

	syscall.Unmount(nbd.devicePath, 0)
	if nbd.IsConnected() {
		logrus.Infof("Issuing a disconnect on %v", nbd.devicePath)
		ioctl(nbd.deviceFile.Fd(), NBD_DISCONNECT, 0)
		logrus.Infof("Clearing NBD queue %v", nbd.devicePath)
		ioctl(nbd.deviceFile.Fd(), NBD_CLEAR_QUE, 0)
		logrus.Infof("Clearing NBD socket %v", nbd.devicePath)
		ioctl(nbd.deviceFile.Fd(), NBD_CLEAR_SOCK, 0)
		logrus.Infof("Closing NBD device file %v", nbd.devicePath)
		nbd.deviceFile.Close()
		nbd.deviceFile = nil

		dummy := make([]byte, 1)
		logrus.Infof("Waking up control socket for %v", nbd.devicePath)
		syscall.Write(nbd.socket, dummy)
		logrus.Infof("Closing control socket for %v", nbd.devicePath)
		syscall.Close(nbd.socket)
		nbd.socket = 0
	}
	logrus.Infof("Disconnected device %v", nbd.devicePath)
}
88490
func (os *OpenStack) DetachDisk(instanceID, volumeID string) error {
	volume, err := os.getVolume(volumeID)
	if err != nil {
		return err
	}
	if volume.Status != VolumeInUseStatus {
		errmsg := fmt.Sprintf("can not detach volume %s, its status is %s.", volume.Name, volume.Status)
		glog.Error(errmsg)
		return errors.New(errmsg)
	}
	cClient, err := os.NewComputeV2()
	if err != nil {
		return err
	}
	if volume.AttachedServerID != instanceID {
		errMsg := fmt.Sprintf("Disk: %s has no attachments or is not attached to compute: %s", volume.Name, instanceID)
		glog.Error(errMsg)
		return errors.New(errMsg)
	}

	// This is a blocking call and effects kubelet's performance directly.
	// We should consider kicking it out into a separate routine, if it is bad.
	err = volumeattach.Delete(cClient, instanceID, volume.ID).ExtractErr()
	if err != nil {
		glog.Errorf("Failed to delete volume %s from compute %s attached %v", volume.ID, instanceID, err)
		return err
	}
	glog.V(2).Infof("Successfully detached volume: %s from compute: %s", volume.ID, instanceID)
	return nil
}
1360102
func (eng *Engine) Disconnect(err error) {
	_ = eng.Inject(func() { eng.disconnect(err) })
	<-eng.running
}
71834
func (conn *gdbConn) detach() error {
	if conn.conn == nil {
		// Already detached
		return nil
	}
	_, err := conn.exec([]byte{'$', 'D'}, "detach")
	conn.conn.Close()
	conn.conn = nil
	return err
}
511895
func (v *volumeClient) Detach(volumeID string, options map[string]string) error {
	return v.doVolumeSet(
		volumeID,
		&api.VolumeSetRequest{
			Action: &api.VolumeStateAction{
				Attach: api.VolumeActionParam_VOLUME_ACTION_PARAM_OFF,
			},
			Options: options,
		},
	)
}
1310500
func (u *storageosUtil) DetachVolume(b *storageosUnmounter, devicePath string) error {
	if !isLoopDevice(devicePath) {
		return nil
	}
	if _, err := os.Stat(devicePath); os.IsNotExist(err) {
		return nil
	}
	return removeLoopDevice(devicePath, b.exec)
}
1118337
func (m *MockCgroupnetcls) RemoveProcess(cgroupname string, pid int) error {
	ret := m.ctrl.Call(m, "RemoveProcess", cgroupname, pid)
	ret0, _ := ret[0].(error)
	return ret0
}
1090767
func Attach(pid int, _ []string) (*Process, error) {
	// TODO: Probably should have SeDebugPrivilege before starting here.
	err := _DebugActiveProcess(uint32(pid))
	if err != nil {
		return nil, err
	}
	exepath, err := findExePath(pid)
	if err != nil {
		return nil, err
	}
	dbp := New(pid)
	if err = dbp.initialize(exepath, []string{}); err != nil {
		dbp.Detach(true)
		return nil, err
	}
	return dbp, nil
}
635007
func (s *oracleVolumeSource) DetachVolumes(ctx context.ProviderCallContext, params []storage.VolumeAttachmentParams) ([]error, error) {
	attachAsMap, err := s.getStorageAttachments()
	if err != nil {
		return nil, errors.Trace(err)
	}
	toDelete := make([]string, len(params))
	ret := make([]error, len(params))
	for i, val := range params {
		found := false
		for _, attach := range attachAsMap[string(val.InstanceId)] {
			if val.VolumeId == attach.Storage_volume_name {
				toDelete[i] = attach.Name
				found = true
			}
		}
		if !found {
			toDelete[i] = ""
			ret[i] = errors.NotFoundf(
				"volume attachment for instance %v and volumeID %v not found",
				val.InstanceId, val.VolumeId)
		}
	}
	for i, val := range toDelete {
		if val == "" {
			continue
		}
		ret[i] = s.api.DeleteStorageAttachment(val)
	}
	return ret, nil
}