The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
c system call rangaswamy High Level Programming 1 02-19-2008 10:53 AM
how to differentiate system call from library call muru UNIX for Advanced & Expert Users 2 07-19-2007 08:20 PM
a system call for sed in a awk script seaten UNIX for Dummies Questions & Answers 6 05-20-2005 07:17 AM
any system call in unix to access ip routing table vinodkumar IP Networking 1 04-21-2005 08:56 AM
Need help to access/mount so to access folder/files on a Remote System using Linux OS S.Vishwanath UNIX for Dummies Questions & Answers 2 07-30-2001 05:17 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 03-24-2008
Registered User
 

Join Date: Dec 2007
Location: TamilNadu,INDIA
Posts: 48
Red face Access()System call

Hi,

Is it possible to check the Existence/read/write of stdin,stdout,stderr using access() call like for the files we do.

Ex: fd=access("./hi.txt",F_OK)

Similarly I wanna check stdin/tdout/stderr using access() call

I tried using fd=access(stdout,F_OK);

But the result is -1.

I believe I did some error in writing it. Will you please suggest the correct way?

Also one more doubt with access() call. Is it True that the standard file desc of STDIN,STDOUT and STDERR are 0,1,2 respectively?
Thanks,
Ramkrix
Reply With Quote
Forum Sponsor
  #2  
Old 03-24-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,298
First off, how did that ever compile, should be:
Code:
fd=access(fileno(stdout),F_OK);
Reply With Quote
  #3  
Old 03-24-2008
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,658
access() requires a path, not an fd, for the first argument. The closest equivalent for an fd that I can think of is an fcntl with a command of F_GETFD or maybe F_GETFL. I would try those. Remember that a valid fd may not refer to a disk file at all. It could be a socket or something like that.
Reply With Quote
  #4  
Old 03-26-2008
Registered User
 

Join Date: Dec 2007
Location: TamilNadu,INDIA
Posts: 48
Hi Perdebo,

then how can we make access() sys call work with stdin, stdout, stderr.

Jim,
I tried your way, but it did not worked out. please help me.

Thanks,
Ramkrix
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:52 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0