LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 10-31-2002, 06:47 AM   #1
jpflathead
LQ Newbie
 
Registered: Oct 2002
Location: Nijmegen, The Netherlands
Distribution: suse and redhat
Posts: 8

Rep: Reputation: 0
Question segmentation fault in a thread


Hi there,
After going throug a lot of info on the internet I have this question:
if I do a outb() in a thread I get a segmentation fault. ioperm() is in that routine. Is that due to the fact that the created thread doesn't run under root? And is that normal? If I understand correctly child processes with fork() run under another user, but pthread runs under the same user (root).
Or is this not correct.
My program has now 3 parts: the main program does the file i/o work and has a timer interrupt routine (sigalrm) which triggers a thread that handles all time related things and a 3rd one which does the i/o to the par.port where the a/d converter is connected.
The latest routine now gives the seg.fault. It worked when the par.port i/o was in the main program, but then I had other problems.
Can anybody help me with this?
 
Old 11-01-2002, 05:23 AM   #2
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
This is from the fork man page: fork creates a child process that differs from the parent process only in its PID and PPID. That would mean that the child process would run as the same user as the parent does.

So as far as I understand you have three different processes running and not three different threads. One of the processes triggers the other to start doing stuff by means of sending a signal at a timer event. After moving the code from the original main to a new process it started segfaulting. Is there any parts of code that initialized certain variables in the main loop which you haven't copied over to the seperate process? Maybe I am understanding it wrong but how is the data passed from the process that is reading/writing to file to the process that is reading/writing to the serial port?

Last edited by Mik; 11-01-2002 at 05:25 AM.
 
  


Reply



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
yast segmentation fault, system freezing - nvidia driver at fault? BaltikaTroika SUSE / openSUSE 2 12-02-2005 09:34 AM
why segmentation fault??? andrewnow Programming 8 03-26-2005 06:50 PM
C Segmentation Fault fatman Programming 20 04-02-2003 05:16 PM
segmentation fault sqn Slackware 3 03-21-2003 05:26 AM
Segmentation Fault live2 Linux - General 6 03-02-2003 08:36 PM

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

All times are GMT -5. The time now is 09:36 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