delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/12/16/08:17:02

From: creative1 AT bigfoot DOT com (creative1)
Subject: b20.1 fork bug or please HELP!!!
16 Dec 1998 08:17:02 -0800 :
Message-ID: <36773534.957E9BF8.cygnus.gnu-win32@bigfoot.com>
Reply-To: creative1 AT bigfoot DOT com
Mime-Version: 1.0
To: gnu-win32 AT cygnus DOT com

Hi there!

I compiled kaosbot (similar to an eggdrop program), you can get it from
www.unionlatina.org/kaosbot/kaosbot1b7.3.tgz

I adapted it perfectly to cygwin, just run it and it will compile out of
the box.

But I have a problem, I can't get the program to launch on the
background,
i have made everything i can about it, but i still have that problem. It

works perfect on several unixes systems, but on cygwin it just crash
with a kernel error, please HEEEELPPPP

The code just in case i am missing something, on main.c
   /* move into background? */
   if (backgrd) {
      xx = fork();
      if (xx == -1)
  fatal("CANNOT FORK PROCESS.", 0);
      if (xx != 0) {
         FILE *fp;
         /* need to attempt to write pid now, not later */
         unlink(pid_file);
         fp = fopen(pid_file, "w");
         if (fp != NULL) {
            fprintf(fp, "%u\n", xx);
            if (fflush(fp)) {
               /* kill bot incase a botchk is run from crond */
               printf("* Warning!  Could not write %s file!\n",
pid_file);
               printf("  Try freeing some disk space\n");
               fclose(fp);
               unlink(pid_file);
               exit(1);
            }
            fclose(fp);
         } else
            printf("* Warning!  Could not write %s file!\n", pid_file);
         printf("Launched into the background  (pid: %d)\n\n", xx);
#if HAVE_SETPGID
  setpgid(xx, xx);
#endif
  exit(0);
      }
   }
   use_stderr = 0;  /* stop writing to stderr now */
   xx = getpid();
   if ((xx != 0) && (!backgrd)) {
      FILE *fp;
      /* write pid to file */
      unlink(pid_file);
      fp = fopen(pid_file, "w");
      if (fp != NULL) {
  fprintf(fp, "%u\n", xx);
         if (fflush(fp)) {
      /* let the bot live since this doesn't appear to be a botchk */
            printf("* Warning!  Could not write %s file!\n", pid_file);
            fclose(fp);
            unlink(pid_file);
         }
  fclose(fp);
      } else
  printf("* Warning!  Could not write %s file!\n", pid_file);
   }
   if (backgrd) {
      /* ok, try to disassociate from controlling terminal */
      /* (finger cross) */
#if HAVE_SETPGID
      setpgid(0, 0);
#endif
      /* close out stdin/out/err */
      freopen("/dev/null", "r", stdin);
      freopen("/dev/null", "w", stdout);
      freopen("/dev/null", "w", stderr);
      /* tcl wants those file handles kept open */
/*    close(0); close(1); close(2);  */
   }

I'll be very grateful if someone point me out what is the problem, or if
it is
a cygwin problem, or how to fix it...

Joaquin Grech


--
---------------------------------------------------------------
!     C r e a t i v i t y     M u s t    S u r v i v e        !
---------------------------------------------------------------
!  Fido: 2:341/19.67                 Euronet: 25:928/100.67   !
!  Internet: creative1 AT bigfoot DOT com                            !
!  Http://surf.to/creative                  Ya me direis :)   !
---------------------------------------------------------------


-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019