Linux popen() alternative
#11
I'm really curious if it works. You said the Windows version with "start " in front of the command string didn't work, so it would be weird if this would work.
Reply
Thanks given by:
#12
I'm sorry, I guess I brought in some confusion.
os.execute("start <cmd>") works on Windows and it doesn't wait for the <cmd> to terminate (only it allocates a new console for the <cmd> and sometimes that console stays after <cmd> finishes, I'll have to find out more details)
os.execute("<cmd> &") works and doesn't wait on Linux, at least on my RasPi.
Reply
Thanks given by:
#13
According to the people here you can use "start /b " to not open a command prompt on windows.

You could possible use:
local cmdline = -- the command string

if (cFile:GetPathSeparator() == "\\") then
   -- Windows
   cmdline = "start /b " .. cmdline -- Put "> nul" after this if you don't want to have the output in the current console.
else
   -- Other platforms
   cmdline = cmdline .. " &"
end

os.execute(cmdline)
Reply
Thanks given by:
#14
Not all non-windows platforms are *nix based. What about mac classic? or are you going to not support it?
Reply
Thanks given by:
#15
We should first have a function to detect on what platform we're at. Using cFile:GetPathSeparator is kinda hackish. I think Apple uses "open <cmdstring>".
Reply
Thanks given by:
#16
OS X does, I'm not sure what mac classic did. I can't find any documentation on creating a process, but what forum threads I have found indicate that it didn't have a shell to perform the command.
And even if it does work on mac classic I have the wikipedia list of path separators up to quote ever more obscure OSs where this would have problems. My next candidate is VMS.
Reply
Thanks given by:
#17
MCS doesn't compile for mac classic anyway, or does it?

STR, what should be the return values of that function? If we let it return an enum osWidows / osLinux / osOSX, there will soon be an OS that is not covered (not a problem, just add a new value), but also an OS that is a sub-descendant of one of the main ones with some tricky little difference, such as osRasPiLinux. And suddenly things are getting out of hands.
Reply
Thanks given by:
#18
Not yet as far as I know. Its part of my probing to work out what is the exact limits of what we are and aren't willing to support.
Reply
Thanks given by:
#19
Could this work?
AString GetOperationType()
{
   AString res = "unknown"
   #if defined (__WIN32__)
      res = "windows";
   #elif defined(__linux__)
      res = "linux";
   #elif defined(__APPLE__)
      res = "apple";
   #endif

   #ifdef __arm__
      res += " arm";
   #endif
   return res;
}

Just to get some basic information about the operation system.
Reply
Thanks given by:
#20
PowerPC? SPARC? ARM64? Android?
Reply
Thanks given by:




Users browsing this thread: 9 Guest(s)