LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-19-2008, 07:04 PM   #1
sharky
Member
 
Registered: Oct 2002
Posts: 545

Rep: Reputation: 74
Set umask in child process doesn't work


I can't set umask using a shell script.

begin sample script

#!/usr/local/bin/tcsh -f
umask 002
xterm &

end

enter "umask" in the child proces, xterm in this case, and it returns '22'. I've tried it with bash and got the same results. Also tried starting xterm with 'exec xterm', '/usr/bin/env xterm' and 'exec /usr/bin/env xterm'. Also tried it with KDE's 'konsole' but got no luck there.

I can set it in my ~/.cshrc file but that is not a solution. This needs to work for everyone on the network and I don't control everyones ~/.cshrc file.

All documentation I've read said that child process inherit umask. That doesn't seem to be the case. What am I doing wrong?
 
Old 06-19-2008, 07:15 PM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
One of the shell startup files is resetting umask to 022. Check the various /etc/defaults or /etc/cshrc, etc. files.

FYI: You cannot control the ability for a user to reset his/her umask once a shell is created. All you can do is setup defaults.

Last edited by Mr. C.; 06-19-2008 at 07:17 PM.
 
Old 06-19-2008, 07:34 PM   #3
sharky
Member
 
Registered: Oct 2002
Posts: 545

Original Poster
Rep: Reputation: 74
Quote:
Originally Posted by Mr. C. View Post
One of the shell startup files is resetting umask to 022. Check the various /etc/defaults or /etc/cshrc, etc. files.

FYI: You cannot control the ability for a user to reset his/her umask once a shell is created. All you can do is setup defaults.
I'm testing this with xterm. The script will eventually start an application that is used on a project shared by several users. It's OK if they manually change the umask but for the most part data will be shared amongst 'groups'.

I found the offending source file. It a central cshrc.user file that is sourced in everyone's ~/.cshrc. I'll modify it based on a variable so it will not set umask on the projects.

Thanks for your help.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how a father process know which child process send the signal SIGCHLD icoming Programming 10 07-20-2010 07:26 AM
How to kill a Child and all its subsequent child process in C shayer009 Programming 3 12-04-2007 12:40 AM
child process usses same amount of ram as parent process socialjazz Programming 7 10-19-2006 05:48 PM
Killing a child process from another child marri Programming 6 10-01-2004 07:08 PM
Bash Scripting - child process affecting parent process mthaddon Linux - General 1 05-02-2004 01:19 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration