本文整理汇总了C++中pid_task函数的典型用法代码示例。如果您正苦于以下问题:C++ pid_task函数的具体用法?C++ pid_task怎么用?C++ pid_task使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pid_task函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gr_chroot_shmat
int
gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
const time_t shm_createtime)
{
#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
struct pid *pid = NULL;
time_t starttime;
if (unlikely(!grsec_enable_chroot_shmat))
return 1;
if (likely(!proc_is_chrooted(current)))
return 1;
read_lock(&tasklist_lock);
pid = find_vpid(shm_cprid);
if (pid) {
struct task_struct *p;
p = pid_task(pid, PIDTYPE_PID);
task_lock(p);
starttime = p->start_time.tv_sec;
if (unlikely(!have_same_root(current, p) &&
time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime))) {
task_unlock(p);
read_unlock(&tasklist_lock);
gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
return 0;
}
task_unlock(p);
} else {
pid = find_vpid(shm_lapid);
if (pid) {
struct task_struct *p;
p = pid_task(pid, PIDTYPE_PID);
task_lock(p);
if (unlikely(!have_same_root(current, p))) {
task_unlock(p);
read_unlock(&tasklist_lock);
gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
return 0;
}
task_unlock(p);
}
}
read_unlock(&tasklist_lock);
#endif
return 1;
}
示例2: send_signal
int send_signal(int myPid) {
/* send the signal */
struct siginfo info;
int ret;
struct task_struct *t;
struct pid *pid_struct;
pid_t pid;
memset(&info, 0, sizeof(struct siginfo));
info.si_signo = SIG_TEST;
info.si_code = SI_QUEUE; // this is bit of a trickery: SI_QUEUE is normally used by sigqueue from user space,
// and kernel space should use SI_KERNEL. But if SI_KERNEL is used the real_time data
// is not delivered to the user space signal handler function.
info.si_int = 1; //real time signals may have 32 bits of data.
rcu_read_lock();
pid = myPid; //integer value of pid
pid_struct = find_get_pid(pid); //function to find the pid_struct
t = pid_task(pid_struct,PIDTYPE_PID); //find the task_struct
if(t == NULL){
printk("no such pid\n");
rcu_read_unlock();
return -ENODEV;
}
rcu_read_unlock();
ret = send_sig_info(SIG_TEST, &info, t); //send the signal
if (ret < 0) {
printk("error sending signal\n");
return ret;
}
return 0;
}
示例3: print_thread_info
static void print_thread_info(int pid)
{
struct task_struct *ptask;
struct pid *k;
struct thread_info *threadinfo = NULL;
union thread_union *threadunion = NULL;
/* find tak by pid */
k = find_vpid(pid);
ptask = pid_task(k, PIDTYPE_PID);
printk(KERN_INFO "process : %s, pid : %d\n", ptask->comm, ptask->pid);
/* ptask->stack point to thread_unuion */
threadinfo = get_thread_info(ptask);
/* union thread_union
* {
* struct thread_info thread_info;
* unsigned long stack[THREAD_SIZE/sizeof(long)];
* };
*/
threadunion = get_thread_union(threadinfo);
show_kstack(threadunion);
//printk(KERN_INFO "task stack : %p\n", ptask->stack);
}
示例4: handle_get_pid_cap
static int handle_get_pid_cap(struct rpc_desc *desc, void *_msg, size_t size)
{
struct pid *pid;
kernel_krg_cap_t cap;
const struct cred *old_cred;
int ret;
pid = krg_handle_remote_syscall_begin(desc, _msg, size,
NULL, &old_cred);
if (IS_ERR(pid)) {
ret = PTR_ERR(pid);
goto out;
}
ret = krg_get_cap(pid_task(pid, PIDTYPE_PID), &cap);
if (ret)
goto out_end;
ret = rpc_pack_type(desc, cap);
if (ret)
goto err_cancel;
out_end:
krg_handle_remote_syscall_end(pid, old_cred);
out:
return ret;
err_cancel:
rpc_cancel(desc);
goto out_end;
}
示例5: send_signal
void send_signal(unsigned long arg){
int ret;
struct siginfo info;
struct task_struct *t;
/* send the signal */
memset(&info, 0, sizeof(struct siginfo));
info.si_signo = SIG_TEST;
info.si_code = SI_QUEUE; // this is bit of a trickery: SI_QUEUE is normally used by sigqueue from user space,
// and kernel space should use SI_KERNEL. But if SI_KERNEL is used the real_time data
// is not delivered to the user space signal handler function.
info.si_int = arg; //real time signals may have 32 bits of data.
rcu_read_lock();
// t = find_task_by_pid_type(PIDTYPE_PID, pid); //find the task_struct associated with this pid
t = pid_task(find_pid_ns(user_process_pid, &init_pid_ns), PIDTYPE_PID);
if(t == NULL){
printk(KERN_WARNING "no such pid\n");
rcu_read_unlock();
return -ENODEV;
}
rcu_read_unlock();
ret = send_sig_info(SIG_TEST, &info, t); //send the signal
if (ret < 0) {
printk("error sending signal\n");
return ret;
}
return ret;
}
示例6: ged_dvfs_probe_signal
void ged_dvfs_probe_signal(int signo)
{
static int cache_pid=GED_NO_UM_SERVICE;
static struct task_struct *t=NULL;
struct siginfo info;
info.si_signo = signo;
info.si_code = SI_QUEUE;
info.si_int = 1234;
if(cache_pid!=g_probe_pid)
{
cache_pid = g_probe_pid;
if(g_probe_pid==GED_NO_UM_SERVICE)
t = NULL;
else
t = pid_task(find_vpid(g_probe_pid), PIDTYPE_PID);
}
if(t!=NULL)
{
send_sig_info(signo, &info, t);
ged_log_buf_print(ghLogBuf_ged_srv, "[GED_K] send signo %d to ged_srv [%d]",signo, g_probe_pid);
}
else
{
g_probe_pid = GED_NO_UM_SERVICE;
ged_log_buf_print(ghLogBuf_ged_srv, "[GED_K] ged_srv not running");
}
}
示例7: intr_handler
static irqreturn_t intr_handler(int irq,void * dev_id)
{
pid_t pid;
struct task_struct *p;
static long interval = 0;
if(count==0){
interval=jiffies;
}
//count the interval between two irqs
interval=jiffies-interval;
printk("The interval between two interrupts is %ld\n",interval);
interval=jiffies;
//printk("Interrupt on %s —–%d /n",dev->name,dev->irq);
count++;
//pid = sys_getpid();
asm(
"movl $0x20,%%eax\n\t"
"int $0x80\n\t"
:"=a"(pid)
);
p = pid_task(find_vpid(pid),PIDTYPE_PID);
printk("进程%d的状态:state=%ld prio=%d policy=%d\n",pid,p->state,p->prio,p->policy);
return IRQ_NONE;
}
示例8: check_ma
static void check_ma(struct quadd_hrt_ctx *hrt_ctx)
{
pid_t pid;
struct pid *pid_s;
struct task_struct *task = NULL;
struct mm_struct *mm;
struct quadd_ctx *quadd_ctx = hrt_ctx->quadd_ctx;
unsigned long vm_size, rss_size;
pid = quadd_ctx->param.pids[0];
rcu_read_lock();
pid_s = find_vpid(pid);
if (pid_s)
task = pid_task(pid_s, PIDTYPE_PID);
rcu_read_unlock();
if (!task)
return;
mm = task->mm;
if (!mm)
return;
vm_size = mm->total_vm;
rss_size = get_mm_rss(mm);
if (vm_size != hrt_ctx->vm_size_prev ||
rss_size != hrt_ctx->rss_size_prev) {
make_sample(hrt_ctx, pid, vm_size, rss_size);
hrt_ctx->vm_size_prev = vm_size;
hrt_ctx->rss_size_prev = rss_size;
}
}
示例9: SYSCALL_DEFINE2
SYSCALL_DEFINE2(smunch, pid_t,pid, long, bit_pattern){
//Check if multi threaded
struct task_struct *p;
bool ret;
p = pid_task(find_vpid(pid), PIDTYPE_PID);
if(!p){
pr_alert("\nprocess table is null");
return -1;
}
ret = current_is_single_threaded();
if(ret == false){
pr_alert("\nError : Multithreaded process, cannot proceed\n");
return -1;
}
//Check if traced
if(p->ptrace & PT_PTRACED){
pr_alert("\nError : Traced process, cannot proceed\n");
return -1;
}
//Check if zombie state
if(p->exit_state == EXIT_ZOMBIE){
if((1 << (SIGKILL-1)) & bit_pattern){
release_task(p);
}
return 0;
}
else{
p->pending.signal.sig[0] |= bit_pattern;
wake_up_process(p);
}
return 0;
}
示例10: notify_user
static void notify_user(struct job *job, int err, int cid)
{
struct siginfo sinfo;
struct task_struct *task;
memset(&sinfo, 0, sizeof(struct siginfo));
sinfo.si_code = SI_QUEUE; /* important, make si_int available */
sinfo.si_int = job->id;
sinfo.si_signo = SIGUSR1;
sinfo.si_uid = current_uid();
if (job->state == STATE_SUCCESS)
sinfo.si_errno = 0;
else if (job->state == STATE_FAILED)
sinfo.si_errno = -err; /* make it positive */
else
return;
task = pid_task(find_vpid(job->pid), PIDTYPE_PID);
if (!task) {
INFO("Consumer/%d: pid[%d] not found", cid, job->pid);
return;
}
send_sig_info(SIGUSR1, &sinfo, task);
}
示例11: gr_handle_chroot_unix
int
gr_handle_chroot_unix(const pid_t pid)
{
#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
struct pid *spid = NULL;
if (unlikely(!grsec_enable_chroot_unix))
return 1;
if (likely(!proc_is_chrooted(current)))
return 1;
read_lock(&tasklist_lock);
spid = find_vpid(pid);
if (spid) {
struct task_struct *p;
p = pid_task(spid, PIDTYPE_PID);
task_lock(p);
if (unlikely(!have_same_root(current, p))) {
task_unlock(p);
read_unlock(&tasklist_lock);
gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
return 0;
}
task_unlock(p);
}
read_unlock(&tasklist_lock);
#endif
return 1;
}
示例12: Moca_InitProcessManagment
int Moca_InitProcessManagment(int id)
{
// Monitored pids
struct pid *pid;
if(!(Moca_tasksMap=Moca_InitHashMap(Moca_tasksHashBits,
2*(1<<Moca_tasksHashBits), sizeof(struct _moca_task), NULL,
Moca_TaskInitializer)))
goto fail;
rcu_read_lock();
pid=find_vpid(id);
if(!pid)
{
// Skip internal process
rcu_read_unlock();
goto clean;
}
Moca_initTask=pid_task(pid, PIDTYPE_PID);
rcu_read_unlock();
if(Moca_InitTaskData()!=0)
goto clean;
return 0;
clean:
Moca_FreeMap(Moca_tasksMap);
fail:
printk(KERN_NOTICE "Moca fail initializing process data \n");
return 1;
}
示例13: sys_setsid
asmlinkage long sys_setsid(void)
{
struct task_struct *group_leader = current->group_leader;
struct pid *sid = task_pid(group_leader);
pid_t session = pid_vnr(sid);
int err = -EPERM;
write_lock_irq(&tasklist_lock);
/* Fail if I am already a session leader */
if (group_leader->signal->leader)
goto out;
/* Fail if a process group id already exists that equals the
* proposed session id.
*/
if (pid_task(sid, PIDTYPE_PGID))
goto out;
group_leader->signal->leader = 1;
__set_special_pids(sid);
spin_lock(&group_leader->sighand->siglock);
group_leader->signal->tty = NULL;
spin_unlock(&group_leader->sighand->siglock);
err = session;
out:
write_unlock_irq(&tasklist_lock);
return err;
}
示例14: VOS_SuspendTask
/*****************************************************************************
Function : VOS_SuspendTask
Description: Suspend a task
Calls : OSAL_SuspendTask
Called By :
Input : ulTaskID -- id of a task
Output : none
Return : return VOS_OK if success
Other : none
*****************************************************************************/
VOS_UINT32 VOS_SuspendTask( VOS_UINT32 ulTaskID )
{
struct task_struct *tsk;
pid_t ulTemp;
if( ulTaskID >= vos_TaskCtrlBlkNumber )
{
return(VOS_ERR);
}
ulTemp = vos_TaskCtrlBlk[ulTaskID].ulLinuxThreadId;
tsk = pid_task(find_vpid(ulTemp), PIDTYPE_PID);
if ( VOS_NULL_PTR == tsk)
{
return(VOS_ERR);
}
if ( tsk->pid != ulTemp )
{
printk("susupend find task to set pri fail.\r\n");
return VOS_ERR;
}
set_task_state(tsk, TASK_UNINTERRUPTIBLE);
if (tsk == current)
{
schedule();
}
return VOS_OK;
}
示例15: VOS_ResumeTask
/*****************************************************************************
Function : VOS_ResumeTask
Description: Resume a task
Input : ulTaskID -- ID of task
Return : Return VOS_OK if successd
*****************************************************************************/
VOS_UINT32 VOS_ResumeTask( VOS_UINT32 ulTaskID )
{
pid_t ulTemp;
struct task_struct *tsk;
if(ulTaskID >= vos_TaskCtrlBlkNumber)
{
return(VOS_ERR);
}
ulTemp = vos_TaskCtrlBlk[ulTaskID].ulLinuxThreadId;
tsk = pid_task(find_vpid(ulTemp), PIDTYPE_PID);
if ( VOS_NULL_PTR == tsk)
{
return(VOS_ERR);
}
if ( tsk->pid != ulTemp )
{
printk("resume find task to set pri fail.\r\n");
return VOS_ERR;
}
/*set_task_state(tsk, TASK_RUNNING);*/
wake_up_process(tsk);
return VOS_OK;
}