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

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

Find path of an application

Posted on 2012-04-18 22:44 RTY 閱讀(624) 評論(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>
            欧美日韩在线三区| 另类av导航| 亚洲国产精品一区制服丝袜 | 蜜臀久久99精品久久久久久9| 亚洲一二三区在线| 亚洲精品美女免费| 黄色亚洲免费| 国产精品专区一| 欧美日韩综合久久| 欧美成人黑人xx视频免费观看| 久久av一区二区| 午夜亚洲视频| 亚洲一区二区视频在线观看| 亚洲精选久久| 亚洲精品精选| 亚洲高清在线精品| 欧美激情精品久久久久久黑人| 久久综合九色综合久99| 久久一综合视频| 午夜精品久久久久久久白皮肤| 亚洲神马久久| 亚洲无线视频| 亚洲午夜极品| 亚洲欧美日韩国产精品| 亚洲网站视频| 午夜精品久久久久影视| 亚洲一区二区在线免费观看视频| 在线亚洲精品| 亚洲一二区在线| 亚洲综合色噜噜狠狠| 亚洲一区久久| 午夜一区二区三视频在线观看| 亚洲午夜电影| 午夜欧美电影在线观看| 亚洲欧美日韩综合| 欧美一区二区在线观看| 久久精品毛片| 久久阴道视频| 欧美国产专区| 欧美午夜无遮挡| 国产精品综合色区在线观看| 国产欧美在线观看一区| 国产一区二区三区最好精华液| 好男人免费精品视频| 在线看欧美视频| 亚洲另类春色国产| 亚洲一区免费| 久久精品日韩欧美| 免费观看国产成人| 亚洲三级视频| 亚洲字幕在线观看| 久久精品国产亚洲aⅴ| 免费成人在线观看视频| 欧美日韩理论| 国产亚洲欧美色| 亚洲高清在线观看一区| 9人人澡人人爽人人精品| 亚洲曰本av电影| 久久婷婷蜜乳一本欲蜜臀| 亚洲第一级黄色片| 一区二区三区视频观看| 欧美一区午夜视频在线观看| 老司机凹凸av亚洲导航| 欧美日韩一区三区四区| 国产亚洲第一区| 亚洲精品美女久久7777777| 亚洲一区一卡| 免费日韩一区二区| 一区二区三区四区五区视频| 欧美一级成年大片在线观看| 欧美成人一区二免费视频软件| 国产精品av一区二区| 伊人久久男人天堂| 亚洲在线观看免费视频| 麻豆freexxxx性91精品| 一区二区不卡在线视频 午夜欧美不卡在 | 久久综合伊人77777麻豆| 亚洲激情视频在线播放| 午夜精品一区二区三区在线视| 嫩模写真一区二区三区三州| 国产精品乱人伦一区二区 | 亚洲欧美日韩国产中文| 另类专区欧美制服同性| 一本色道久久综合亚洲精品婷婷| 久久国产一区| 国产精品久久久久高潮| 亚洲人午夜精品免费| 久久电影一区| 夜夜狂射影院欧美极品| 麻豆成人精品| 国产一区二区三区视频在线观看 | 亚洲天堂av电影| 欧美成人午夜激情| 国产综合久久久久久| 亚洲私人影院在线观看| 欧美激情精品久久久六区热门| 亚洲欧美激情诱惑| 欧美日韩国产在线播放网站| 亚洲国产日韩欧美在线动漫| 久久精品一区二区三区不卡牛牛| 一区二区高清在线观看| 欧美第一黄网免费网站| 国内精品亚洲| 欧美一区二区三区四区在线| 一区二区三区四区五区视频| 欧美国产免费| 亚洲国产精品久久久久秋霞不卡 | 激情校园亚洲| 欧美影院在线播放| 一区二区欧美国产| 欧美精品在线观看播放| 亚洲国产精品99久久久久久久久| 久久久久久伊人| 亚洲一区二区在线播放| 国产精品久久久久国产a级| 亚洲最新在线| 亚洲精选在线观看| 欧美另类69精品久久久久9999| 欧美午夜精品久久久| 依依成人综合视频| 亚洲毛片网站| 国产日韩欧美视频| 国产亚洲欧美一区二区三区| 韩国一区二区三区美女美女秀| 亚洲成人中文| 宅男精品导航| 久久精品天堂| 欧美激情精品久久久久久变态| 亚洲日本欧美| 亚洲影院色无极综合| 久久er精品视频| 欧美成人黄色小视频| 欧美午夜在线视频| 韩国欧美国产1区| 亚洲精品在线视频| 欧美一级专区免费大片| 麻豆成人在线播放| 亚洲另类一区二区| 新片速递亚洲合集欧美合集| 麻豆av福利av久久av| 欧美午夜电影完整版| 激情久久综艺| 亚洲一区二区三区乱码aⅴ| 久久美女性网| 一区二区三区四区国产精品| 久久精品国产免费| 欧美日韩综合视频网址| 激情久久五月天| 亚洲自拍偷拍色片视频| 麻豆freexxxx性91精品| 中国亚洲黄色| 欧美国产视频在线| 国产午夜久久| 亚洲一区二区三区中文字幕| 老司机精品视频一区二区三区| 日韩一级黄色av| 米奇777超碰欧美日韩亚洲| 国产精品免费一区二区三区观看| 亚洲国产婷婷综合在线精品| 欧美亚洲视频在线观看| 亚洲精品中文字幕有码专区| 久久久久99| 国产欧美精品一区二区三区介绍| 日韩亚洲欧美成人| 免播放器亚洲| 香蕉成人伊视频在线观看| 欧美日韩国产在线| 亚洲国产一区在线观看| 久久人人超碰| 午夜国产不卡在线观看视频| 欧美手机在线| 一区二区三区产品免费精品久久75 | 久久久久久香蕉网| 国产伦精品一区二区三区四区免费| 99精品免费| 欧美激情偷拍| 久久久久久久久久久一区| 国产女主播在线一区二区| 亚洲中字在线| 中文精品视频| 国产精品成人av性教育| 宅男在线国产精品| 亚洲激情六月丁香| 牛牛影视久久网| 亚洲国产精品国自产拍av秋霞| 久久综合九九| 久久夜色精品| 亚洲黄一区二区三区| 欧美~级网站不卡| 久久在线播放| 亚洲日本精品国产第一区| 欧美国产精品劲爆| 欧美a级片网| 日韩视频一区二区三区在线播放免费观看 | 亚洲欧美国产制服动漫| 国产精品久久综合| 欧美一区国产一区| 欧美专区日韩视频| 亚洲电影免费| 亚洲二区三区四区|