This is the mail archive of the cygwin-xfree@cygwin.com mailing list for the Cygwin XFree86 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Xwin shutdown command line option


Igor Pechtchanski wrote:

> This only works if the "sysvinit" package is installed, and it will
> kill *all* XWin processes, which is not what the OP wanted.

Of course you're right about what it does, but the OP did say:

> rather than using ps and checking for pid of XWin and using kill -9
> if u can provide that option from command line it would be gr8
                   ^^^^

I gave the command line to do just that.  I got the impression that
the OP wanted to have just one server running at a time.  If the
intention is to have more than one server running, and to kill the
one connected to a specific host, it should be possible to use a
script along the following lines:

----------- /usr/local/bin/killx -----------
#!/bin/bash

# Usage: killx.sh [remote_host]
# if remote_host is specified, kill all XWin processes connected to
# remote_host, otherwise, kill all XWin servers started without the
# -query option

remote_host="$1"

if [ -n "$remote_host" ]
then
  # only kill XWin where the command line
  # contains "-query <remote_host>"
  for i in `pidof /usr/X11R6/bin/XWin`
  do
    cat /proc/$i/cmdline |
      tr '\000' @ |
      grep -q "@-query@$remote_host@" &&
      echo kill -9 $i
  done
else
  # No remote host given, only kill XWin if the
  # command line does not contain -query
  for i in `pidof /usr/X11R6/bin/XWin`
  do
    cat /proc/$i/cmdline |
      tr '\000' @ |
      grep -qv "@-query@" &&
      echo kill -9 $i
  done
fi
--------------------------------------------

Note that this is not industrial-strength scripting, just a quick
hack.  I never use the -query option, so I can't verify that it works
as advertised.  To avoid damage, I've prefixed the kill commands with
echo so that you can verify that it would kill the right process.
Once you're satisfied that it would work for you, delete the echo.


HTH,

Phil Betts


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]