pid

守护进程

ぃ、小莉子 提交于 2019-11-28 19:40:09
1.创建shell脚本 touch /data/image/deamon.sh vi /data/image/deamon.sh   拷贝脚本 #!/bin/bash test(){ while true do echo `date` >> /data/image/log.txt sleep 5 done } case $1 in start) path="/root/shouhu.pid" if [ -f $path ]; then pid=`cat /data/image/deamon.pid` echo "pid $pid running..." else test & echo $! > /data/image/deamon.pid echo "running $!..." fi ;; stop) pid=`cat /data/image/deamon.pid` if [ -z pid ] then kill -9 $pid echo "stop $pid..." rm -rf /data/image/deamon.pid fi ;; restart) path="/data/image/deamon.pid" if [ -f "$path" ];then pid=`cat /data/image/deamon.pid` kill -9 $pid echo " stop

Why does getpid() return pid_t instead of int?

こ雲淡風輕ζ 提交于 2019-11-28 19:32:08
问题 What's the logic behind calls like getpid() returning a value of type pid_t instead of an unsigned int ? Or int ? How does this help? I'm guessing this has to do with portability? Guaranteeing that pid_t is the same size across different platforms that may have different sizes of int s etc.? 回答1: I think it's the opposite: making the program portable across platforms, regardless of whether, e.g., a PID is 16 or 32 bits (or even longer). 回答2: The reason is to allow nasty historical

PHP 无限级分类(递归)

百般思念 提交于 2019-11-28 19:01:07
php无限极分类 今天琢磨了好久,现在想想除了更加深沉的意识到自己身上的不足之外,毫无收获,垂头丧气的感觉真真确确迎面而来 其实啊,网上遍地都是,,傻傻的我,还是在这里做下笔记,搜到了先放这里,后面会再测试的,, 案例一 <?php $arr = array( array('id'=>1,'name'=>'电脑','pid'=>0), array('id'=>2,'name'=>'手机','pid'=>0), array('id'=>3,'name'=>'笔记本','pid'=>1), array('id'=>4,'name'=>'台式机','pid'=>1), array('id'=>5,'name'=>'智能机','pid'=>2), array('id'=>6,'name'=>'功能机','pid'=>2), array('id'=>7,'name'=>'超级本','pid'=>3), array('id'=>8,'name'=>'游戏本','pid'=>3), ); function demo($arr,$id,$level) { $list =array(); foreach ($arr as $k=>$v){ if ($v['pid'] == $id){ $v['level']=$level; $v['son'] = demo($arr,$v['id'],$level

后台权限管理层级分配两个必要的递归函数

冷暖自知 提交于 2019-11-28 18:51:30
public function treeLevel(array $data, int $pid = 0, string $html = ‘–’, int $level = 0) { static a r r = [ ] ; f o r e a c h ( arr = []; foreach ( a r r = [ ] ; f o r e a c h ( data as KaTeX parse error: Expected '}', got 'EOF' at end of input: … if ( pid == $val[‘pid’]) { // 重复一个字符多少次 v a l [ ′ h t m l ′ ] = s t r r e p e a t ( val['html'] = str_repeat( v a l [ ′ h t m l ′ ] = s t r r ​ e p e a t ( html, $level * 2); $val[‘level’] = $level + 1; $arr[] = $val; t h i s − > t r e e L e v e l ( this->treeLevel( t h i s − > t r e e L e v e l ( data, $val[‘id’], $html, $val[‘level’]); } } return

widow怎么结束某端口占用

笑着哭i 提交于 2019-11-28 17:30:18
netstat -aon|findstr "9090" 查找端口占用进程 tasklist|findstr "8224" 根据pid查找占用方式 taskkill /f /t /im javaw.exe或者 taskkill /pid 8224 /F 结束进程 备注:至于我第一个命令没好使,可能没配置java的环境变量???有时间在查吧!!!!!!!!!! 来源: https://www.cnblogs.com/cuteCoderSnow/p/11416290.html

Must my pidfile be located in /var/run?

穿精又带淫゛_ 提交于 2019-11-28 16:11:15
问题 I'm asking in both contexts: technically and stylistically. Can my application/daemon keep a pidfile in /opt/my_app/run/ ? Is it very bad to do so? My need is this: my daemon runs under a specific user, and the implementor must mkdir a new directory in /var/run , chown, and chgrp it to make my daemon run. Seems easier to just keep the pidfile local (to the daemon). 回答1: I wouldn't put a pidfile under an application installation directory such as /opt/my_app/whatever . This directory could be

JS当中的无限分类递归树

穿精又带淫゛_ 提交于 2019-11-28 15:05:01
列表转换成树形结构方法定义: //javascript 树形结构 function toTree(data) { // 删除 所有 children,以防止多次调用 data.forEach(function(item) { delete item.children; }); // 将数据存储为 以 id 为 KEY 的 map 索引数据列 var map = {}; data.forEach(function(item) { // 在该方法中可以给每个元素增加其他属性 item.text = item.name; map[item.id] = item; }); // console.log(map); var val = []; data.forEach(function(item) { // 以当前遍历项,的pid,去map对象中找到索引的id var parent = map[item.pid]; // 好绕啊,如果找到索引,那么说明此项不在顶级当中,那么需要把此项添加到,他对应的父级中 if (parent) { // 可以给每个父节点添加属性 parent.iconCls = "i-folder"; // 添加到父节点的子节点属性中 (parent.children || (parent.children = [])).push(item); } else { /

About the pid of the process

拟墨画扇 提交于 2019-11-28 13:13:33
I've a somewhat silly question, if i have a series of processes that are created ... these are not necessarily some sort of inheritance, the pid of the processes have to be numbers continuous or random pids ? This is determined by the Operating System. In general, they are usually sequentially assigned by the OS. However, this behavior is not something to base decisions upon, since most operating system specifications state that the process ID allocation is not deterministic (ie: it could be random, and could change in a future version, etc). On Linux, pids are generally allocated sequentially

多任务编程

梦想与她 提交于 2019-11-28 12:49:53
对话级多任务 进程级 多任务 进程是运行中的程序 pid_t getpid();//返回当前进程得PID pid_t getppid();//返回父进程PID task_struct结构体是一个进程存在的唯一标示, 也就是进程控制块。PCB struct task_struct *task[512] ={&init_task}; 指针数组 pid hash数组 帮助管理进程PID fork();创建一个新的进程 #include<unistd.h> pit_t fork(void); 函数返回值:在父进程中创建返回的是子进程得PID号; 在子进程中返回的是0 ,创建失败返回-1 线程级 多任务 来源: http://www.cnblogs.com/yuankaituo/p/4236728.html

Mac OS X: Getting detailed process information (specifically its launch arguments) for arbitrary running applications using its PID

ε祈祈猫儿з 提交于 2019-11-28 12:15:53
I am trying to detect when particular applications are launched. Currently I am using NSWorkspace , registering for the "did launch application" notification. I also use the runningApplications method to get apps that are currently running when my app starts. For most apps, the name of the app bundle is enough. I have a plist of "known apps" that I cross check with the name of that passed in the notification. This works fine until you come across an app that acts as a proxy for launching another application using command line arguments. Example: The newly released Portal on the Mac doesn't