• 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: Process ID of Xserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Process ID of Xserver


  • Subject: Re: Process ID of Xserver
  • From: robert delius royar <email@hidden>
  • Date: Fri, 1 Oct 2004 14:25:00 -0400 (EDT)
  • Organization: An Apple OS X end user
  • Priority: NEW

Fri, 1 Oct 2004 (09:58 -0700 UTC) Kevin Geiss wrote:

well, 'ps auxwwj' will list all processes along with their parent pids. the X server should be called 'X11', with the full path:

/Applications/Utilities/X11.app/Contents/MacOS/X11

oddly enough, on my system there were two of them, one was the parent of the other.

USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME PPID PGID SESS JOBC COMMAND
kevin 19006 9.7 2.8 110296 18372 ?? S 9:48AM 0:10.82 19005 16043 172e084 0 /Applications/Utilities/X11.app/Contents/MacOS/X11 -psn_0_13500417 :0
kevin 19005 0.0 0.1 28760 792 ?? S 9:48AM 0:00.03 16043 16043 172e084 0 /Applications/Utilities/X11.app/Contents/MacOS/X11 -psn_0_13500417

Yes, I use this technique: X11PID=`ps -axw | grep X11.app | grep " :0" | grep -v grep | cut -c 1-5 | head -1` export X11PID

Only the X11 with the $DISPLAY parameter has a PID that works with GetProcessForPID(). If I happen to use its parent's PID, the PSN object comes back as 00000000_00000000.

Is the PID available to clients of the server with a simpel getppid() type call? Currently my shell script sets the X11PID which I query with getenv() from C. Then I use the PID to get the PSN for SetFrontProcess(&PSN). It works, but it seems subject to potential failure, for example if the $DISPLAY is different.

I also tried X11PSN=`ps -auxwwj | grep "/Applications/Utilities/X11.app/Contents/MacOS/X11 -psn_" | cut -f 3 -d "_" | head -1`
export X11PSN
which works fine when I try it in bash, but which does not work when run from the desktop. The X11PID example does work from the desktop.



On Oct 1, 2004, at 8:17 AM, robert delius royar wrote:

Is there a reliable way to get the PID of the Xserver which owns the root window? Either a shell method or one which runs within a child process would be OK. I know I can get the parent's PID in a program, but I don't think I can be sure that that will always be the server. For example the parent might be an XTerm.

With the PID, I can get the server app's serial number which I can then use to talk to some of the event manager routines.


-- Dr. Robert Delius Royar Associate Professor of English Morehead State University Morehead, Kentucky _______________________________________________ Do not post admin requests to the list. They will be ignored. X11-users mailing list (email@hidden) This email sent to email@hidden
References: 
 >Process ID of Xserver (From: robert delius royar <email@hidden>)
 >Re: Process ID of Xserver (From: Kevin Geiss <email@hidden>)

  • Prev by Date: Re: x11 fullscreen kills command-tab?
  • Next by Date: Re: Process ID of Xserver
  • Previous by thread: Re: Process ID of Xserver
  • Next by thread: Re: Process ID of Xserver
  • Index(es):
    • Date
    • Thread