Exemplo n.º 1
0
/*
 * Check that a child is making forward progress by comparing the timestamps it
 * recorded before making its last syscall.
 * If no progress is being made, send SIGKILLs to it.
 */
static void check_child_progress(struct childdata *child)
{
	struct syscallrecord *rec;
	struct timeval tv;
	time_t diff, old, now;
	pid_t pid;

	pid = child->pid;

	if (pid == EMPTY_PIDSLOT)
		return;

	rec = &child->syscall;

	old = rec->tv.tv_sec;

	if (old == 0)
		return;

	gettimeofday(&tv, NULL);
	now = tv.tv_sec;

	if (old > now)
		diff = old - now;
	else
		diff = now - old;

	/* hopefully the common case. */
	if (diff < 30)
		return;

	/* After 30 seconds of no progress, send a kill signal. */
	if (diff == 30) {
		stuck_syscall_info(child);
		debugf("child %d (pid %u) hasn't made progress in 30 seconds! Sending SIGKILL\n",
				child->num, pid);
		child->kill_count++;
		kill_pid(pid);
	}

	/* if we're still around after 40s, repeatedly send SIGKILLs every second. */
	if (diff < 40)
		return;

	debugf("sending another SIGKILL to child %d (pid %u). [kill count:%d] [diff:%d]\n",
		child->num, pid, child->kill_count, diff);
	child->kill_count++;
	kill_pid(pid);

	/* if we wrapped, just reset it, we'll pick it up next time around. */
	if (diff > 2146) {	/* max adjtime offset, + the 1 second since last time. */
		output(1, "child %u wrapped! old=%lu now=%lu\n", child->num, old, now);
		rec->tv.tv_sec = now;
		return;
	}
}
Exemplo n.º 2
0
/*
 * Check that a child is making forward progress by comparing the timestamps it
 * recorded before making its last syscall.
 * If no progress is being made, send SIGKILLs to it.
 */
static bool is_child_making_progress(struct childdata *child)
{
	struct syscallrecord *rec;
	struct timespec tp;
	time_t diff, old, now;
	pid_t pid;

	pid = child->pid;

	if (pid == EMPTY_PIDSLOT)
		return TRUE;

	rec = &child->syscall;

	old = rec->tp.tv_sec;

	/* haven't done anything yet. */
	if (old == 0)
		return TRUE;

	clock_gettime(CLOCK_MONOTONIC, &tp);
	now = tp.tv_sec;

	if (old > now)
		diff = old - now;
	else
		diff = now - old;

	/* hopefully the common case. */
	if (diff < 30)
		return TRUE;

	/* After 30 seconds of no progress, send a kill signal. */
	if (diff == 30) {
		stuck_syscall_info(child);
		debugf("child %d (pid %u) hasn't made progress in 30 seconds! Sending SIGKILL\n",
				child->num, pid);
		child->kill_count++;
		kill_pid(pid);
	}

	/* if we're still around after 40s, repeatedly send SIGKILLs every second. */
	if (diff < 40)
		return FALSE;

	debugf("sending another SIGKILL to child %d (pid %u). [kill count:%d] [diff:%d]\n",
		child->num, pid, child->kill_count, diff);
	child->kill_count++;
	kill_pid(pid);

	return FALSE;
}
Exemplo n.º 3
0
/*
 * Shutdown fullscreen view.
 */
