Game Development Community

RC2 - Linux - Platform::restartInstance

by Rodney Rindels - Torqued · in Torque Game Builder · 06/14/2006 (12:07 am) · 5 replies

It seems as is restartInstance was implemented in a platformWin32 only way, but the reference to it sits in games/main.cc line 373 without regard to platform.

This of course breaks the linker since there is no reference to Platform::restartInstance for linux (* could be the same for Mac, I dont have one handy to test with).

Of course commenting out the one call, fixes the compile on linux, and removes the restartInstance functionality, but I believe that was implemented for a reason for switching projects , that might be of use to include in the other platforms, if it hasn't been hacked in yet :-)

#1
06/15/2006 (1:21 am)
Rodney,

This has in fact been implemented in both the Windows and Mac builds. A community submitted Linux implementation would be well received!

Cheers,
-Justin
#2
06/15/2006 (3:30 am)
Ok tomorrow I'll take a crack at this and run it past the t2d linux group. It seems as if your using a windows createprocess to relaunch yourself and then killing off the parent if I/O has stopped.

In linux its similar, but you have issues on linux with not keeping the actual process name of the launched original process because its not considered safe to do so, but that was already partially broken at least by picking up argv[0] in main() which is normally only done as far as I know in daemon type applications, but our case is fine since were going to want to want to figure out who we are an just exec ourselves. and kill off the parent. I'll investiage it more and come up with something , (I figured the linux community would fix this, but wanted to get it noted somewhere) and it might be helpful if you could share your MAC solution to this , since it could be actually identical in linux....
#3
06/15/2006 (3:47 pm)
Ok this works for me, and I slammed open and closed a project a few hundred times..

Maybe somebody else might want to tell me if I'm doing anything "Torque" wrong ....


//-----------------------------------------------------------------------------
void Platform::restartInstance()
{

        if (Game->isRunning() )
        {
               //Con::errorf( "Error restarting Instance. Game is Still running!");
                return;
        }

        char cmd[2048];
        sprintf(cmd, "%s &", x86UNIXState->getExePathName());
        system(cmd);
        exit(0);
}

I'll email this also to you justin..
#4
06/16/2006 (10:30 am)
@Justin: You getting my emails? Haven't heard anything in a while.
#5
06/16/2006 (10:32 am)
Also David has some good changes to this . His should be the authoritative source of course...