青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

posts - 319, comments - 22, trackbacks - 0, articles - 11
  C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

Find path of an application

Posted on 2012-04-18 22:44 RTY 閱讀(613) 評(píng)論(0)  編輯 收藏 引用 所屬分類: C/C++Mac os
Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Find path of an application


  • SubjectRe: Find path of an application
  • From: Terry Lambert <email@hidden>
  • Date: Tue, 16 Dec 2008 02:01:54 -0800
  • Delivered-to: email@hidden
  • Delivered-to: email@hidden

On Dec 16, 2008, at 1:00 AM, Rakesh Singhal wrote:
I am done with finding the process is running or not. Thanks a lot. Still I am stuck with second issue to find the path to my application in my system. Actually there are 3 steps:

1. To know that application is running or not?  Now it is done. 2. If not then get the path of application where it was installed (user can change the path during installation). 3. Launch the application.

My code is standard C++ tool so I want to use only C and C++ APIs. Please suggest me. 

You said this was a GUI app that you didn't control the sources to. So control it anyway by renaming the binary in the bundle and putting a stub in there that will save off the id for you and then reexec the real binary:


--- example with no error checking --- #include <mach-o/dyld.h>	/* _NSGetExecutablePath */ #include <limits.h>		/* PATH_MAX */ #include <unistd.h>		/* execve */ #include <libgen.h>		/* dirname */ #include <string.h>		/* strcpy */

#define BINARYNAME	"myreal_executable"

int main(int ac, char *av[]) { 	char pathbuf[PATH_MAX + 1]; 	char real_executable[PATH_MAX + 1]; 	char *bundle_id; 	int  bufsize = sizeof(pathbuf);

	_NSGetExecutablePath( pathbuf, &bufsize);

	bundle_id = dirname(pathbuf);

	strcpy(real_executable, bundle_id); 	strcat(real_executable, "/"); 	strcat(real_executable, BINARYNAME);

	execv(real_executable, av); } --------------------

Then write the path into /var/run/program.<pid> before you do the execv call to give control to the real binary.

Then in your other program go looking for /var/run/program.*. When you find one, take the pid and do an atoi() on it to get the integer pid back. Then end it a kill(pid, 0).

This function will return one of three things:

(1) 0, indicating that the process exists and you have the right to send it signals

(2) -1, with errno set to EPERM, indicating that the process exists and you do not have rights to send it a signal

(3) -1, with errno set to ESRCH, indicating that the process does not (yet) exist

-

Ideally, all this would be unnecessary because you put your daemon and the program you want to give it a UI into the same bundle, which ,means either one of them can find the other by looking at the dirname() from their own call to _NSGetExecutablePath().

No grovelling around trying to find out where something came from, because it tells you.