static void
fs3270_save_callback(struct raw3270_request *rq, void *data)
{
	struct fs3270 *fp;

	fp = (struct fs3270 *) rq->view;

	/* Correct idal buffer element 0 address. */
	fp->rdbuf->data[0] -= 5;
	fp->rdbuf->size += 5;

	/*
	 * If the rdbuf command failed or the idal buffer is
	 * to small for the amount of data returned by the
	 * rdbuf command, then we have no choice but to send
	 * a SIGHUP to the application.
	 */
	if (rq->rc != 0 || rq->rescnt == 0) {
		if (fp->fs_pid)
			kill_pid(fp->fs_pid, SIGHUP, 1);
		fp->rdbuf_size = 0;
	} else
		fp->rdbuf_size = fp->rdbuf->size - rq->rescnt;
	raw3270_request_reset(rq);
	wake_up(&fp->wait);
}
Exemplo n.º 4
0
static int fake_ioctl(int nr, unsigned long int cmd, void *arg)
{
    unsigned long fw;

    if (debug > LOG_NODEBUG)
        info("Video loopback %d cmd %lu", nr, cmd);

    loops[nr]->ioctlnr = cmd;
    memcpy(loops[nr]->ioctldata, arg, _IOC_SIZE(cmd));
    loops[nr]->ioctllength = _IOC_SIZE(cmd);

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
    kill_proc(loops[nr]->pid, SIGIO, 1);    /* Signal the pipe feeder */
#else
    kill_pid(loops[nr]->pid, SIGIO, 1);
#endif

#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
    fw = loops[nr]->frameswrite;
    wait_event_interruptible(loops[nr]->wait, fw != loops[nr]->frameswrite);
#else
    interruptible_sleep_on(&loops[nr]->wait);
#endif    
    if (cmd & IOC_IN) {
        if (memcmp (arg, loops[nr]->ioctlretdata, _IOC_SIZE(cmd)))
            return 1;
    } else {
        memcpy (arg, loops[nr]->ioctlretdata, _IOC_SIZE(cmd));
    }
    return 0;
}
Exemplo n.º 5
0
static int ulo_xfer_begin(struct ulo_dev *dev, unsigned long long start,
			  int size)
{
	int err;
	struct ulo_qelem *qelem;
	struct ulo_queue *queue;
	struct ulo_ctl_ready ready;
	spinlock_t *spin;

	BUILD_BUG_ON(sizeof(qelem->ctl.rcvreq.start) != sizeof(start)
		     || sizeof(qelem->ctl.rcvreq.size) != sizeof(size));
	//UloDbg("start %Lu, size %d\n", start, size);

	qelem = ulo_wait(dev, UloQ_READY);
	err = PTR_ERR(qelem);
	if (IS_ERR(qelem))
		goto out;

	ready = qelem->ctl.ready;
	qelem->ctl.rcvreq.start = start;
	qelem->ctl.rcvreq.size = size;
	queue = dev->queue + UloQ_RCVREQ;
	spin = &queue->spin;
	spin_lock(spin);
	list_add_tail(&qelem->list, &queue->head);
	spin_unlock(spin);

	/* wake up the user process */
	err = kill_pid(ready.pid, ready.signum, 0);
 out:
	UloDbgErr(err);
	return err;
}
Exemplo n.º 6
0
static void
smb_put_super(struct super_block *sb)
{
	struct smb_sb_info *server = SMB_SB(sb);

	lock_kernel();

	smb_lock_server(server);
	server->state = CONN_INVALID;
	smbiod_unregister_server(server);

	smb_close_socket(server);

	if (server->conn_pid)
		kill_pid(server->conn_pid, SIGTERM, 1);

	bdi_destroy(&server->bdi);
	kfree(server->ops);
	smb_unload_nls(server);
	sb->s_fs_info = NULL;
	smb_unlock_server(server);
	put_pid(server->conn_pid);
	kfree(server);

	unlock_kernel();
}
Exemplo n.º 7
0
Arquivo: inode.c Projeto: 020gzh/linux
static void ncp_put_super(struct super_block *sb)
{
	struct ncp_server *server = NCP_SBP(sb);

	ncp_lock_server(server);
	ncp_disconnect(server);
	ncp_unlock_server(server);

	ncp_stop_tasks(server);

	mutex_destroy(&server->rcv.creq_mutex);
	mutex_destroy(&server->root_setup_lock);
	mutex_destroy(&server->mutex);

	if (server->info_sock)
		sockfd_put(server->info_sock);
	sockfd_put(server->ncp_sock);
	kill_pid(server->m.wdog_pid, SIGTERM, 1);
	put_pid(server->m.wdog_pid);

	bdi_destroy(&server->bdi);
	kfree(server->priv.data);
	kfree(server->auth.object_name);
	vfree(server->rxbuf);
	vfree(server->txbuf);
	vfree(server->packet);
	call_rcu(&server->rcu, delayed_free);
}
Exemplo n.º 8
0
static void wb_dfe_exit ( void ) 
{
    struct pid *pid_ptr;
    int pid_index = 0;
    int i ;
    PRINTF("Killing module thread ...\n");
    for (i = 0; i < dfe_nr_threads; i++) {
        killed[i] = 0;
    }
    dfe_gone = 1;
    while (pid_index < dfe_nr_threads) {
        for (i = 0; i < dfe_nr_threads; i++) {
            if (0 == killed[i]) {
                pid_ptr = find_get_pid(pid[i]);
                PRINTF("we try to kill kernel thread %d ,thread id is %d !\n", i,pid[i]);
                if (!kill_pid(pid_ptr, SIGTERM, 1)) {
                    PRINTF("Unable to kill thread. Waiting for completion !\n");
                    wake_up(&wait);
                    wait_for_completion(&evt_dead);
                }
                PRINTF("~~~~~kernel thread %d ,thread id  %d was killed !~~~~~\n", i,pid[i]);
                killed[i] = 1;
                ++pid_index;
            }
        }
    }
    PRINTF("Bye bye, %s !\n",DRIVER_DESC);
}
Exemplo n.º 9
0
static void ncp_put_super(struct super_block *sb)
{
	struct ncp_server *server = NCP_SBP(sb);

	ncp_lock_server(server);
	ncp_disconnect(server);
	ncp_unlock_server(server);

	ncp_stop_tasks(server);

#ifdef CONFIG_NCPFS_NLS
	/* unload the NLS charsets */
	unload_nls(server->nls_vol);
	unload_nls(server->nls_io);
#endif /* CONFIG_NCPFS_NLS */

	if (server->info_filp)
		fput(server->info_filp);
	fput(server->ncp_filp);
	kill_pid(server->m.wdog_pid, SIGTERM, 1);
	put_pid(server->m.wdog_pid);

	kfree(server->priv.data);
	kfree(server->auth.object_name);
	vfree(server->rxbuf);
	vfree(server->txbuf);
	vfree(server->packet);
	sb->s_fs_info = NULL;
	kfree(server);
}
Exemplo n.º 10
0
static void check_lock(lock_t *_lock)
{
	pid_t pid;

	if (_lock->lock != LOCKED)
		return;

	/* First the easy case. If it's held by a dead pid, release it. */
	pid = _lock->owner;
	if (pid_alive(pid) == -1) {
		if (errno != ESRCH)
			return;

		debugf("Found a lock held by dead pid %d. Freeing.\n", pid);
		unlock(_lock);
		return;
	}

	/* If a pid has had a lock a long time, something is up. */
	if (_lock->contention > STEAL_THRESHOLD) {
		debugf("pid %d has held lock for too long. Releasing, and killing.\n", pid);
		kill_pid(pid);
		unlock(_lock);
		return;
	}
	return;
}
Exemplo n.º 11
0
uint64_t stack_pop(struct stack_t *s) {
    if (s->size == 0) {
        printk("[stack_pop ]: STACK UNDERFLOW\n"); kill_pid(task_pid(current), SIGKILL, 1);
        return 0;
    }
    s->size--;
    return s->items[s->size];
}
Exemplo n.º 12
0
/***********************************************************************
 * Stack implementations.
 */
