Home » U++ TheIDE » U++ TheIDE: Compiling, Linking, Debugging of your packages » UPP_MAIN__ is not exported to env in linux
UPP_MAIN__ is not exported to env in linux [message #6322] |
Mon, 06 November 2006 13:08 |
zsolt
Messages: 697 Registered: December 2005 Location: Budapest, Hungary
|
Contributor |
|
|
I'm using UPP_MAIN__ environment variable in windows to find out if the app runs under the ide.
Additionally I can use my custom files using that path, as the app is not installed yet.
But this variable is not exported when running IDE in Linux.
Is this intentional or a bug?
Do you have any alternative way to it?
|
|
|
|
|
Re: UPP_MAIN__ is not exported to env in linux [message #6331 is a reply to message #6327] |
Tue, 07 November 2006 00:16 |
zsolt
Messages: 697 Registered: December 2005 Location: Budapest, Hungary
|
Contributor |
|
|
I fixed this for normal run and the debug session.
In Ide/Host.cpp, the end of void LocalHost::Launch(const char *_cmdline, bool console) method is:
pid_t pid = fork();
if(pid == 0)
{
int from = 0;
Vector<const char *> env;
const char *envptr = environment;
while(envptr[from])
{
env.Add(&envptr[from]);
from += strlen(&envptr[from]) + 1;
}
env.Add(NULL);
const char **envp = env.Begin();
execve(args[0], args, (char *const *)envp);
}
sPid().Add(pid);
#endif
An other pace, where I had to change for debug run is Web/sproc.cpp in void LocalSlaveProcess::Open(const char *command, const char *envptr) method:
#if DO_SVRLOG
SVRLOG(args.GetCount() << "arguments:");
for(int a = 0; a < args.GetCount(); a++)
SVRLOG("[" << a << "]: <" << (args[a] ? args[a] : "NULL") << ">");
#endif//DO_SVRLOG
SVRLOG("running execve, app = " << app << ", #args = " << args.GetCount());
int from = 0;
Vector<const char *> env;
while(envptr[from])
{
env.Add(&envptr[from]);
from += strlen(&envptr[from]) + 1;
}
env.Add(NULL);
const char **envp = env.Begin();
execve(app_full, args.Begin(), (char *const *)envp);
SVRLOG("execve failed, errno = " << errno);
printf("Error running '%s', error code %d\n", command, errno);
exit(-errno);
#endif
I'm not very good in pointer aritmethic, so tests are needed. Currently, this fix is working fine on my Ubuntu Linux 606 system.
|
|
|
Re: UPP_MAIN__ is not exported to env in linux [message #6333 is a reply to message #6331] |
Tue, 07 November 2006 00:30 |
zsolt
Messages: 697 Registered: December 2005 Location: Budapest, Hungary
|
Contributor |
|
|
I made them a little bit more elegant.
In Ide/Host.cpp, the end of void LocalHost::Launch(const char *_cmdline, bool console) method is:
pid_t pid = fork();
if(pid == 0)
{
const char *from = environment;
Vector<const char *> env;
while(*from)
{
env.Add(from);
from += strlen(from) + 1;
}
env.Add(NULL);
const char **envp = env.Begin();
execve(args[0], args, (char *const *)envp);
}
sPid().Add(pid);
#endif
Web/sproc.cpp in void LocalSlaveProcess::Open(const char *command, const char *envptr) method:
#if DO_SVRLOG
SVRLOG(args.GetCount() << "arguments:");
for(int a = 0; a < args.GetCount(); a++)
SVRLOG("[" << a << "]: <" << (args[a] ? args[a] : "NULL") << ">");
#endif//DO_SVRLOG
SVRLOG("running execve, app = " << app << ", #args = " << args.GetCount());
const char *from = envptr;
Vector<const char *> env;
while(*from)
{
env.Add(from);
from += strlen(from) + 1;
}
env.Add(NULL);
const char **envp = env.Begin();
execve(app_full, args.Begin(), (char *const *)envp);
SVRLOG("execve failed, errno = " << errno);
printf("Error running '%s', error code %d\n", command, errno);
exit(-errno);
#endif
|
|
|
|
|
|
Goto Forum:
Current Time: Fri May 03 03:26:46 CEST 2024
Total time taken to generate the page: 0.04436 seconds
|