-- Terry _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list      (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden  
References: 
 >Find path of an application (From: "Rakesh Singhal" <email@hidden>)
 >Re: Find path of an application (From: Jean-Daniel Dupas <email@hidden>)
 >Re: Find path of an application (From: "Rakesh Singhal" <email@hidden>)
 >Re: Find path of an application (From: Jean-Daniel Dupas <email@hidden>)
 >Re: Find path of an application (From: "Rakesh Singhal" <email@hidden>)

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            一区二区亚洲| 一区二区视频欧美| 亚洲专区国产精品| 一本大道久久a久久综合婷婷| 亚洲欧美日韩另类精品一区二区三区| 欧美激情视频一区二区三区在线播放 | 国产精品美女久久久免费| 99成人在线| 亚洲一区二区成人| 国产日韩欧美在线观看| 久久一本综合频道| 欧美成人精品福利| 亚洲欧美视频一区| 久久精品日韩| 9色porny自拍视频一区二区| 中文在线不卡视频| 国模精品一区二区三区色天香| 美日韩免费视频| 欧美日韩精品久久| 久久国产精品99精品国产| 久久久久久久久综合| 日韩一级在线观看| 亚洲欧美电影在线观看| 亚洲高清久久久| 国产精品99久久久久久宅男 | 国产精品亚洲美女av网站| 久久国产主播| 欧美激情va永久在线播放| 亚洲女人av| 美女精品在线| 久久成人精品视频| 欧美国产日韩在线观看| 久久综合狠狠综合久久综青草 | 伊人久久噜噜噜躁狠狠躁 | 亚洲欧美日韩综合| 老司机午夜精品视频在线观看| 亚洲一区二区三区在线| 久久天堂成人| 欧美在线观看网站| 欧美日韩国语| 欧美国产高清| 黄色成人精品网站| 亚洲一区二区在线播放| 野花国产精品入口| 久久久噜噜噜久久| 久久www成人_看片免费不卡| 欧美日韩精品免费观看视一区二区| 久久天堂精品| 国产午夜久久| 亚洲一区二区三区四区在线观看| 一本色道久久88综合亚洲精品ⅰ| 久久精品视频在线看| 欧美一区二区网站| 欧美婷婷久久| 夜夜爽www精品| 亚洲桃花岛网站| 欧美日韩伊人| 日韩一区二区免费看| 日韩视频免费观看高清完整版| 久久综合色播五月| 免费影视亚洲| 黄色日韩网站| 久久免费黄色| 麻豆精品网站| 亚洲视频欧美在线| 亚洲午夜在线观看视频在线| 欧美激情成人在线| 亚洲精品免费一区二区三区| 尤物99国产成人精品视频| 久久国产色av| 蜜桃av综合| 亚洲国产欧美一区二区三区同亚洲| 久久精品国产亚洲高清剧情介绍| 久久激情五月激情| 黄色精品一区二区| 久久综合久久综合久久| 欧美~级网站不卡| 日韩香蕉视频| 欧美性猛交视频| 亚洲欧美日韩精品久久久| 久久不射中文字幕| 精品动漫一区| 欧美精品在欧美一区二区少妇| 亚洲精品欧美| 亚洲色图制服丝袜| 国产婷婷色一区二区三区四区| 欧美一区二区在线看| 六月婷婷一区| a4yy欧美一区二区三区| 国产精品乱子久久久久| 欧美一区二区三区四区在线观看 | 亚洲国产成人精品久久久国产成人一区 | 欧美成人精品h版在线观看| 亚洲激情在线观看| 欧美午夜精品久久久久免费视| 亚洲天天影视| 女人香蕉久久**毛片精品| 亚洲免费不卡| 国产日韩欧美制服另类| 免费亚洲一区二区| 亚洲一区国产视频| 欧美顶级大胆免费视频| 午夜精品网站| 亚洲经典三级| 国产视频一区在线| 欧美国产精品专区| 欧美在线在线| 亚洲乱码国产乱码精品精98午夜| 久久久亚洲高清| 99视频精品| 精品999成人| 国产精品久久毛片a| 久久综合中文| 欧美在线视频观看| 夜夜嗨av一区二区三区| 老司机67194精品线观看| 亚洲一区二区免费看| 在线观看亚洲专区| 国产欧美日韩一区二区三区| 欧美日韩福利视频| 免播放器亚洲一区| 久久国产精品免费一区| 一本久久a久久精品亚洲| 欧美激情第二页| 久久久噜噜噜久久| 欧美一级理论性理论a| 一区二区三区免费看| 亚洲黄网站在线观看| 国产日韩在线看片| 国产精品每日更新| 欧美日韩一区三区四区| 欧美韩日视频| 欧美高清视频在线观看| 老司机一区二区| 久久不射网站| 久久国产日韩| 久久精品欧美日韩| 欧美在线观看视频| 午夜日韩福利| 欧美一区二区三区免费看| 亚洲性视频网站| 亚洲中无吗在线| 亚洲欧美激情诱惑| 午夜精品久久久久久久99樱桃 | 欧美激情第一页xxx| 欧美成人午夜激情在线| 欧美电影免费观看大全| 欧美成人精精品一区二区频| 麻豆国产精品va在线观看不卡| 久久一区二区三区超碰国产精品| 欧美一区二区三区在线免费观看| 亚洲欧美日韩精品久久奇米色影视| 一本色道**综合亚洲精品蜜桃冫| 亚洲精品乱码久久久久久按摩观 | 国产日本欧洲亚洲| 国产婷婷精品| 有坂深雪在线一区| 亚洲伦理精品| 亚洲一区欧美二区| 久久国产天堂福利天堂| 欧美女主播在线| 欧美日韩免费一区| 国产精品久久久久毛片大屁完整版 | 欧美成人在线影院| 欧美精品在线视频观看| 欧美午夜精品伦理| 国产亚洲亚洲| 最新日韩中文字幕| 午夜精品影院| 免费不卡在线观看av| 亚洲精选国产| 性欧美xxxx视频在线观看| 久久人人97超碰国产公开结果| 欧美精品在线观看一区二区| 国产精品ⅴa在线观看h| 精品不卡在线| 一区二区三区日韩精品| 久久精品30| 亚洲片国产一区一级在线观看| 宅男精品导航| 久久免费的精品国产v∧| 欧美视频免费在线| 韩日精品视频一区| 亚洲一区二区三区高清 | 欧美一级欧美一级在线播放| 久久综合99re88久久爱| 99视频精品| 久热精品在线| 国产日韩欧美麻豆| 在线中文字幕一区| 裸体一区二区| 亚洲欧美日韩天堂一区二区| 欧美国产第一页| 黄色成人在线网址| 欧美伊人久久久久久久久影院| 亚洲国产欧美在线| 久久久久久一区二区| 国产乱码精品一区二区三区五月婷 | 亚洲婷婷综合色高清在线| 久久亚洲一区二区三区四区|