This is the mail archive of the cygwin@cygwin.com 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]

inetd: works with gcc-compiled program, not msvc


I am running inetutils-1.3.2-16 and cygwin-1.3.6-6 on Windows 2000.

I added a service to /etc/inetd.conf like this:
   foo stream tcp nowait root c:/path/prog prog

prog.exe just printf's and exits.  If prog is compiled in gcc it works,
"telnet hostname foo" prints the output of the program.  Buf if prog is
compiled with msvc, no output appears (of course I checked that the program
produces output when run at a cygwin prompt).  The same thing happens if I
use cygwin's telnet or if I telnet from a linux.

I thought maybe the problem was with cygwin's dup or exec, so I wrote a
little test

  int fd;

  if ( (fd = open(outfile, O_CREAT | O_WRONLY | O_TRUNC , 0666)) < 0) {
    printf("cannot open %s for output, %s\n", outfile, strerror(errno));
    exit(1);
  }
  dup2(fd, 0);
  close(fd);
  dup2(0, 1);
  dup2(0, 1);
  execl(program, program, 0);

But this test works with both the gcc and msvc compilations (the output
winds up in the file).

I also tried, but nothing changed
- use execv (as does inted)
- have the program use write() instead of printf()

While some may find this to be a good way to encourage people to use gcc
rather than msvc, and I'd rather do just that, unfortunately I need to run
a service written by someone else in msvc.

Any ideas?

BTW, I found that I had to add my service to Windows' copy of services
(located in c:/windows/system32/drivers/etc), adding it to
c:/cygwin/etc/services didn't work, inted would fail when it did a
getservbyname on the name of the service (and so would a test program I
wrote that just calls getservbyname).  Is this supposed to happen?

Also, on Linux, when I'm adding a service to just test something, I often
skip adding an entry to /etc/services and just put the number of the
service in /etc/inetd.conf - this works there but not in cygwin.  Was this
by design?



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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