Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - posix_spawnp() not working with relative paths: (7 Items)
   
posix_spawnp() not working with relative paths  
Hi guys,
working with posix_sawnp() showed one very inconvenient behaviour compored to the classic spawnp() variant.
I am focusing on the ...p() variant, which checks for scripts and also PATH environment.
Documentation of posix_spawnp() says this about the given file to be spwaned:
<snip>
   If the file parameter _contains_ a slash character, the file parameter is used as the pathname for the new process 
image file.
</snip>
it says "contains" and excatly this is not working.
The Implementation only checks for starting with '/'  -> check lib/c/1d/posix_spawnp.c

So you can't use posix_spawnp() calls with relative file paths, so a ./MyBinary is not working.
I think the implementation of this ...p() variant should be changed in a way that it behaves the same way the none POSIX
 spwanp() does for relative file paths.
any suggestions?

TIA
/hp
Re: posix_spawnp() not working with relative paths  
no comments on this?
I guess I have to file a ticket -> PR
Re: posix_spawnp() not working with relative paths  
Actually the current implementation (r217700) looks - based on a quick
glance - correct to me.  It does check for a leading path separator at
line 57, but only to shortcut directly through to posix_spawn() in the
absolute path case.  I suspect that something else is not quite right.
Does your application work if you explicitly include "./" on the PATH?

Regards,
Neil
Re: posix_spawnp() not working with relative paths  
> Actually the current implementation (r217700) looks - based on a quick
> glance - correct to me.  It does check for a leading path separator at
> line 57, but only to shortcut directly through to posix_spawn() in the
> absolute path case.  I suspect that something else is not quite right.
> Does your application work if you explicitly include "./" on the PATH?
> 
> Regards,
> Neil

If you want to add CWD to your Path you have to add "." to your PATH.
I don't know anybody how has a "./" in PATH.
Elements in PATH are directories that do not to have a trailing "/".
The incorrectness is in the difference of documentation and implementation.
It says: "if the given filepath *CONTAINS* ..."
this not checked, just compare the part of filepath resolution to spawnp(), it is different and in my eyes incomplete.
And ... just try to launch a binary with "./binary"
It will not work with posix_spawnp() and that's an error
even if I do not have CWD in my PATH addressing the binary with ./binary has to work.

/hp
Re: posix_spawnp() not working with relative paths  
On Mon, 2009-10-19 at 14:12 -0400, Hans-Peter Reichert wrote:
> > Actually the current implementation (r217700) looks - based on a quick
> > glance - correct to me.  It does check for a leading path separator at
> > line 57, but only to shortcut directly through to posix_spawn() in the
> > absolute path case.  I suspect that something else is not quite right.
> > Does your application work if you explicitly include "./" on the PATH?
> > 
> > Regards,
> > Neil
> 
> If you want to add CWD to your Path you have to add "." to your PATH.
> I don't know anybody how has a "./" in PATH.
> Elements in PATH are directories that do not to have a trailing "/".
> The incorrectness is in the difference of documentation and implementation.
> It says: "if the given filepath *CONTAINS* ..."
> this not checked, just compare the part of filepath resolution to spawnp(), it is different and in my eyes incomplete.

> And ... just try to launch a binary with "./binary"
> It will not work with posix_spawnp() and that's an error
> even if I do not have CWD in my PATH addressing the binary with ./binary has to work.

Yes, that's why I was asking.  Does adding "./" to your PATH workaround
the problem for you for now?  I'm writing a PR for this but it would be
useful to know if that works around the problem.

Regards,
Neil
Re: posix_spawnp() not working with relative paths  
I've gone ahead and raised PR 72089 for this.  If you raise a support ticket, please let your support rep know the PR 
number.

Regards,
Neil
AW: posix_spawnp() not working with relative paths  
I don't have the chance to test that, sorry.
/hp 

>-----Ursprüngliche Nachricht-----
>Von: Neil Schellenberger [mailto:community-noreply@qnx.com] 
>Gesendet: Montag, 19. Oktober 2009 20:34
>An: ostech-core_os
>Betreff: Re: posix_spawnp() not working with relative paths
>
>On Mon, 2009-10-19 at 14:12 -0400, Hans-Peter Reichert wrote:
>> > Actually the current implementation (r217700) looks - based on a 
>> > quick glance - correct to me.  It does check for a leading path 
>> > separator at line 57, but only to shortcut directly through to 
>> > posix_spawn() in the absolute path case.  I suspect that 
>something else is not quite right.
>> > Does your application work if you explicitly include "./" 
>on the PATH?
>> > 
>> > Regards,
>> > Neil
>> 
>> If you want to add CWD to your Path you have to add "." to your PATH.
>> I don't know anybody how has a "./" in PATH.
>> Elements in PATH are directories that do not to have a trailing "/".
>> The incorrectness is in the difference of documentation and 
>implementation.
>> It says: "if the given filepath *CONTAINS* ..."
>> this not checked, just compare the part of filepath 
>resolution to spawnp(), it is different and in my eyes incomplete.
>> And ... just try to launch a binary with "./binary"
>> It will not work with posix_spawnp() and that's an error 
>even if I do 
>> not have CWD in my PATH addressing the binary with ./binary 
>has to work.
>
>Yes, that's why I was asking.  Does adding "./" to your PATH 
>workaround the problem for you for now?  I'm writing a PR for 
>this but it would be useful to know if that works around the problem.
>
>Regards,
>Neil
>
>
>
>
>_______________________________________________
>
>OSTech
>http://community.qnx.com/sf/go/post40261
>
> 
 
*******************************************
Harman Becker Automotive Systems GmbH
Management Board: Dr. Klaus Blickle (Chairman), Dr. Udo Hüls, Michael Mauser
Chairman of the Supervisory Board: Ansgar Rempp | Domicile: Karlsbad | 
Local Court Mannheim: Register No. 361395

 
*******************************************
Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen. Wenn Sie nicht der richtige Adressat 
sind oder diese E-Mail irrtuemlich erhalten haben, informieren Sie bitte sofort den Absender und loeschen Sie diese Mail
. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have 
received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, 
disclosure or distribution of the contents in this e-mail is strictly forbidden.
*******************************************