05-05-2015, 08:11 AM
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.
Linux popen() alternative
|
05-05-2015, 08:11 AM
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.
05-05-2015, 03:58 PM
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.
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)
05-05-2015, 10:17 PM
Not all non-windows platforms are *nix based. What about mac classic? or are you going to not support it?
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>".
05-05-2015, 10:56 PM
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.
05-05-2015, 11:14 PM
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.
05-05-2015, 11:22 PM
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.
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.
05-05-2015, 11:34 PM
PowerPC? SPARC? ARM64? Android?
|
« Next Oldest | Next Newest »
|