Yes! That was my bad. I haven't fork()ed in a while. At the end of the fork exit(0) gracefully.
> -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Valnir > Sent: Tuesday, March 08, 2005 11:36 AM > To: [email protected] > Subject: Re: Pausing a Loop. > > Ok.. using the "process_output" call in combination with the > "fork" option, I was able to do what I wanted.. I ran across > one little issue though. For some reason, the forked > processes aren't terminating. Is there something I'm missing? > Do you have to kill the fork afterwards? > > - Valnir > > ----- Original Message ----- > From: "Jason Gauthier" <[EMAIL PROTECTED]> > To: "Valnir" <[EMAIL PROTECTED]> > Cc: <[email protected]> > Sent: Tuesday, March 08, 2005 10:59 AM > Subject: RE: Pausing a Loop. > > > It's not a lack of C concepts, but the design of ROM. > > ROM has 1 main loop. It processes all input and output in that one > loop. > If you tore up that code, functionized it, you could > theoretically call > it whenever you wanted to check for player input or process player > output. (acutally player output is easy, you can call > process_output() > at any time) But processing input wouldn't be grand. > > I wouldn't go that route, because it's a hack at that point. > Unless you overhauled it, but there's not much gain in my opinion, > others may differ. > > > > > > > -----Original Message----- > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On > Behalf Of Valnir > > Sent: Tuesday, March 08, 2005 10:48 AM > > To: [email protected] > > Subject: Re: Pausing a Loop. > > > > It does help, and it's a very interesting concept. I am not > > sure it's 100% what I'm after though. > > > > What I am really after is the C equivalent of the VB DoEvents > > function. I want it to stay in the same process, pause the > > loop, take care of any requests, output, etc, and then > > continue the loop, pause, so on and so forth. > > > > (I did try the fork, and it seems to work, but it doesn't do > > exactly what I > > want) > > > > - Valnir > > > > ----- Original Message ----- > > From: "Jason Gauthier" <[EMAIL PROTECTED]> > > To: "Valnir" <[EMAIL PROTECTED]>; <[email protected]> > > Sent: Tuesday, March 08, 2005 10:07 AM > > Subject: RE: Pausing a Loop. > > > > > > Sure. > > > > If you've had no experience with threads then let's not go > that route > > for now. Threads are great, but I wouldn't want to stick > you in that > > mess blind. > > > > fork() is easy, but a little more "expensive" than threads. > Overall, I > > think a basic fork() should do the job. > > > > fork() is a C function that creates a copy of your process, > > and executes > > the specified code in copy. > > It returns a value you can use to identify the child from > the parent. > > > > If you have unix handy "man fork". > > > > This is an example > > > > process_players > > { > > int f; > > > > f = fork(); > > > > /* something bad happened */ > > if (f==-1) { > > // fork failed, tell your command issuer > > return; > > } > > > > if (!f) { > > // Everything here is where you want to put your time > > consuming code > > } > > } > > > > > > Couple things to note. > > The command issuer will not be waiting for the command to > > finish either. > > (You could force a wait if you want) > > Thus, if the command issuer executes this command in rapid > > succession it > > will hurt your box. > > > > Secondly, if you change any variables, they will be reflected in the > > parent when the child exits. > > > > Hope that helps. > > > > Jason > > > > > > > -----Original Message----- > > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On > > Behalf Of Valnir > > > Sent: Tuesday, March 08, 2005 9:55 AM > > > To: [email protected] > > > Subject: Re: Pausing a Loop. > > > > > > Ok... I have to say this is something I have never tried. A > > > little help or direction?? > > > > > > - Valnir > > > > > > ----- Original Message ----- > > > From: "Jason Gauthier" <[EMAIL PROTECTED]> > > > To: "Valnir" <[EMAIL PROTECTED]> > > > Cc: <[email protected]> > > > Sent: Tuesday, March 08, 2005 9:53 AM > > > Subject: RE: Pausing a Loop. > > > > > > > > > It was perfectly clear. There is no function to tell the > mud to "go > > > about your business". > > > > > > You need to either thread the entire function, or call > > fork() and run > > > this as a child process. > > > > > > Jason > > > > > > > -----Original Message----- > > > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On > > > Behalf Of Valnir > > > > Sent: Tuesday, March 08, 2005 9:50 AM > > > > To: [email protected] > > > > Subject: Re: Pausing a Loop. > > > > > > > > Maybe it would be clearer if I posted the function, so > here it is. > > > > > > > > void do_alts( CHAR_DATA *ch, char *argument ) { > > > > DIR *player_dir; > > > > struct dirent *players; > > > > CHAR_DATA *victim, *lch; > > > > char buf[MSL]; > > > > char output[MSL] = { '\0' }; > > > > int count = 0; > > > > > > > > if ( ( victim = get_char_online(argument) ) == NULL ) > > > > { > > > > if ( ( victim = get_char_offline(argument) ) == NULL ) > > > > { > > > > send_to_char("The character was not found to > > > > compare against.\n\r", ch); > > > > return; > > > > } > > > > } > > > > > > > > send_to_char( "^fPlease wait while we scan for alts. " > > > > "This process can take a minute...^0\n\r\n\r", ch ); > > > > > > > > send_to_char( "Searching pfiles", ch ); > > > > > > > > if ( ( player_dir = opendir(PLAYER_DIR) ) != NULL ) > > > > { > > > > while ( ( players = readdir(player_dir) ) != NULL ) > > > > { > > > > send_to_char( ".", ch ); > > > > > > > > if ( !str_cmp( players->d_name, "." ) > > > > || !str_cmp( players->d_name, ".." ) ) > > > > continue; > > > > > > > > if ( !str_cmp( players->d_name, victim->name ) ) > > > > continue; > > > > > > > > if ( ( lch = get_char_online(players->d_name) ) > > > == NULL ) > > > > lch = get_char_offline(players->d_name); > > > > > > > > if ( !str_cmp( victim->pcdata->host, > > > lch->pcdata->host ) ) > > > > { > > > > if ( !IS_SET( lch->pen, PEN_SNOOP_PROOF ) > > > > && !IS_IMMORTAL(lch) ) > > > > { > > > > sprintf( buf, "^$%2d^!) > ^$%s^0\n\r", ++count, > > > > lch->name ); > > > > strcat( output, buf ); > > > > } > > > > } > > > > > > > > unload_char(lch); > > > > } > > > > > > > > send_to_char( "\n\r\n\r", ch ); > > > > if ( count > 0 ) > > > > { > > > > sprintf( buf, "Below is a list of all characters > > > > connecting" > > > > " from host:\n\r\t%s\n\r\n\r", > > > victim->pcdata->host ); > > > > send_to_char( buf, ch ); > > > > > > > > send_to_char( output, ch ); > > > > } > > > > else > > > > send_to_char( "No matches found.\n\r", ch ); > > > > } > > > > else > > > > bug( "Could not open PLAYER_DIR!", 0 ); > > > > > > > > closedir(player_dir); > > > > unload_char(victim); > > > > return; > > > > } > > > > > > > > > > > > > > > > ----- Original Message ----- > > > > From: "Jason Gauthier" <[EMAIL PROTECTED]> > > > > To: "Valnir" <[EMAIL PROTECTED]> > > > > Cc: <[email protected]> > > > > Sent: Tuesday, March 08, 2005 9:44 AM > > > > Subject: RE: Pausing a Loop. > > > > > > > > > > > > Your best bet would be to run that in a separate thread. > > > > (or fork(), if you don't want to mess with threading) > > > > > > > > > > > > > -----Original Message----- > > > > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On > > > > Behalf Of Valnir > > > > > Sent: Tuesday, March 08, 2005 9:41 AM > > > > > To: [email protected] > > > > > Subject: Pausing a Loop. > > > > > > > > > > Ok, I created a nice little function so that my immortals can > > > > > find the alts of the any character on the game by comparing > > > > > against the host listed in the pfiles. The problem is that > > > > > since it loads and unloads every pfile, it takes a minute to > > > > > run, and since it does that, it literally pauses the game > > > > > while it's running. What command can I add into the loop to > > > > > tell it to pick up other process requests, etc? I'm sure > > > > > there is one, and I just don't know what it is. > > > > > > > > > > Thanks in advance! > > > > > - Valnir > > > > > > > > > > -- > > > > > ROM mailing list > > > > > [email protected] > > > > > http://www.rom.org/cgi-bin/mailman/listinfo/rom > > > > > > > > > > > > > -- > > > > ROM mailing list > > > > [email protected] > > > > http://www.rom.org/cgi-bin/mailman/listinfo/rom > > > > > > > > > > -- > > > ROM mailing list > > > [email protected] > > > http://www.rom.org/cgi-bin/mailman/listinfo/rom > > > > > > > -- > > ROM mailing list > > [email protected] > > http://www.rom.org/cgi-bin/mailman/listinfo/rom > > > > -- > ROM mailing list > [email protected] > http://www.rom.org/cgi-bin/mailman/listinfo/rom >