void stack_push(struct stack_t *s, uint64_t u) {
    if (s->size == STACKSIZE) {
        printk("[stack_push]: STACK OVERFLOW\n"); kill_pid(task_pid(current), SIGKILL, 1);
        return;
    }
    s->items[s->size] = u;
    s->size++;
    return;
}
Exemplo n.º 13
0
static int vloopback_release(struct file *f)
#endif
{
    struct video_device *loopdev = video_devdata(f);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
    priv_ptr ptr = (priv_ptr)dev_get_drvdata(&loopdev->dev);
#else
    priv_ptr ptr = (priv_ptr)loopdev->vd_private_data;
#endif    
    int nr = ptr->pipenr;

    if (debug > LOG_NODEBUG)
        info("Video loopback %d", nr);

    if (ptr->in) {
        down(&loops[nr]->lock);
        if (loops[nr]->buffer && !loops[nr]->ropen) {
            rvfree(loops[nr]->buffer, loops[nr]->buflength * num_buffers);
            loops[nr]->buffer = NULL;
        }

        up(&loops[nr]->lock);
        loops[nr]->frameswrite++;
        
        if (waitqueue_active(&loops[nr]->wait))
            wake_up(&loops[nr]->wait);

        loops[nr]->width = 0;
        loops[nr]->height = 0;
        loops[nr]->palette = 0;
        loops[nr]->wopen = 0;
        pipesused--;
    } else {
        down(&loops[nr]->lock);

        if (loops[nr]->buffer && !loops[nr]->wopen) {
            rvfree(loops[nr]->buffer, loops[nr]->buflength * num_buffers);
            loops[nr]->buffer = NULL;
        }

        up(&loops[nr]->lock);
        loops[nr]->ropen = 0;

        if (loops[nr]->zerocopy && loops[nr]->buffer) {
            loops[nr]->ioctlnr = 0;
            loops[nr]->ioctllength = 0;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
            kill_proc(loops[nr]->pid, SIGIO, 1);
#else
            kill_pid(loops[nr]->pid, SIGIO, 1);
#endif            
        }
    }

    return 0;
}
Exemplo n.º 14
0
static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg,
		int error_code, struct r3964_block_header *pBlock)
{
	struct r3964_message *pMsg;
	unsigned long flags;

	if (pClient->msg_count < R3964_MAX_MSG_COUNT - 1) {
queue_the_message:

		pMsg = kmalloc(sizeof(struct r3964_message),
				error_code ? GFP_ATOMIC : GFP_KERNEL);
		TRACE_M("add_msg - kmalloc %p", pMsg);
		if (pMsg == NULL) {
			return;
		}

		spin_lock_irqsave(&pClient->lock, flags);

		pMsg->msg_id = msg_id;
		pMsg->arg = arg;
		pMsg->error_code = error_code;
		pMsg->block = pBlock;
		pMsg->next = NULL;

		if (pClient->last_msg == NULL) {
			pClient->first_msg = pClient->last_msg = pMsg;
		} else {
			pClient->last_msg->next = pMsg;
			pClient->last_msg = pMsg;
		}

		pClient->msg_count++;

		if (pBlock != NULL) {
			pBlock->locks++;
		}
		spin_unlock_irqrestore(&pClient->lock, flags);
	} else {
		if ((pClient->last_msg->msg_id == R3964_MSG_ACK)
		    && (pClient->last_msg->error_code == R3964_OVERFLOW)) {
			pClient->last_msg->arg++;
			TRACE_PE("add_msg - inc prev OVERFLOW-msg");
		} else {
			msg_id = R3964_MSG_ACK;
			arg = 0;
			error_code = R3964_OVERFLOW;
			pBlock = NULL;
			TRACE_PE("add_msg - queue OVERFLOW-msg");
			goto queue_the_message;
		}
	}
	/* Send SIGIO signal to client process: */
	if (pClient->sig_flags & R3964_USE_SIGIO) {
		kill_pid(pClient->pid, SIGIO, 1);
	}
}
Exemplo n.º 15
0
static void * th_timeout(void *arg)
{
	proc_wt_t *wt = (proc_wt_t *)arg;
	msleep(wt->timeout);
	printf("timeout %d and cancle wait_pid\n", wt->timeout);
	wt->status |= PROC_S_TIMEOUT;
	kill_pid(wt);
	//pthread_cancel(wt->thr_wait);
	return NULL;
}
Exemplo n.º 16
0
void lbr_stack_pop(struct stack_lbr_t *s) {
    if (s->size == 0) {
        printk("[lbr_stack_pop ]: STACK UNDERFLOW\n"); kill_pid(task_pid(current), SIGKILL, 1);
        return;
    }
    s->size--;
    get_cpu();
    put_lbr(&s->items[s->size]); 
    put_cpu();
}
Exemplo n.º 17
0
void lbr_stack_push(struct stack_lbr_t *s) {
    if (s->size == STACKSIZE) {
        printk("[lbr_stack_push]: STACK OVERFLOW\n"); kill_pid(task_pid(current), SIGKILL, 1);
        return;
    }
    get_cpu();
    get_lbr(&s->items[s->size]);
    put_cpu();
    s->size++;
}
Exemplo n.º 18
0
int kill_pid( char *name, int pidx) 
{
	// Loesche alle Prozesse, die unter PPid diese ID haben
	struct dirent *datei;
	DIR *inhalt;
	FILE *fp;
	char fpname[KV];
	char fpgets[KV];
	int pid;

	deep++;
	if (( inhalt = opendir(procpfad)) == NULL ) {
		fprintf(stderr,"Opendir brachte NULL");
		return -1;
	}

	while (1) {
		datei = readdir( inhalt );
		if ( datei == NULL ) {
			break;
		}
		
		if ( datei->d_type == DT_DIR &&  datei->d_name[0] != '.'  && ( datei->d_name[0] >= '0' && datei->d_name[0] <= '9') ) {
			sprintf(fpname,"%s/%s/status",procpfad,datei->d_name);
			if ((fp = fopen(fpname,"r")) == NULL ) continue;
			pid = 0;
			while(1) {
				if ( (fgets( fpgets, KV, fp)) == NULL ) break;
				if ( (strstr(fpgets,name) != NULL)  && (strstr(fpgets,"PPid") != NULL) ) {
					pid = 1; 
				}	
			}
			fclose(fp);
			if ( pid != 0 ) {
				#ifdef WD
				DEBUG( REST, $DB  1, "PPID = %d in %s bei deep=%d\n",pid,datei->d_name,deep);
				#endif
				pid = (int) atol(datei->d_name);
				kill_pid(datei->d_name,pid);
				deep--;
			}
		}
	}
	closedir(inhalt);
	#ifdef WD
	DEBUG( REST, $DB  1, "Kill mit pidx = %d\n",pidx);
	#endif
	kill( pidx, SIGTERM);
	return 0;
}
Exemplo n.º 19
0
static void
fs3270_restore_callback(struct raw3270_request *rq, void *data)
{
	struct fs3270 *fp;

	fp = (struct fs3270 *) rq->view;
	if (rq->rc != 0 || rq->rescnt != 0) {
		if (fp->fs_pid)
			kill_pid(fp->fs_pid, SIGHUP, 1);
	}
	fp->rdbuf_size = 0;
	raw3270_request_reset(rq);
	wake_up(&fp->wait);
}
Exemplo n.º 20
0
static void exitModuleTest ( void ) {
    struct pid *pid_ptr;

    PRINTF("Killing module thread ...\n");

    moduleTestExiting = 1;
    pid_ptr = find_get_pid(pid);
    if (!kill_pid (pid_ptr,SIGTERM,1)) {
        PRINTF("Unable to kill thread. Waiting for completion !\n");
        wake_up (&wait);	
        wait_for_completion(&evt_dead);
    }
    PRINTF("Bye bye, %s !\n",DRIVER_DESC);	    
}
Exemplo n.º 21
0
/* kill off any connections chosen by the user */
static int traverse_fn1(const struct connections_key *key,
			const struct connections_data *crec,
			void *private_data)
{
	if (crec->cnum == -1 && process_exists(crec->pid)) {
		char buf[30];
		slprintf(buf,sizeof(buf)-1,"kill_%s", procid_str_static(&crec->pid));
		if (cgi_variable(buf)) {
			kill_pid(crec->pid);
			sleep(SLEEP_TIME);
		}
	}
	return 0;
}
Exemplo n.º 22
0
static void abort_suspicious_process(int bad_pid)
{
	struct pid *bad_p = find_vpid(bad_pid);

	if (bad_p)
	{
		printk(KERN_ERR "Killing process(%d) with signal %d\n",
			bad_pid, SIGABRT);
		kill_pid(bad_p, SIGABRT, 1);
	}
	else
	{
		printk(KERN_ERR "%s: Invalid pid %d.\n", __func__, bad_pid);
	}
}
/**
 * Kills a process and all of its children
 * */
