LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-29-2009, 06:02 AM   #1
neel_learning_linux
LQ Newbie
 
Registered: May 2008
Posts: 13

Rep: Reputation: 0
changing thread user context in linux


Hi!

I wanted to know whether there is a way in linux to change the user context of *one of the threads* in the process.

I do not want to launch another process using fork or any other method.

I know that on Windows it is possible but don't know if on linux.

Thanks in advance,
-Neel.
 
Old 07-29-2009, 11:37 PM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Jessie (Fluxbox WM)
Posts: 1,388
Blog Entries: 52

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
Is getcontext and setcontext what you are after?

You can also change the user id with getuid() and setuid().
 
Old 07-31-2009, 01:06 AM   #3
neel_learning_linux
LQ Newbie
 
Registered: May 2008
Posts: 13

Original Poster
Rep: Reputation: 0
Thanks for the reply.

I am not sure. here is what I want to do:

- Change context of *only* of thread to some user from root
- use gssapi to fetch the ticket for that user
- change thread context back to root

I believe setcontext/getcontext might be the way to go but I am not sure that it will not change context of rest of the process or even GSSAPI will work with this kind of approach. I will do some trials and find out.. If you do have any further suggestions/comments, they are welcome.

Thanks,
- Neel.
 
Old 07-31-2009, 02:34 AM   #4
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Jessie (Fluxbox WM)
Posts: 1,388
Blog Entries: 52

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
Sorry, I missed your emphasis.

No, it isn't possible to just change one of the threads. The pthreads in *nix systems are light-weight compared to the Windows equivalent, and share more state information. The POSIX standard requires that they share user and group ids.

Incidentally, a fork is much faster than a CreateProcess on Windows (CreateProcess is something more akin to vfork+exec). For a long time fork was the only way to do multitasking in Unix, so it is well optimized for the job. Not sure if that makes it any more palatable?

Last edited by neonsignal; 07-31-2009 at 02:38 AM.
 
  


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
changing context thread of sw signal handler nesta Programming 5 06-01-2009 11:01 PM
How can I get the context info for a thread/process running in user mode? LostInLinux4ever Programming 1 05-23-2007 04:00 PM
Thread context switch causes lost interrupt EmbeddedSteve Linux - Kernel 1 09-01-2006 03:45 PM
Handling of Interrupts in thread context asurya Linux - Newbie 1 04-05-2006 09:15 AM
Kernel Thread Execution Context and PID ratwings Linux - Newbie 0 02-11-2005 04:06 AM


All times are GMT -5. The time now is 08:04 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration