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 01:53 PM
how to differentiate system call from library call muru UNIX for Advanced & Expert Users 2 07-20-2007 12:20 AM
a system call for sed in a awk script seaten UNIX for Dummies Questions & Answers 6 05-20-2005 11:17 AM
any system call in unix to access ip routing table vinodkumar IP Networking 1 04-21-2005 12:56 PM
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 09:17 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-24-2008
ramkrix ramkrix is offline
Registered User
  
 

Join Date: Dec 2007
Location: TamilNadu,INDIA
Posts: 52
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
  #2 (permalink)  
Old 03-24-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,763
First off, how did that ever compile, should be:
Code:
fd=access(fileno(stdout),F_OK);
  #3 (permalink)  
Old 03-24-2008
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,123
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.
  #4 (permalink)  
Old 03-27-2008
ramkrix ramkrix is offline
Registered User
  
 

Join Date: Dec 2007
Location: TamilNadu,INDIA
Posts: 52
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:22 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0