This is the mail archive of the cygwin-patches mailing list for the Cygwin 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: [PATCH] Fix cygrunsrv invocation in cygcheck


On Tue, 16 Aug 2005, Brian Dessent wrote:

> Igor Pechtchanski wrote:
>
> > As mentioned in <http://cygwin.com/ml/cygwin/2005-08/msg00724.html>, I
> > noticed something strange in the "cygcheck -s" output:
>
> This fix was part of my patch from June in
> <http://cygwin.com/ml/cygwin-patches/2005-q2/msg00138.html> but since it
> was grouped with the unrelated cygcheck -p code, it kind of got lost on
> the floor.

That's why it's better to send many micro-patches instead of one monster
patch...  :-)
Hmm, you should ping the list about it, then -- it's been what, two months?

> > why not simply run "cygrunsrv --list --verbose" in verbose mode, instead
> > of actually going through one iteration of the loop?  Simply to reuse the
> > "copy output" code?  Brian?
>
> The reason I did it that way is because if I had run "cygrunsrv --list
> --verbose" initially, then it would be necessary to parse the output and
> extract out the service names, since it has to run "cygrunsrv --query"
> for each individual service in the case of (!verbose).  By running just
> "cygrunsrv --list" you get a simple listing of service names with no
> parsing necessary, and I did not want to make cygcheck depend on the
> particular output format of cygrunsrv.
>
> This is awkward I admit because there is no cygrunsrv option that does
> the equivalent of "--query" for all services.  So to support both
> verbose and non-verbose listing of all services, you either have to run
> "--list --verbose" and then filter out the fields that should not be in
> the verbose output, or you have to run "--query" individually for each
> service.  And I did not want to mess about with text parsing and
> filtering so I decided to take the easy route and just invoke cygrunsrv
> a few extra times.

I actually meant something like

if (verbose) {
  f = popen("cygrunsrv --list --verbose");
  copy_output(f, stdout);
} else {
  f = popen("cygrunsrv --list");
  buf[fread(buf, 1, sizeof(buf)-1, f)] = '\0';
  pclose(f);
  for (char *srv = strtok(buf), "\n"); srv; srv = strtok(NULL, "\n")) {
    f = popen("cygrunsrv --query "+srv);
    copy_output(f, stdout);
  }
}

	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

If there's any real truth it's that the entire multidimensional infinity
of the Universe is almost certainly being run by a bunch of maniacs. /DA


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