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

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一区二区三区网页| 免费成人黄色| 91久久综合| 亚洲精品欧美在线| 欧美日韩在线不卡| 午夜精品国产精品大乳美女| 亚洲综合色在线| 国产精品一区二区三区四区五区| 国产一区在线播放| 久久夜色精品国产| 另类国产ts人妖高潮视频| 91久久亚洲| 夜夜嗨av一区二区三区免费区| 国产精品国产亚洲精品看不卡15| 亚洲欧美怡红院| 欧美一区二区高清在线观看| 1024亚洲| 一区二区三区精密机械公司| 国产一区二区你懂的| 欧美成人黑人xx视频免费观看| 欧美高清视频一区| 欧美一级网站| 欧美成年人网站| 午夜精品视频| 鲁鲁狠狠狠7777一区二区| 亚洲视频精品| 久久精品色图| 亚洲一区二区三区影院| 久久久爽爽爽美女图片| 亚洲午夜久久久久久久久电影院 | 亚洲经典一区| 中文av一区特黄| 亚洲国产成人在线| 亚洲天堂av图片| 亚洲激情专区| 亚洲伊人色欲综合网| 亚洲国产精品成人va在线观看| 亚洲一区二区精品视频| 亚洲国产专区校园欧美| 香蕉免费一区二区三区在线观看| 亚洲精品美女在线观看| 欧美在线高清| 亚洲亚洲精品在线观看 | 一区免费在线| 亚洲网站啪啪| 一区二区免费看| 亚洲日产国产精品| 国产亚洲激情| 中文日韩在线| 亚洲美洲欧洲综合国产一区| 久久久久国产精品一区| 欧美一区在线视频| 欧美三级韩国三级日本三斤| 欧美大片一区二区三区| 狠狠入ady亚洲精品| 亚洲自拍偷拍麻豆| 亚洲一区二区三| 欧美激情亚洲精品| 欧美激情一区二区三区成人| 国产一区自拍视频| 欧美在线免费观看| 久久成人在线| 国产无一区二区| 亚洲欧美另类久久久精品2019| 亚洲午夜性刺激影院| 欧美激情四色 | 久久久久国产一区二区三区四区| 国产精品入口66mio| 亚洲视频一区二区在线观看| 亚洲天堂av高清| 欧美日韩三区四区| 亚洲伦理久久| 亚洲一区二区三区免费观看| 欧美性做爰猛烈叫床潮| 一本一本大道香蕉久在线精品| 亚洲视频播放| 欧美性猛交xxxx乱大交退制版 | 欧美激情按摩在线| 亚洲国产精品久久久久秋霞影院 | 久久综合综合久久综合| 免费在线欧美黄色| 亚洲日本中文字幕区| 欧美日韩国产区一| 亚洲尤物在线| 麻豆久久久9性大片| 欧美精品国产| 中文国产成人精品久久一| 欧美在线视频一区| 1024精品一区二区三区| 欧美国产成人精品| 亚洲在线视频| 女同性一区二区三区人了人一| 亚洲伦理在线观看| 国产精品日韩精品欧美精品| 久久精品亚洲一区二区| 亚洲激情小视频| 欧美一级黄色网| 亚洲黄色毛片| 国产精品一区二区三区四区 | 中国成人在线视频| 麻豆精品在线观看| 亚洲宅男天堂在线观看无病毒| 国产在线播放一区二区三区| 欧美高清视频一区二区| 亚洲欧美文学| 亚洲日本在线视频观看| 久久理论片午夜琪琪电影网| 在线亚洲美日韩| 伊人久久亚洲影院| 国产精品日韩久久久久| 麻豆成人精品| 欧美一级大片在线观看| 亚洲靠逼com| 免费久久99精品国产| 销魂美女一区二区三区视频在线| 亚洲国产小视频在线观看| 国产精品一区二区久久国产| 欧美二区视频| 久久久av水蜜桃| 亚洲一区二区在线观看视频| 亚洲日本一区二区三区| 欧美a级在线| 久久久精品日韩欧美| 亚洲专区在线| 在线中文字幕日韩| 日韩午夜在线视频| 91久久综合| 在线看日韩欧美| 国产亚洲毛片在线| 国产农村妇女精品| 国产精品你懂得| 欧美视频免费在线| 欧美日韩三区四区| 欧美日韩成人在线播放| 欧美激情欧美狂野欧美精品| 老司机免费视频一区二区| 久久久久欧美精品| 久久国产精品一区二区三区四区| 午夜激情综合网| 亚洲制服丝袜在线| 午夜精品电影| 性久久久久久久久| 新狼窝色av性久久久久久| 香蕉av777xxx色综合一区| 午夜在线成人av| 亚洲综合精品一区二区| 午夜精品久久久久久久蜜桃app| 亚洲视频观看| 亚洲欧美日韩国产| 欧美一区高清| 久久久久久夜| 免费观看在线综合| 欧美日本在线观看| 亚洲成人在线视频播放| 免费影视亚洲| 欧美激情一区二区三区高清视频| 亚洲风情亚aⅴ在线发布| 亚洲黄色片网站| 一本一本久久a久久精品综合麻豆| 亚洲网站在线| 欧美在线免费看| 美日韩精品免费| 欧美日韩一区二区视频在线观看| 欧美日韩在线播放三区| 国产美女高潮久久白浆| 在线免费观看日本一区| 日韩天堂在线视频| 午夜精品一区二区三区在线| 久久美女艺术照精彩视频福利播放| 免费亚洲网站| 亚洲精品免费观看| 校园春色国产精品| 美女精品在线观看| 国产精品国产三级国产专播精品人| 国产在线拍偷自揄拍精品| 亚洲区一区二| 亚洲欧美在线另类| 欧美国产一区二区三区激情无套| 日韩系列在线| 久久福利视频导航| 欧美日产一区二区三区在线观看| 国产精品久久久久久久久久久久久久 | 亚洲天堂av图片| 久久精品国产久精国产思思| 欧美日韩成人综合| 国内精品伊人久久久久av影院| 99视频精品在线| 久久婷婷蜜乳一本欲蜜臀| 亚洲三级影院| 久久精品一区中文字幕| 欧美大片一区二区三区| 国产精品你懂的在线| 亚洲国产美女精品久久久久∴| 欧美一级片一区| 亚洲国产高清高潮精品美女| 欧美伊久线香蕉线新在线| 欧美午夜www高清视频| 亚洲高清视频一区二区|