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

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

Find path of an application

Posted on 2012-04-18 22:44 RTY 閱讀(613) 評論(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| 宅男在线国产精品| 在线观看日韩av电影| 免费美女久久99| 亚洲人体大胆视频| 欧美freesex8一10精品| 亚洲天堂男人| 欧美一区二区精美| 亚洲国产成人久久综合一区| 亚洲精品久久久久中文字幕欢迎你| 欧美日韩精品免费看 | 麻豆国产精品va在线观看不卡 | 欧美三区视频| 久久免费精品视频| 欧美日韩免费| 久久久久一区二区| 欧美日韩亚洲激情| 久久综合一区二区三区| 欧美日韩免费观看一区| 久久久久五月天| 欧美日本高清一区| 久久美女艺术照精彩视频福利播放| 母乳一区在线观看| 久久精品99| 欧美日韩视频专区在线播放 | 99国产精品99久久久久久| 亚洲欧美成人精品| 亚洲精品一区在线观看| 欧美一激情一区二区三区| 亚洲精品视频在线看| 午夜精品免费在线| 在线一区亚洲| 久久综合一区二区三区| 久久国产精品久久久久久久久久 | 欧美一区二区成人| 亚洲午夜小视频| 牛牛影视久久网| 久久伊人亚洲| 国产精品一区二区三区四区| 亚洲三级视频| 91久久精品一区二区三区| 午夜精品美女久久久久av福利| 日韩亚洲成人av在线| 老司机一区二区| 久久久久.com| 国产视频一区在线| 亚洲精品视频在线看| 久久国产一区二区三区| 欧美一区=区| 国产精品二区二区三区| 亚洲美女精品成人在线视频| 亚洲高清一区二区三区| 免费成人高清视频| 欧美在线视频全部完| 欧美亚一区二区| 91久久精品网| 9久re热视频在线精品| 免费成人美女女| 亚洲国产天堂久久综合| **网站欧美大片在线观看| 久久久精彩视频| 蜜臀av性久久久久蜜臀aⅴ四虎 | 蘑菇福利视频一区播放| 国产日产精品一区二区三区四区的观看方式| 亚洲精品在线观看免费| 一区二区三区日韩精品视频| 欧美日韩国产黄| 亚洲精品在线电影| 午夜精品在线看| 国产在线不卡视频| 久久日韩精品| 亚洲国内自拍| 午夜综合激情| 国产色视频一区| 久久久精品久久久久| 欧美激情亚洲国产| 亚洲网友自拍| 国产欧美日韩亚洲一区二区三区| 午夜影院日韩| 欧美黄色视屏| 亚洲在线观看视频| 国产一区二区三区av电影| 久久久一区二区三区| 亚洲国产婷婷| 香蕉久久夜色| 亚洲成人在线网| 欧美另类99xxxxx| 亚洲欧美一区二区三区久久| 久热精品视频在线观看一区| 夜夜精品视频| 国产一区二区精品久久99| 欧美va天堂在线| 亚洲在线视频| 欧美大片免费| 久久成人国产| 中文国产一区| 国内一区二区三区在线视频| 欧美成年人视频网站欧美| 亚洲免费在线观看| 亚洲激情午夜| 久久婷婷av| 亚洲综合另类| 亚洲麻豆国产自偷在线| 国产日韩欧美在线看| 欧美精品播放| 久久亚洲综合网| 亚洲欧美日韩区| 一本色道久久综合亚洲二区三区| 开心色5月久久精品| 校园激情久久| 一本大道久久a久久精品综合| 国内免费精品永久在线视频| 欧美日韩亚洲一区二区三区四区| 久久久九九九九| 亚洲欧美日韩国产综合在线| 99ri日韩精品视频| 亚洲福利在线观看| 久久全球大尺度高清视频| 午夜亚洲激情| 亚洲一区二区欧美| 日韩亚洲欧美综合| 亚洲国产欧美在线人成| 激情亚洲一区二区三区四区| 国产嫩草一区二区三区在线观看| 欧美色综合天天久久综合精品| 欧美国产在线观看| 毛片一区二区| 欧美99久久| 麻豆精品精华液| 免费久久99精品国产自在现线| 欧美在线视频a| 欧美一区二区三区在线播放| 欧美一级大片在线免费观看| 亚洲一区二区在| 亚洲男人的天堂在线aⅴ视频| 亚洲午夜黄色| 午夜精品久久久久久久男人的天堂 | 亚洲第一在线综合在线| 欧美搞黄网站| 欧美国产精品| 亚洲国产精品视频| 亚洲精品久久久久久下一站 | 欧美伊人久久| 久久久久久亚洲综合影院红桃| 久久精品二区| 免费成人黄色| 欧美日韩免费观看一区三区| 欧美视频网址| 国产精品老牛| 国内精品一区二区三区| 在线观看成人av| 亚洲人成啪啪网站| 一区二区三区视频在线看| 亚洲视频在线视频| 欧美一级淫片aaaaaaa视频| 久久久久久久久蜜桃| 欧美激情2020午夜免费观看| 亚洲欧洲视频| 亚洲尤物精选| 狂野欧美一区| 欧美日韩一区在线播放| 国产视频亚洲| 日韩亚洲一区二区| 久久爱www.| 亚洲第一福利视频| 一区二区三区国产精品| 欧美一级一区| 欧美国产视频在线| 国产精品色网| 亚洲激情国产| 午夜欧美精品| 欧美成人午夜激情视频| 一本色道久久综合一区| 久久国产直播| 欧美日韩一区二区三区在线| 国内成人在线| 亚洲视频一区二区免费在线观看| 久久动漫亚洲| 亚洲精品字幕| 久久精品综合| 国产精品欧美在线| 亚洲欧洲精品一区二区三区| 欧美一区二区三区在线播放| 亚洲国产日韩欧美综合久久| 欧美资源在线观看| 国产精品久久亚洲7777| 亚洲黄色av一区| 久久久久**毛片大全| 亚洲一区二区免费在线| 欧美精品国产精品日韩精品| 在线日韩成人| 久久精品国产99| 亚洲一区二区av电影|