• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Launching X11 client with NSTask
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Launching X11 client with NSTask


  • Subject: Re: Launching X11 client with NSTask
  • From: Tom Harrington <email@hidden>
  • Date: Thu, 3 Jun 2004 12:45:36 -0600

On May 27, 2004, at 12:42 PM, Drew McCormack wrote:
I am testing launching of X11 programs from inside Cocoa, but I can't
get it to work. I get this error:

Xlib: connection to "localhost:0.0" refused by server
Xlib: No protocol specified

Error: Can't open display: localhost:0.0


This is the code:

NSTask *task = [[[NSTask alloc] init] autorelease];
[task setLaunchPath:@"/usr/X11R6/bin/xeyes"];
[task setEnvironment:
[NSDictionary dictionaryWithObjectsAndKeys:
@"localhost:0.0", @"DISPLAY",
nil]];
[task launch];

Can anyone with more understanding of X11 than me tell me what I am
missing? (Note the xeyes works fine from the command line in either an
xterm or an apple terminal.)

Two things:

1. -[NSTask setEnvironment] writes the complete environment for the NSTask, i.e., if you use this you have to specify all environment vars for the task.

2. In order to run an X11 app like this, you need to have HOME set, and you're not doing that.

You need to be sure that HOME is set for the subprocess.

--
Tom Harrington
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: Resizing issue
  • Next by Date: Re: Debugging under 10.2
  • Previous by thread: Resizing issue
  • Next by thread: [ANN] Smultron - an open source text editor
  • Index(es):
    • Date
    • Thread