polyglot twice in winboard

Discussions about Winboard/Xboard. News about engines or programs to use with these GUIs (e.g. tournament managers or adapters) belong in this sub forum.

Moderator: Andres Valverde

polyglot twice in winboard

Postby Peter Fendrich » 29 Jul 2005, 00:17

When I start polyglot under winboard, I can see two polyglot instances in taskmanager. When I quit winboard the two polyglot tasks are still in live. A new winbord with polyglot will prodece two new instances av polyglot.
Is this a known issue? It must be a bug?
My own program is stopped and normally finished when winboard gets the quit.
/Peter
User avatar
Peter Fendrich
 
Posts: 193
Joined: 26 Sep 2004, 20:28
Location: Sweden

Re: polyglot twice in winboard

Postby Peter Fendrich » 29 Jul 2005, 01:20

The problem when quitting winboard is solved - it was my fault.

Still there are two instances of polyglot in the task manager but both disappear when I quit. I can delete one of the processes and continue to use polyglot under winboard. What does that second polyglot process do?
/Peter
User avatar
Peter Fendrich
 
Posts: 193
Joined: 26 Sep 2004, 20:28
Location: Sweden

Re: polyglot twice in winboard

Postby Roger Brown » 29 Jul 2005, 01:25

Peter Fendrich wrote:The problem when quitting winboard is solved - it was my fault.

Still there are two instances of polyglot in the task manager but both disappear when I quit. I can delete one of the processes and continue to use polyglot under winboard. What does that second polyglot process do?
/Peter



Hello Peter,

The two instances are fine. I remember Fabien attempting to explain it to me. I was hopelessly lost of course.

It has something to do with the cygwin dll used to get it to work under windows......

Then again I could be wrong.

:shock:

Later.
Roger Brown
 
Posts: 346
Joined: 24 Sep 2004, 12:31

Re: polyglot twice in winboard

Postby Dann Corbit » 29 Jul 2005, 02:28

Polyglot is a forking server, which is why you see multiple instances.
That is also why it needs the cygwin dll
Dann Corbit
 

Re: polyglot twice in winboard

Postby Roger Brown » 29 Jul 2005, 03:25

Dann Corbit wrote:Polyglot is a forking server, which is why you see multiple instances.
That is also why it needs the cygwin dll





Hello Dann,

See, I knew I was hopelessly wrong!

Damn, I am good!

:wink:

Not everyone knows their limitations the way I know mine.

Sigh.

Later.
Roger Brown
 
Posts: 346
Joined: 24 Sep 2004, 12:31

Re: polyglot twice in winboard

Postby Peter Fendrich » 29 Jul 2005, 19:50

Dann Corbit wrote:Polyglot is a forking server, which is why you see multiple instances.
That is also why it needs the cygwin dll


Yes Dann,
but I went suspicious when one of the instances could be killed and polyglot still worked. That's also why I asked what that process is doing.

/Peter
User avatar
Peter Fendrich
 
Posts: 193
Joined: 26 Sep 2004, 20:28
Location: Sweden

Re: polyglot twice in winboard

Postby Dann Corbit » 29 Jul 2005, 22:15

Code: Select all
// engine_open()

