473,795 Members | 2,826 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

illegal seek

this code gives an "illegal seek error" on close() call
what is this error and when does it come?

main()
{
int fd,num;
char buf[150];
fd = open ("123.c",O_RDWR );
if(fd!=-1)
{

printf("a file with fd=%d is opened\n",fd);
num=read(fd,buf ,150);
printf("num=%d\ nREAD:%s",num,b uf);
perror("READ");
close(fd);
perror("CLOSE") ;
}
}
Jun 27 '08
22 7278
On 16 May 2008 at 10:25, CBFalconer wrote:
Of course the Twink-troll also snipped my explanation, which
follows below:
Indeed I did. Because it was utter bullshit. It was an expression of
your opinion, which I violently disagree with, and I don't think it is
worthy of a reply. You clearly never get bored of endless rants about
topicality, but I'm no longer rising to the bait.

Watch: I'm snipping it again.

[snip]
which is part of the trolls standard mechanism, aiming to disturb
the normal operation of the newsgroup.
Of course, replying to spam doesn't disturb the normal operation of the
newsgroup in the slightest. Neither does your continual attempts to
drive away new participants in the group by continually spewing out your
tedious views on topicality. And neither does the stream of
embarrassingly wrong answers you provide to questions.
I see no reason to ever use open, close and read, when fopen, fclose
and fread are available everywhere, and portable.
Of course you don't. You have no interest in any program more
complicated than a solution to one of the exercises in K&R. You have an
arrogant disdain for people who dirty their hands with real-world
programming, when they might come across good reasons to use open, close
and read. Here are the first few that spring to mind:

* to be able to work with file permissions and ownership
* getting file information with fstat (e.g. the size of a file)
* locking files with fcntl or flock
* getting file change notifications with fcntl
* to be able to send ioctls to devices

Jun 27 '08 #21
In article <sl************ *******@nospam. invalid>,
Antoninus Twink <no****@nospam. invalidwrote:
>On 16 May 2008 at 10:25, CBFalconer wrote:
>I see no reason to ever use open, close and read, when fopen, fclose
and fread are available everywhere, and portable.
>Here are the first few that spring to mind:
>* to be able to work with file permissions and ownership
* getting file information with fstat (e.g. the size of a file)
* locking files with fcntl or flock
* getting file change notifications with fcntl
* to be able to send ioctls to devices
Those all involve extensions beyond the perview of C itself, and
are best discussed in a newsgroup that deals with the scope of the
extensions required (e.g., POSIX is going to have different behaviours
than Linux or MS Windows.)

In every extension I can currently think of that supports
the operations listed, open(), close() and read() are unnecessary
for any of the listed operations: those operations work on file
descriptors, and one can determine a FILE's file descriptor using
the fileno() extension upon a file that one has fopen()'d.
And if there are OS's that support file descriptors but do not
offer fileno() but still offer the listed operations, then such
OSs would certainly not be operating in any standardized way, which
would make it even more important to discuss the details in
an appropriate newsgroup rather than here.

--
"This quitting thing, it's a hard habit to break once you start."
-- Walter Matthau
Jun 27 '08 #22
jacob navia <ja***@nospam.o rgwrites:
[...]
Why would you need to use fileno each time when you just
use open/close etc and be done with it?

You gave no valid reason.
I'm sure there are plenty of valid reasons to use open/close rather
than fileno.

comp.unix.progr ammer would be a great place to discuss those reasons
(if they're not already thoroughly covered in the FAQ).

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 27 '08 #23

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4218
by: Waitman Gobble | last post by:
Hello, I am new to Python. I am having trouble with zipfile.py. On a Linux machine with python 2.4.2 I have trouble opening a zipfile. Python is complaining about the bit where it does a seek(-22,2). Looks to me like zipfile.py is trying to come back 22 bytes from the end of file. # python
0
314
by: Felix Finch | last post by:
I have a perl test program which has about 80 test cases, each of which creates its own schema so I can remove them with DROP SCHEMA xxx CASCADE. Normally each test case creates and drops the same schema, but it can run a mode to preserve each schema and all the disk files for each test. I recently changed my cleanup code to run psql with all -c commands on one command line rather than a separate psql -c for each one ... psql -c 'DROP...
59
7524
by: Rico | last post by:
Hello, I have an application that I'm converting to Access 2003 and SQL Server 2005 Express. The application uses extensive use of DAO and the SEEK method on indexes. I'm having an issue when the recordset opens a table. When I write Set rst = db.OpenRecordset("MyTable",dbOpenTable, dbReadOnly) I get an error. I believe it's invalid operation or invalid parameter, I'm
4
6916
by: Vlad | last post by:
I am having problems using the file.create method within a function that is called when looping through an array of filepaths. If I call my function with a hardcoded file path --C:\Temp.txt the function creates the file as expected. When I loop through my array I get the error - "ArgumentException was unhandled - Illegal characters in path" The value "C:\Temp.txt" is the first value in the array - as it works
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10164
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10001
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9042
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7540
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.