void PCAPExporterPipe::kill_all(int ppid)
{
	sleep(2); //give the process some time to finish its work
	bfs::path path("/proc/");
	if (!bfs::exists(path) || !bfs::is_directory(path)){
		THROWEXCEPTION("Directory /proc not found...");
	}

	std::string line;
	std::vector<int> my_pids;
	std::vector<int> my_ppids;
	my_ppids.push_back(ppid);
	bfs::directory_iterator dir_iterator = bfs::directory_iterator(path);
	bfs::directory_iterator end_itr;
	while (dir_iterator != end_itr) {
		if (bfs::is_directory(dir_iterator->status())  &&
				this->checkint(dir_iterator->leaf().c_str()))
		{
			std::string filename = dir_iterator->path().file_string() + "/stat";
			std::ifstream myfile(filename.c_str());
			if (myfile.is_open()) {
				getline (myfile,line);
				char *token = strtok (const_cast<char*>(line.c_str())," ");
				int count = 0;
				while (token != NULL) {
					if (count++ == 3) { // field of parent pid
						for (std::vector<int>::iterator it = my_ppids.begin(); it != my_ppids.end(); it++) {
							if (atoi(token) == *it) {
								msg(MSG_DEBUG, "Pid %s  is a child of %d", dir_iterator->leaf().c_str(), *it );
								my_pids.push_back(boost::lexical_cast<int>(dir_iterator->leaf()));
								my_ppids.push_back(boost::lexical_cast<int>(dir_iterator->leaf()));
								break;
							}
						}
					}
					token = strtok (NULL, " ");
				}
				myfile.close();
			}
		}
		dir_iterator++;
	}
	my_pids.push_back(ppid);
	for (std::vector<int>::iterator it = my_pids.begin(); it != my_pids.end(); it++) {
		msg(MSG_DEBUG, "Killing Pid %d", *it);
		kill_pid(*it);
	}
}
Exemplo n.º 24
0
static ssize_t
backfire_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
{
	int signo;
	struct pid *pid;

	if (sscanf(buf, "%d", &signo) >= 1) {
		if (signo > 0 && signo < 32) {
			pid = get_pid(task_pid(current));
			do_gettimeofday(&sendtime);
			kill_pid(pid, signo, 1);
		} else
			printk(KERN_ERR "Invalid signal no. %d\n", signo);
	}
	return strlen(buf);
}
Exemplo n.º 25
0
static int rtw_resume(struct usb_interface *pusb_intf)
{
	struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf);
	struct rtw_adapter *padapter = dvobj->if1;
	struct net_device *pnetdev;
	struct pwrctrl_priv *pwrpriv = NULL;
	int ret = -1;
	unsigned long start_time = jiffies;

	DBG_8723A("==> %s (%s:%d)\n", __func__, current->comm, current->pid);

	if (!padapter)
		goto exit;
	pnetdev = padapter->pnetdev;
	pwrpriv = &padapter->pwrctrlpriv;

	down(&pwrpriv->lock);
	rtw_reset_drv_sw23a(padapter);
	pwrpriv->bkeepfwalive = false;

	DBG_8723A("bkeepfwalive(%x)\n", pwrpriv->bkeepfwalive);
	if (pm_netdev_open23a(pnetdev, true) != 0) {
		up(&pwrpriv->lock);
		goto exit;
	}

	netif_device_attach(pnetdev);
	netif_carrier_on(pnetdev);

	up(&pwrpriv->lock);

	if (padapter->pid[1] != 0) {
		DBG_8723A("pid[1]:%d\n", padapter->pid[1]);
		kill_pid(find_vpid(padapter->pid[1]), SIGUSR2, 1);
	}

	rtw23a_roaming(padapter, NULL);

	ret = 0;