void engine_open(engine_t * engine) {

   const char * dir, * command;
   char string[StringSize];
   int argc;
   char * ptr;
   char * argv[256];
   int from_engine[2], to_engine[2];
   pid_t pid;

   ASSERT(engine!=NULL);

   // init

   dir = option_get_string("EngineDir");
   my_log("POLYGLOT Dir \"%s\"\n",dir);

   command = option_get_string("EngineCommand");
   my_log("POLYGLOT Command \"%s\"\n",command);

   // parse the command line and create the argument list

   if (strlen(command) >= StringSize) my_fatal("engine_open(): buffer overflow\n");
   strcpy(string,command);

   argc = 0;

   for (ptr = strtok(string," "); ptr != NULL; ptr = strtok(NULL," ")) {
      argv[argc++] = ptr;
   }

   argv[argc] = NULL;

   // create the pipes

   if (pipe(from_engine) == -1) {
      my_fatal("engine_open(): pipe(): %s\n",strerror(errno));
   }

   if (pipe(to_engine) == -1) {
      my_fatal("engine_open(): pipe(): %s\n",strerror(errno));
   }

   // create the child process

   pid = fork();

   if (pid == -1) {

      my_fatal("engine_open(): fork(): %s\n",strerror(errno));

   } else if (pid == 0) {

      // child = engine

      // close unused pipe descriptors to avoid deadlocks

      my_close(from_engine[0]);
      my_close(to_engine[1]);

      // attach the pipe to standard input

      my_dup2(to_engine[0],STDIN_FILENO);
      my_close(to_engine[0]);

      // attach the pipe to standard output

      my_dup2(from_engine[1],STDOUT_FILENO);
      my_close(from_engine[1]);

      // attach standard error to standard output

      my_dup2(STDOUT_FILENO,STDERR_FILENO);

      // set a low priority

      if (UseNice) nice(+20);

      // change the current directory

      if (dir[0] != '\0' && chdir(dir) == -1) {
         my_fatal("engine_open(): chdir(): %s\n",strerror(errno));
      }

      // launch the new executable file

      execvp(argv[0],&argv[0]);

      // execvp() only returns when an error has occured

      my_fatal("engine_open(): execvp(): %s\n",strerror(errno));

   } else { // pid > 0

      ASSERT(pid>0);

      // parent = PolyGlot

      // close unused pipe descriptors to avoid deadlocks

      my_close(from_engine[1]);
      my_close(to_engine[0]);

      // fill in the engine struct

      engine->io->in_fd = from_engine[0];
      engine->io->out_fd = to_engine[1];
      engine->io->name = "ENGINE";

      io_init(engine->io);
   }
}



And then in main, we find this:

Code: Select all
int main(int argc, char * argv[]) {

   int s;
   board_t board[1];

   // init

   if (UseMegaHack) {
      for (s = 1; s < 64; s++) signal(s,&sig_handler);
   } else {
      signal(SIGINT,SIG_IGN);
      signal(SIGTERM,SIG_IGN);
   }

   util_init();
   printf("PolyGlot %s by Fabien Letouzey\n",Version);

   option_init();

   square_init();
   piece_init();
   attack_init();
   move_do_init();

   hash_init();

   my_random_init();

   // read options

   if (argc >= 2) option_set("OptionFile",argv[1]);

   parse_option(); // HACK: also launches the engine
Dann Corbit
 

Re: polyglot twice in winboard

Postby Hartmut Woldeit » 30 Jul 2005, 01:24

@Dann

very interesting posting ...

May all your Christmases be white!

Hartmut
Hartmut Woldeit
 
Posts: 17
Joined: 26 Sep 2004, 23:16

Re: polyglot twice in winboard

Postby Fabien Letouzey » 30 Jul 2005, 08:36

Peter Fendrich wrote:but I went suspicious when one of the instances could be killed and polyglot still worked. That's also why I asked what that process is doing.


Hi Peter,

It's a dummy process that's not needed anymore. I suppose there must be a reason why the DLL can't get rid of it on Windows ...

Fabien.
Fabien Letouzey
 
Posts: 110
Joined: 03 Dec 2004, 10:17
Location: France

Re: polyglot twice in winboard

Postby Ross Boyd » 11 Aug 2005, 07:00

Dann Corbit wrote:Polyglot is a forking server...


Geez Dann, there's no need to swear about it....

:D
User avatar
Ross Boyd
 
Posts: 83
Joined: 26 Sep 2004, 23:07
Location: Wollongong, Australia


Return to Winboard and related Topics

Who is online

Users browsing this forum: No registered users and 39 guests