Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to next message
zsolt is currently offline  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 #6323 is a reply to message #6322] Mon, 06 November 2006 13:24 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
zsolt wrote on Mon, 06 November 2006 07:08


Is this intentional or a bug?



Bug - not yet implemented...

Maybe you can help, see ide/Host.cpp line 253, instead of execvp there should be execvpe with the new environment.

try something like

Buffer<char> env(environment.GetCount() + 1);
memcpy(env, environment, environment.GetCount() + 1);
if(pid == 0)
    execvpe(args[0], args, env);


and report results Wink

Mirek
Re: UPP_MAIN__ is not exported to env in linux [message #6327 is a reply to message #6323] Mon, 06 November 2006 17:42 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 697
Registered: December 2005
Location: Budapest, Hungary
Contributor
Thanks, I will try 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 Go to previous messageGo to next message
zsolt is currently offline  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 Go to previous messageGo to next message
zsolt is currently offline  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
Re: UPP_MAIN__ is not exported to env in linux [message #6500 is a reply to message #6333] Tue, 14 November 2006 22:38 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 697
Registered: December 2005
Location: Budapest, Hungary
Contributor
Mirek, I saw that you merged my modifications into Ide/Host.cpp. Thanks for that.

But what is the problem with my second patch? I created it, because in the original version, the LocalSlaveProcess::Open() method passes environment to child process, got from Environment() function, not the envptr argument of the method.
Re: UPP_MAIN__ is not exported to env in linux [message #6509 is a reply to message #6500] Wed, 15 November 2006 13:39 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
My apology. I did pasted it in to compare two versions, confirmed it seems ok, but then deleted the new code instead of old by mistake.

Should be OK now.

Mirek
Re: UPP_MAIN__ is not exported to env in linux [message #6511 is a reply to message #6509] Wed, 15 November 2006 13:59 Go to previous message
zsolt is currently offline  zsolt
Messages: 697
Registered: December 2005
Location: Budapest, Hungary
Contributor
Thanks.
Previous Topic: How to compile thrid-party packages?
Next Topic: Slow Linking under Linux
Goto Forum:
  


Current Time: Fri May 03 03:26:46 CEST 2024

Total time taken to generate the page: 0.04436 seconds