• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ pfind函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中pfind函数的典型用法代码示例。如果您正苦于以下问题:C++ pfind函数的具体用法?C++ pfind怎么用?C++ pfind使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了pfind函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: procfs_open

/*
 * set things up for doing i/o on
 * the pfsnode (vp).  (vp) is locked
 * on entry, and should be left locked
 * on exit.
 *
 * for procfs we don't need to do anything
 * in particular for i/o.  all that is done
 * is to support exclusive open on process
 * memory images.
 */
int
procfs_open(void *v)
{
	struct vop_open_args *ap = v;
	struct pfsnode *pfs = VTOPFS(ap->a_vp);
	struct proc *p1 = ap->a_p;	/* tracer */
	struct proc *p2;		/* traced */
	int error;

	if ((p2 = pfind(pfs->pfs_pid)) == 0)
		return (ENOENT);	/* was ESRCH, jsp */

	switch (pfs->pfs_type) {
	case Pmem:
		if (((pfs->pfs_flags & FWRITE) && (ap->a_mode & O_EXCL)) ||
		    ((pfs->pfs_flags & O_EXCL) && (ap->a_mode & FWRITE)))
			return (EBUSY);

		if ((error = process_checkioperm(p1, p2)) != 0)
			return (error);

		if (ap->a_mode & FWRITE)
			pfs->pfs_flags = ap->a_mode & (FWRITE|O_EXCL);

		return (0);

	default:
		break;
	}

	return (0);
}
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:43,代码来源:procfs_vnops.c


示例2: linprocfs_close

/*
 * close the pfsnode (vp) after doing i/o.
 * (vp) is not locked on entry or exit.
 *
 * nothing to do for procfs other than undo
 * any exclusive open flag (see _open above).
 */
