Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: spawnle & umask

Reply
Thread Tools

Re: spawnle & umask

 
 
Yves Glodt
Guest
Posts: n/a
 
      12-08-2005
Fredrik Lundh wrote:
> Yves Glodt wrote:
>
>> I tried something like this but the umask part does not work clearly...:
>>
>> newpid =
>> os.spawnle(os.P_NOWAIT,'/usr/bin/touch','/usr/bin/touch','xyz','umask 0113')
>>
>> What would be the correct syntax for setting the umask for the created
>> process...?

>
> not sure, but something like
>
> try:
> old_mask = os.umask(0113)
> newpid = os.spawnle(...)
> finally:
> os.umask(old_mask) # restore
>
> might work.


It does, I did like this:

os.umask(0113)
newpid =
os.spawnl(os.P_NOWAIT,'/usr/local/bin/wine','/usr/local/bin/wine',executable)

But I wanted to use spawnle and it's env argument, to avoid setting
umask manually...

regards,
Yves


> </F>
>
>
>

 
Reply With Quote
 
 
 
 
David Wahler
Guest
Posts: n/a
 
      12-08-2005
Yves Glodt wrote:
> It does, I did like this:
>
> os.umask(0113)
> newpid =
> os.spawnl(os.P_NOWAIT,'/usr/local/bin/wine','/usr/local/bin/wine',executable)
>
> But I wanted to use spawnle and it's env argument, to avoid setting
> umask manually...


The umask is not part of the environment, so there's no way to set it
directly through spawnle. Why don't you want to use os.umask?

-- David

 
Reply With Quote
 
 
 
 
Yves Glodt
Guest
Posts: n/a
 
      12-08-2005
David Wahler wrote:
> Yves Glodt wrote:
>> It does, I did like this:
>>
>> os.umask(0113)
>> newpid =
>> os.spawnl(os.P_NOWAIT,'/usr/local/bin/wine','/usr/local/bin/wine',executable)
>>
>> But I wanted to use spawnle and it's env argument, to avoid setting
>> umask manually...

>
> The umask is not part of the environment, so there's no way to set it
> directly through spawnle.


ok

> Why don't you want to use os.umask?


Only because I thought spawnle could set it through env...
But as it can't I will now go with os.umask.

thanks,
Yves

> -- David
>

 
Reply With Quote
 
Donn Cave
Guest
Posts: n/a
 
      12-08-2005
In article <(E-Mail Removed)>,
Yves Glodt <(E-Mail Removed)> wrote:

> David Wahler wrote:
> > Yves Glodt wrote:
> >> It does, I did like this:
> >>
> >> os.umask(0113)
> >> newpid =
> >> os.spawnl(os.P_NOWAIT,'/usr/local/bin/wine','/usr/local/bin/wine',executabl
> >> e)
> >>
> >> But I wanted to use spawnle and it's env argument, to avoid setting
> >> umask manually...

> >
> > The umask is not part of the environment, so there's no way to set it
> > directly through spawnle.

>
> ok
>
> > Why don't you want to use os.umask?

>
> Only because I thought spawnle could set it through env...
> But as it can't I will now go with os.umask.


On UNIX, the "spawn" functions are just Python code that wraps up
the low level fork and execve system calls. There's no reason you
can't write your own version if you like, that does what you need.

It does make sense to want to modify umask and who knows what other
inheritable context in the fork, so you might be thinking of an
API with a function that's called at that time, like

spawnve(wait, file, args, env, func)

The funny thing is, that's such a good idea that the implementation
already has a function with that signature. The only difference is
that func() also must call the appropriate execve function. So for
example,

def execumask113(file, args, env):
os.umask(0113)
return os.execve(file, args, env)

...
os._spawnvef(os.P_NOWAIT, '/usr/local/bin/wine',
['wine', exe], os.environ, execumask113)

Now the problem is that this function is evidently not part of the
published API for os.py, so it would be unseemly to complain if it
were to change in later versions. So I guess the right thing to do
is write your own spawn function from the ground up. But at least
you have some ideas there about how it might work.

Donn Cave, http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
umask vs umask Daniel Berger Ruby 8 04-16-2008 05:11 AM
getting umask without changing it Faik Uygur Python 0 06-16-2006 09:07 AM
umask option for tarfile extract Faik Uygur Python 0 06-15-2006 11:42 AM
problem with "os.spawnle(os.P_NOWAIT,'C:\info.exe')" muttu2244@yahoo.com Python 2 12-16-2005 03:51 PM
spawnle & umask Yves Glodt Python 0 12-08-2005 10:43 AM



Advertisments