exit:
	if (pwrpriv)
		pwrpriv->bInSuspend = false;
	DBG_8723A("<===  %s return %d.............. in %dms\n", __func__,
		  ret, jiffies_to_msecs(jiffies - start_time));

	return ret;
}
Exemplo n.º 26
0
int killall( char *programmname ) 
{
	struct dirent *datei;
	DIR *inhalt;
	int fp;
	char fpname[KV];
	char fpgets[KV];
	int pid,erg;

	if (( inhalt = opendir(procpfad)) == NULL ) {
		perror("Opendir brachte NULL");
		return -1;
	}

	while (1) {
		datei = readdir( inhalt );
		if ( datei == NULL ) {
			break;
		}
		if ( datei->d_type == DT_DIR &&  datei->d_name[0] != '.'  && ( datei->d_name[0] >= '0' && datei->d_name[0] <= '9') ) {
			sprintf(fpname,"%s/%s/cmdline",procpfad,datei->d_name);
			if ((fp = open(fpname,O_RDONLY)) != -1 ) {
				pid = 0;
				if ((erg=read(fp, fpgets, KV )) > 0 ) {
					int i;
					for ( i = 0; i < erg-1; i++ ) {
						if ( fpgets[i] == '\0' ) fpgets[i] = ' ';
					}
					if ( strstr(fpgets,programmname) != NULL ) {
						pid = (int) atol(datei->d_name);
					}	
					if ( pid != 0 ) { 
						#ifdef WD
						DEBUG( REST, $DB  1, "Kill_pid mit %s und %d",datei->d_name, pid);
						#endif
						kill_pid(datei->d_name, pid);
					}
				}
				close(fp);
			}
		}
	}
	closedir(inhalt);
	return 1;
}
Exemplo n.º 27
0
/* kill off any connections chosen by the user */
static int traverse_fn1(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* state)
{
	struct connections_data crec;

	if (dbuf.dsize != sizeof(crec))
		return 0;

	memcpy(&crec, dbuf.dptr, sizeof(crec));

	if (crec.cnum == -1 && process_exists(crec.pid)) {
		char buf[30];
		slprintf(buf,sizeof(buf)-1,"kill_%d", (int)crec.pid);
		if (cgi_variable(buf)) {
			kill_pid(crec.pid);
		}
	}
	return 0;
}
Exemplo n.º 28
0
static void __exit ModExit(void)
{
	if(thread_id){
		kill_pid(task_pid(thread_id), SIGTERM, 1);
	}
	
	wait_for_completion(&on_exit);

	device_destroy(template_class, device_number);
	class_destroy(template_class);

	printk("trying to unregister 0x%x\n", device_number);
	
	cdev_del( driver_object );
	unregister_chrdev_region( device_number, 1 );
	
	printk("exiting\n");
	
}
Exemplo n.º 29
0
/* Checks running processes for a minute and 
 * closes all processes not important to system, 
 * except the test browser.
 */
static int process_init(void)
{
	printk(KERN_INFO "Loading my_process module\n");
	
        struct task_struct *task;
	    int run_loop = 1;

        while(run_loop < myint){     
        	for_each_process(task){
 			    if(strstr(myfile, task->comm) == NULL){  
                    printk(KERN_INFO "Match not found %s\n", task->comm);   //list process trying to be open
                    kill_pid(find_vpid(task->pid), SIGKILL, 1);  //kill process
                }
        	}               
		printk(KERN_INFO "+++++++++++++++next list +++++++++++++++++++++ %d\n", run_loop);
		msleep(1000); //1 second
		run_loop++;
	}	
        return 0;
}
Exemplo n.º 30
0
static __exit void udpcli_exit(void)
{
	if( (1 == _udpcli_running) &&  _udpcli_thread ) 
	{
		printk("call kthread_stop\n");
#if 0
		/* 3.6.6 kernel has this  */
		kill_pid(find_vpid(_udpcli_thread->pid), SIGKILL, 0);
#elif 1
		/* 3.2.o kernel use this */
#endif
		kthread_stop(_udpcli_thread);
	}

	if( udpcli_sock )
	{
		sock_release(udpcli_sock);
	}

	printk("module exit.\n");
}