LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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-18-2012, 12:49 PM   #1
newbie_member
LQ Newbie
 
Registered: Jul 2012
Posts: 4

Rep: Reputation: Disabled
Smile Read file in folder /proc/"pid"/fd/0 in ubuntu v11.10?


I cannot read file in folder /proc/"pid"/fd/0 which I need read it from C language to display screen.

Thank you so much!
 
Old 07-18-2012, 01:08 PM   #2
ppoulsen
LQ Newbie
 
Registered: May 2012
Posts: 5

Rep: Reputation: Disabled
Have you tried running your program with superuser privileges?
Code:
sudo ./my_program
 
Old 07-18-2012, 01:26 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
Originally Posted by newbie_member View Post
I cannot read file in folder /proc/"pid"/fd/0 which I need read it from C language to display screen.

Thank you so much!
Please confirm that you want to use a C program to read this file.

What happens when you try to read it?

On my system, I randonly checked some processes, and it seems that fd0 typically points to /dev/null. What would you expect to accomplish by reading from there?
 
Old 07-18-2012, 01:42 PM   #4
newbie_member
LQ Newbie
 
Registered: Jul 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
Oh sorry, I only want get information TTY of a process, but I don't know read it from C language.

Ex: commands "ps -A" in terminal

Result:
PID TTY TIME CMD

2935 ? 00:00:00 gnome-pty-helpe
2936 pts/0 00:00:00 bash
 
Old 07-19-2012, 06:05 AM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Do you want to find if a process uses a TTY?

In BASH, you could do:

Code:
ls -l /proc/<PID>/fd | grep tty
 
  


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
[SOLVED] There is no "menu.lst" in my Ubuntu "/boot/grub/" folder. msbstar Linux - Newbie 18 09-15-2012 02:26 PM
unpredictable "delete" "move to trash" or "cut" file menu option dorianrenato Linux - General 3 11-28-2011 07:41 PM
[SOLVED] gnome 2 kate The file "could not be opened: it is not a normal file, it is a folder" masuch Linux - Newbie 9 09-29-2011 06:41 PM
read call is hanging and ls -l /proc/PID/fd shows broken pipe on file descriptor exceed1 Linux - Server 0 01-22-2011 01:24 PM
System Information Made Easy : Contains of "/proc" folder in details thandermax Linux - News 4 01-17-2006 06:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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