static int
linprocfs_close(struct vop_close_args *ap)
{
	struct pfsnode *pfs = VTOPFS(ap->a_vp);
	struct proc *p;

	switch (pfs->pfs_type) {
	case Pmem:
		if ((ap->a_fflag & FWRITE) && (pfs->pfs_flags & O_EXCL))
			pfs->pfs_flags &= ~(FWRITE|O_EXCL);
		/*
		 * If this is the last close, then it checks to see if
		 * the target process has PF_LINGER set in p_pfsflags,
		 * if this is *not* the case, then the process' stop flags
		 * are cleared, and the process is woken up.  This is
		 * to help prevent the case where a process has been
		 * told to stop on an event, but then the requesting process
		 * has gone away or forgotten about it.
		 */
		p = NULL;
		if ((ap->a_vp->v_opencount < 2)
		    && (p = pfind(pfs->pfs_pid))
		    && !(p->p_pfsflags & PF_LINGER)) {
			p->p_stops = 0;
			p->p_step = 0;
			wakeup(&p->p_step);
		}
		if (p)
			PRELE(p);
		break;
	default:
		break;
	}
	return (vop_stdclose(ap));
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:42,代码来源:linprocfs_vnops.c


示例3: sys_getpgid

/*
 * Get an arbitrary pid's process group id 
 */
int
sys_getpgid(struct getpgid_args *uap)
{
	struct proc *p = curproc;
	struct proc *pt;
	int error;

	error = 0;

	if (uap->pid == 0) {
		pt = p;
		PHOLD(pt);
	} else {
		pt = pfind(uap->pid);
		if (pt == NULL)
			error = ESRCH;
	}
	if (error == 0) {
		lwkt_gettoken_shared(&pt->p_token);
		uap->sysmsg_result = pt->p_pgrp->pg_id;
		lwkt_reltoken(&pt->p_token);
	}
	if (pt)
		PRELE(pt);
	return (error);
}
开发者ID:victoredwardocallaghan,项目名称:DragonFlyBSD,代码行数:29,代码来源:kern_prot.c


示例4: sys_setpgid

/*
 * set process group (setpgid/old setpgrp)
 *
 * caller does setpgid(targpid, targpgid)
 *
 * pid must be caller or child of caller (ESRCH)
 * if a child
 *	pid must be in same session (EPERM)
 *	pid can't have done an exec (EACCES)
 * if pgid != pid
 * 	there must exist some pid in same session having pgid (EPERM)
 * pid must not be session leader (EPERM)
 */
int
sys_setpgid(struct setpgid_args *uap)
{
	struct proc *curp = curproc;
	struct proc *targp;		/* target process */
	struct pgrp *pgrp = NULL;	/* target pgrp */
	int error;

	if (uap->pgid < 0)
		return (EINVAL);

	if (uap->pid != 0 && uap->pid != curp->p_pid) {
		if ((targp = pfind(uap->pid)) == NULL || !inferior(targp)) {
			if (targp)
				PRELE(targp);
			error = ESRCH;
			targp = NULL;
			goto done;
		}
		lwkt_gettoken(&targp->p_token);
		/* targp now referenced and its token is held */

		if (targp->p_pgrp == NULL ||
		    targp->p_session != curp->p_session) {
			error = EPERM;
			goto done;
		}
		if (targp->p_flags & P_EXEC) {
			error = EACCES;
			goto done;
		}
	} else {
		targp = curp;
		PHOLD(targp);
		lwkt_gettoken(&targp->p_token);
	}
	if (SESS_LEADER(targp)) {
		error = EPERM;
		goto done;
	}
	if (uap->pgid == 0) {
		uap->pgid = targp->p_pid;
	} else if (uap->pgid != targp->p_pid) {
		if ((pgrp = pgfind(uap->pgid)) == NULL ||
	            pgrp->pg_session != curp->p_session) {
			error = EPERM;
			goto done;
		}
	}
	error = enterpgrp(targp, uap->pgid, 0);
done:
	if (pgrp)
		pgrel(pgrp);
	if (targp) {
		lwkt_reltoken(&targp->p_token);
		PRELE(targp);
	}
	return (error);
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:72,代码来源:kern_prot.c


示例5: osi_StopListener

void
osi_StopListener(void)
{
    struct proc *p;

    soclose(rx_socket);
    p = pfind(rxk_ListenerPid);
    if (p)
	psignal(p, SIGUSR1);
}
开发者ID:bagdxk,项目名称:openafs,代码行数:10,代码来源:rx_knet.c


示例6: procfs_inactive

/*
 * _inactive is called when the pfsnode
 * is vrele'd and the reference count goes
 * to zero.  (vp) will be on the vnode free
 * list, so to get it back vget() must be
 * used.
 *
 * for procfs, check if the process is still
 * alive and if it isn't then just throw away
 * the vnode by calling vgone().  this may
 * be overkill and a waste of time since the
 * chances are that the process will still be
 * there and pfind is not free.
 *
 * (vp) is not locked on entry or exit.
 */
int
procfs_inactive(void *v)
{
	struct vop_inactive_args *ap = v;
	struct vnode *vp = ap->a_vp;
	struct pfsnode *pfs = VTOPFS(vp);

	if (pfind(pfs->pfs_pid) == NULL && !(vp->v_flag & VXLOCK))
		vgone(vp);

	return (0);
}
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:28,代码来源:procfs_vnops.c


示例7: main

int main(int argc, char **argv)
{
   int i;
   char *fullpath;

   for (i=1; i<argc; i++) {
      fullpath = pfind(argv[i]);
      if (fullpath == NULL)
        printf("Unable to find %s in $PATH.\n", argv[i]);
      else 
        printf("Found %s @ %s.\n", argv[i], fullpath);
   }
}
开发者ID:Mathiasdm,项目名称:cdt,代码行数:13,代码来源:pfind.c


示例8: osi_StopListener

void
osi_StopListener(void)
{
    struct proc *p;

    /*
     * Have to drop global lock to safely do this.
     * soclose() is currently protected by Giant,
     * but pfind and psignal are MPSAFE.
     */
    int haveGlock = ISAFS_GLOCK();
    if (haveGlock)
	AFS_GUNLOCK();
    soshutdown(rx_socket, 2);
#ifndef AFS_FBSD70_ENV
    soclose(rx_socket);
#endif
    p = pfind(rxk_ListenerPid);
    afs_warn("osi_StopListener: rxk_ListenerPid %lx\n", p);
    if (p)
	psignal(p, SIGUSR1);
#ifdef AFS_FBSD50_ENV
    PROC_UNLOCK(p);
#endif
#ifdef AFS_FBSD70_ENV
    {
      /* Avoid destroying socket until osi_NetReceive has
       * had a chance to clean up */
      int tries;
      struct mtx s_mtx;

      MUTEX_INIT(&s_mtx, "rx_shutdown_mutex", MUTEX_DEFAULT, 0);
      MUTEX_ENTER(&s_mtx);
      tries = 3;
      while ((tries > 0) && (!so_is_disconn(rx_socket))) {
	msleep(&osi_StopListener, &s_mtx, PSOCK | PCATCH,
	       "rx_shutdown_timedwait", 1 * hz);
	--tries;
      }
      if (so_is_disconn(rx_socket))
	soclose(rx_socket);
      MUTEX_EXIT(&s_mtx);
      MUTEX_DESTROY(&s_mtx);
    }
#endif
    if (haveGlock)
	AFS_GLOCK();
}
开发者ID:stevenjenkins,项目名称:openafs,代码行数:48,代码来源:rx_knet.c


示例9: ptrace

/*
 * ptrace()
 *	Cause a process to begin talking to us as a debugging slave
 */
int
ptrace(pid_t pid, port_name name)
{
	struct proc *myproc, *p;
	uint x;
	extern struct proc *pfind();

	/*
	 * If pid == 0 && name == 0, this we return whether we're
	 * being ptrace()'ed.
	 */
	myproc = curthread->t_proc;
	if (!pid && !name) {
		return(myproc->p_dbg.pd_name != 0);
	}

	/*
	 * Find the process.  Bomb if he doesn't exist, or is
	 * already being debugged.
	 */
	p = pfind(pid);
	if (!p) {
		return(err(ESRCH));
	}
	if (p->p_dbg.pd_name) {
		v_sema(&p->p_sema);
		return(err(EBUSY));
	}

	/*
	 * See if we have the rights to do this
	 */
	x = perm_calc(myproc->p_ids, PROCPERMS, &p->p_prot);
	if (!(x & P_DEBUG)) {
		return(err(EPERM));
	}

	/*
	 * Stuff his fields with our request for him to call us.
	 * Then let him go.
	 */
	p->p_dbg.pd_port = -1;
	p->p_dbg.pd_name = name;
	p->p_dbg.pd_flags = PD_ALWAYS|PD_EVENT|PD_EXIT;
	v_sema(&p->p_sema);
	return(0);
}
开发者ID:JamesLinus,项目名称:vsta,代码行数:51,代码来源:ptrace.c


示例10: debugger_writemem_callback

void debugger_writemem_callback(struct allocation_t* ref)
{
	struct message_t* message = __get(ref);
	if (!message)
		return;

	if (message->header.request != 1)
		goto cleanup;

	if (message->socket < 0)
		goto cleanup;

	if (!message->payload)
		goto cleanup;

	struct debugger_writemem_t* request = (struct debugger_writemem_t*)message->payload;
	if (request->process_id < 0)
		goto cleanup;

	if (request->address == 0)
		goto cleanup;

	if (request->dataLength == 0)
		goto cleanup;

	struct  proc* (*pfind)(pid_t) = kdlsym(pfind);

	struct proc* process = pfind(request->process_id);
	if (process == 0)
		goto cleanup;

	void(*_mtx_unlock_flags)(struct mtx *m, int opts, const char *file, int line) = kdlsym(_mtx_unlock_flags);

	int result = proc_rw_mem(process, (void*)request->address, request->dataLength, request->data, &request->dataLength, 1);
	// You need to unlock the process, or the kernel will assert and hang
	PROC_UNLOCK(process);

	WriteLog(LL_Debug, "proc_rw_mem returned %d", result);


cleanup:
	__dec(ref);
}
开发者ID:geekwish,项目名称:mira-project,代码行数:43,代码来源:debugger_plugin.c


示例11: setSocialInfo

//2. Define syscall(struct thread *td, struct syscall_args *arg){...}
static int
setSocialInfo(struct thread *td, struct setSocialInfo_args *arg)
{
 
     //setSocialInfo logic:
     //if PID exists, set social_info to such process
     //if PID does not exists, return error code (-1)
    
    struct proc *process2;
    process2 = pfind(arg->pid);
    if(process2 == NULL){
        td->td_retval[0] = -1;
        return 0;
    }
    else{
        process2->social_info = arg->social_info; //set process's social_info with arg's social_info
        PROC_UNLOCK(process2);
        return 0;
    }
    
}
开发者ID:peiguo,项目名称:ECS150,代码行数:22,代码来源:hw1.c


示例12: getProcessTickets

//2. Define syscall(struct thread *td, struct syscall_args *arg){...}
static int 
getProcessTickets(struct thread *td, struct getProcessTickets_args *arg)
{
    //getProcessTickets logic here
    //if PID exists, get tickets from such process
    //if PID does not exists, return error code (-1)
    struct proc *process1;
    int procTickets;
    process1 = pfind(arg->pid);
    if(process1 == NULL){
        td->td_retval[0] = -1;
        return 0;
    }
    else{
        procTickets = process1->tickets;
        td->td_retval[0] = procTickets;
        PROC_UNLOCK(process1);
        return 0;
    }
    
}
开发者ID:peiguo,项目名称:ECS150,代码行数:22,代码来源:hw1.c


示例13: ptrace

/*
 * sys-trace system call.
 */
void
ptrace()
{
    register struct proc *p;
    register struct a {
        int req;
        int pid;
        int *addr;
        int data;
    } *uap;

    uap = (struct a *)u.u_arg;
    if (uap->req <= 0) {
        u.u_procp->p_flag |= P_TRACED;
        return;
    }
    p = pfind(uap->pid);
    if (p == 0 || p->p_stat != SSTOP || p->p_ppid != u.u_procp->p_pid ||
        !(p->p_flag & P_TRACED)) {
        u.u_error = ESRCH;
        return;
    }
    while (ipc.ip_lock)
        sleep((caddr_t)&ipc, PZERO);
    ipc.ip_lock = p->p_pid;
    ipc.ip_data = uap->data;
    ipc.ip_addr = uap->addr;
    ipc.ip_req = uap->req;
    p->p_flag &= ~P_WAITED;
    setrun(p);
    while (ipc.ip_req > 0)
        sleep((caddr_t)&ipc, PZERO);
    u.u_rval = ipc.ip_data;
    if (ipc.ip_req < 0)
        u.u_error = EIO;
    ipc.ip_lock = 0;
    wakeup((caddr_t)&ipc);
}
开发者ID:ibara,项目名称:retrobsd,代码行数:41,代码来源:sys_process.c


示例14: sys_getsid

/*
 * Get an arbitrary pid's session id.
 */
int
sys_getsid(struct getsid_args *uap)
{
	struct proc *p = curproc;
	struct proc *pt;
	int error;

	error = 0;

	if (uap->pid == 0) {
		pt = p;
		PHOLD(pt);
	} else {
		pt = pfind(uap->pid);
		if (pt == NULL)
			error = ESRCH;
	}
	if (error == 0)
		uap->sysmsg_result = pt->p_session->s_sid;
	if (pt)
		PRELE(pt);
	return (error);
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:26,代码来源:kern_prot.c


示例15: setProcessTickets

//2. Define syscall(struct thread *td, struct syscall_args *arg){...}
static int
setProcessTickets(struct thread *td, struct setProcessTickets_args *arg)
{
   /*
    setProcessTickets logic:
    if PID exists, set tickets to such process
    if PID does not exists, return error code (-1)
    */
    
    struct proc *process0;
    process0 = pfind(arg->pid);
    if(process0 == NULL){
        td->td_retval[0] = -1;
        return 0;
    }
    else{
        process0->tickets = arg->tickets; //set process1's tickets with arg's tickets
        td->td_retval[0] = process0->tickets;
        PROC_UNLOCK(process0);
        return 0;
    }

}
开发者ID:peiguo,项目名称:ECS150,代码行数:24,代码来源:hw1.c


示例16: getSocialInfo

//2. Define syscall(struct thread *td, struct syscall_args *arg){...}
static u_int64_t
getSocialInfo(struct thread *td, struct getSocialInfo_args *arg)
{
 
     //getSocialInfo logic:
     //if PID exists, get social_info from such process
     //if PID does not exists, return error code (-1)
    
    struct proc *process0;
    u_int64_t social_info;
    process0 = pfind(arg->pid);
    if(process0 == NULL){
        td->td_retval[0] = -1;
        return 0;
    }
    else{
        social_info = process0->social_info; //get process's social_info
        td->td_retval[0] = social_info;  //will just truncate
        PROC_UNLOCK(process0);
        return 0;
    }
    
}
开发者ID:peiguo,项目名称:ECS150,代码行数:24,代码来源:hw1.c


示例17: kthread_create

/*
 * Fork a kernel thread.  Any process can request this to be done.
 * The VM space and limits, etc. will be shared with proc0.
 */
int
kthread_create(void (*func)(void *), void *arg,
    struct proc **newpp, const char *fmt, ...)
{
	struct proc *p2;
	register_t rv[2];
	int error;
	va_list ap;

	/*
	 * First, create the new process.  Share the memory, file
	 * descriptors and don't leave the exit status around for the
	 * parent to wait for.
	 */
	error = fork1(&proc0, 0,
	    FORK_SHAREVM|FORK_NOZOMBIE|FORK_SIGHAND, NULL, 0, func, arg, rv);
	if (error)
		return (error);

	p2 = pfind(rv[0]);

	/*
	 * Mark it as a system process and not a candidate for
	 * swapping.
	 */
	p2->p_flag |= P_INMEM | P_SYSTEM;	/* XXX */

	/* Name it as specified. */
	va_start(ap, fmt);
	vsnprintf(p2->p_comm, sizeof p2->p_comm, fmt, ap);
	va_end(ap);

	/* All done! */
	if (newpp != NULL)
		*newpp = p2;
	return (0);
}
开发者ID:NKSG,项目名称:INTER_MANET_NS3,代码行数:41,代码来源:kern_kthread.c



注:本文中的pfind函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pfmt函数代码示例发布时间:2022-05-30
下一篇:
C++ pfatal函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap