473,320 Members | 1,939 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Linking to an opened inode w/o links left: how?

Hi,

I am writing a wrapper in C for an existing program. The wrapper
maintains a run file that is created for one invocation of the program
and is removed for another. My idea of making the last action
fool-proof is like this:

- save the run file status via stat()
- open the run file for reading
- unlink() it
- do an execv() on the program to be started
- if the execv() fails, restore the link to the inode saved by stat()
and close the run file
- otherwise, the run file is deleted upon completion of the program
started

However, link() only allows adding a link by referring to another link
to a given inode, not to the inode itself. Is there another way, or
should I forget about this scheme and just use a fork() to start the
program?

Thanks,

Jan Stap
Nov 13 '05 #1
16 1657
Jan Stap <js*******@stap.mdcc.cx> scribbled the following:
Hi, I am writing a wrapper in C for an existing program. The wrapper
maintains a run file that is created for one invocation of the program
and is removed for another. My idea of making the last action
fool-proof is like this: - save the run file status via stat()
Not a standard C function.
- open the run file for reading
- unlink() it
Not a standard C function.
- do an execv() on the program to be started
- if the execv() fails, restore the link to the inode saved by stat()
Neither of these is a standard C function.
and close the run file
- otherwise, the run file is deleted upon completion of the program
started However, link() only allows adding a link by referring to another link
to a given inode, not to the inode itself. Is there another way, or
should I forget about this scheme and just use a fork() to start the
program?


link() and fork() are not standard C functions.

Just to be clear and all, comp.unix.programmer is a better place to ask
about this.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"It's not survival of the fattest, it's survival of the fittest."
- Ludvig von Drake
Nov 13 '05 #2
I guess this is both wrong, and not my business, but wasn't *nix written in
C and therefore all that stuff is a subset of C?

ML

"Joona I Palaste"
Hi,

I am writing a wrapper in C for an existing program. The wrapper
maintains a run file that is created for one invocation of the program
and is removed for another. My idea of making the last action
fool-proof is like this:

- save the run file status via stat()


Not a standard C function.
- open the run file for reading
- unlink() it


Not a standard C function.
- do an execv() on the program to be started
- if the execv() fails, restore the link to the inode saved by stat()


Neither of these is a standard C function.
and close the run file
- otherwise, the run file is deleted upon completion of the program
started

However, link() only allows adding a link by referring to another link
to a given inode, not to the inode itself. Is there another way, or
should I forget about this scheme and just use a fork() to start the
program?


link() and fork() are not standard C functions.

Just to be clear and all, comp.unix.programmer is a better place to ask
about this.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"It's not survival of the fattest, it's survival of the fittest."
- Ludvig von Drake

Nov 13 '05 #3
Marcus Lessard <sp****@spam.com> scribbled the following:
I guess this is both wrong, and not my business, but wasn't *nix written in
C and therefore all that stuff is a subset of C?


Unix *was* written in C, yes. But this doesn't magically make all this
a subset of C. The web browser I use, Mozilla, was also written in C,
but you don't see me asking questions how to configure the HTTP headers
that Mozilla is sending here, do you?
If you are meaning that the C API that Unix defines is a subset of C,
that is also wrong. For it to be a subset of C it would have to work on
all platforms that have a C implementation. This is provably false.

PS. Please don't top-post. Thanks.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"When a man talks dirty to a woman, that's sexual harassment. When a woman talks
dirty to a man, that's 14.99 per minute + local telephone charges!"
- Ruben Stiller
Nov 13 '05 #4
On Mon, 10 Nov 2003 12:46:39 -0500
"Marcus Lessard" <sp****@spam.com> wrote:

Please don't top post. I've fixed it and if you want to know why do a
google search. We've already been through all the arguments.
"Joona I Palaste"
<snip stuff about *nix specific code>
I guess this is both wrong, and not my business, but wasn't *nix
written in C and therefore all that stuff is a subset of C?


No. The various Unix derivative are written in C + lots of extensions +
assembler. It is not possible to write a complete operating system
entirely in C.

The C language and standard library are defined by K&R1 (for
pre-standard) and the ANSI & ISO standards (ANSI predates ISO slightly)
for anything since 1989.

Here we only discuss C, not the *nix API or any other API or extensions.
--
Mark Gordon
Paid to be a Geek & a Senior Software Developer
Although my email address says spamtrap, it is real and I read it.
Nov 13 '05 #5
Marcus Lessard wrote:
I guess this is both wrong, and not my business, but wasn't *nix written in
C and therefore all that stuff is a subset of C?

ML


By your logic, any program written in C is a subset of the C language.
If I write a program to drive a vending machine using the C language,
then the vending machine must be a subset of the C language.
Nope, wrong.

If I use a tool to build a house, then the house is a subset of
the tool. {Replace tool with hammer, drill, ruler, etc.}
Hmm, doesn't make sense either.

The _standard_ C language is all that is described by the ANSI/ISO
standard. Nothing more. Languages are tools used to create
programs.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Nov 13 '05 #6
Fair enough.

"Thomas Matthews" > The _standard_ C language is all that is described by
the ANSI/ISO
standard. Nothing more.

Nov 13 '05 #7
Not a C question but since you said it would you mind explaining it?

ejd

"Joona I Palaste"

PS. Please don't top-post. Thanks.
Nov 13 '05 #8
Marcus Lessard <sp****@spam.com> scribbled the following:
Not a C question but since you said it would you mind explaining it?
You mean the bit about not top-posting? Sure.
It has to do with how you write your reply to the post you are quoting.
In bottom-posting, the quoted article goes first, the reply goes next.
In top-posting, the reply goes first, the quoted article goes next.

Example of bottom-posting:
-----------------------------------------------------------------------
Foo Bar wrote: Is this true? Yes.
-----------------------------------------------------------------------
Example of top-posting:
-----------------------------------------------------------------------
Yes.
Foo Bar wrote: Is this true? -----------------------------------------------------------------------

The reasons why top-posting is bad have been explained here several
times in the last couple of days. Read the newsgroup a little more to
find them.
"Joona I Palaste" PS. Please don't top-post. Thanks.


--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Insanity is to be shared."
- Tailgunner
Nov 13 '05 #9

"Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message
news:bo**********@oravannahka.helsinki.fi...
Marcus Lessard <sp****@spam.com> scribbled the following:
Not a C question but since you said it would you mind explaining it?


You mean the bit about not top-posting? Sure.
It has to do with how you write your reply to the post you are quoting.
In bottom-posting, the quoted article goes first, the reply goes next.
In top-posting, the reply goes first, the quoted article goes next.


Ahh. I wondered if there was a preference on that. Thanks.

ML
Nov 13 '05 #10
In article <bo**********@oravannahka.helsinki.fi>
Joona I Palaste <pa*****@cc.helsinki.fi> writes:
The reasons why top-posting is bad have been explained here several
times in the last couple of days. Read the newsgroup a little more to
find them.


I have an example I came up with, but I like this one (apparently
written by Clifton Sharp; see
<http://groups.google.com/groups?selm=MPG.1989acc3b7d63f2498973a%40news.cis. dfn.de>)
even better:

"I'll see you at Linda's wedding."
"Well, see ya soon."
"Congratulations!"
"Ten thousand a year."
"How much?"
"Got a really big raise this time."
"Sorry to hear it. How's the job?"
"She's not feeling well. Flu, I think."
"Same as ever. How's yours?"
"How's your wife?"
"They painted her purple. They should call her the Prune Fart now."
"Good. Did you hear what Martin and Sheila did to the Sea Breeze?"
"Good, and you?"
"Bill! How the heck are you?"

One's goal in writing in a newsgroup is -- or at least should be,
I believe -- communicating with others, and carefully-edited quotes
interspersed with replies should help one achieve that.
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://67.40.109.61/torek/index.html (for the moment)
Reading email is like searching for food in the garbage, thanks to spammers.
Nov 13 '05 #11
Chris Torek <no****@elf.eng.bsdi.com> scribbled the following:
In article <bo**********@oravannahka.helsinki.fi>
Joona I Palaste <pa*****@cc.helsinki.fi> writes:
The reasons why top-posting is bad have been explained here several
times in the last couple of days. Read the newsgroup a little more to
find them.
I have an example I came up with, but I like this one (apparently
written by Clifton Sharp; see
<http://groups.google.com/groups?selm=MPG.1989acc3b7d63f2498973a%40news.cis. dfn.de>)
even better: "Got a really big raise this time."
"Sorry to hear it. How's the job?"
Sorry to hear someone's got a big raise? Isn't that carrying envy a
bit too far?
"How's your wife?"
"They painted her purple. They should call her the Prune Fart

now."

Painted his wife purple? Why? For her to pass as a Cataxxan?

(Yes, I know what it really means. I was just having fun.)

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"This is a personnel commuter."
- Train driver in Scientific American
Nov 13 '05 #12

"Chris Torek"

One's goal in writing in a newsgroup is -- or at least should be,
I believe -- communicating with others, and carefully-edited quotes
interspersed with replies should help one achieve that.
--


Us "top-posters" are not insane or stupid...we think that we are saving you
the trouble of scrolling down to the new material. I honestly wouldn't have
imagined that it was a big deal, but when in Rome post as the Romans do.

ML
Nov 13 '05 #13
Marcus Lessard <sp****@spam.com> scribbled the following:
"Chris Torek"
One's goal in writing in a newsgroup is -- or at least should be,
I believe -- communicating with others, and carefully-edited quotes
interspersed with replies should help one achieve that.
Us "top-posters" are not insane or stupid...we think that we are saving you
the trouble of scrolling down to the new material. I honestly wouldn't have
imagined that it was a big deal, but when in Rome post as the Romans do.


If you find it tiresome to scroll though the quoted material, there is
too much quoted material. Bottom-posting goes hand-in-hand with
selective snipping.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"My absolute aspect is probably..."
- Mato Valtonen
Nov 13 '05 #14
On Wed, 12 Nov 2003 11:41:33 -0500, "Marcus Lessard" <sp****@spam.com>
wrote:

"Chris Torek"

One's goal in writing in a newsgroup is -- or at least should be,
I believe -- communicating with others, and carefully-edited quotes
interspersed with replies should help one achieve that.
--


Us "top-posters" are not insane or stupid...we think that we are saving you
the trouble of scrolling down to the new material. I honestly wouldn't have
imagined that it was a big deal, but when in Rome post as the Romans do.

ML

Scrolling down to try to figure out what you're replying to is not an
improvement.

--
Al Balmer
Balmer Consulting
re************************@att.net
Nov 13 '05 #15
Alan Balmer <al******@att.net> scribbled the following:
On Wed, 12 Nov 2003 11:41:33 -0500, "Marcus Lessard" <sp****@spam.com>
wrote:
"Chris Torek"
One's goal in writing in a newsgroup is -- or at least should be,
I believe -- communicating with others, and carefully-edited quotes
interspersed with replies should help one achieve that.


Us "top-posters" are not insane or stupid...we think that we are saving you
the trouble of scrolling down to the new material. I honestly wouldn't have
imagined that it was a big deal, but when in Rome post as the Romans do.

Scrolling down to try to figure out what you're replying to is not an
improvement.


Indeed, I have seen top-posted articles where the reply starts with
something like "But in that case..." while there are several points in
the original article, not related to each other. "In *which* case?" I
have to ask myself. Of course it was obvious to the responder when he
read the original article but I can't read the responder's mind.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Hasta la Vista, Abie!"
- Bart Simpson
Nov 13 '05 #16
Marcus Lessard wrote:
Chris Torek wrote:
One's goal in writing in a newsgroup is -- or at least should be,
I believe -- communicating with others, and carefully-edited quotes
interspersed with replies should help one achieve that.


Us "top-posters" are not insane or stupid.
We think that
we are saving you the trouble of scrolling down to the new material.
I honestly wouldn't have imagined that it was a big deal,
but when in Rome post as the Romans do.


The point is that
we don't want you to quote the article to which you are responding.
Instead, snip out everything that is irrelevant to your response.
Don't complain about misspelled words, poor grammar, punctuation
or capitalization. Quietly fix it if it bothers you.
Paraphrase as necessary to best represent *your* understanding
of what was said in the article to which you are responding.
Subscribers can consult the archives of previous messages
if they feel that you have misrepresented what was actually said.
If the article to which you are responding makes multiple points,
try to isolate each point and insert your response immediately
after each point.

Nov 13 '05 #17

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

Similar topics

33
by: randau | last post by:
Linking to a Targeted Browser Window I'd like to open reference links to other web sites in a separate browser window from the browser window hosting my own web site pages. The Link Target...
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the...
16
by: Thomas Maier-Komor | last post by:
Hi everybody, I have a problem with a certain link pattern that gets resolved wrong in the IE, but works find on Firefox. Maybe somebody has an idea, how to work around it. I have an .html...
6
by: shyam | last post by:
Hi All I had raised a simillar query in an earlier post ...
3
by: Robert McEuen | last post by:
Using A2K3, Windows XP I'm handling a many-to-many relationship with a linking table structure as follows (irrelevant fields omitted): tblIssue PK_IssueID (autonumber, primary key) IssueName...
15
by: kamarajbca | last post by:
dear sir, Now I am doing the task that the index page contains the US states Map.When i am pressing on the particular state that state map will be open.I create the link to states using with...
2
by: asit | last post by:
why this program shows ambiguous behavior ?? import os import stat import time #import types file_name=raw_input("Enter file name : ") print file_name, "information" st=os.stat(file_name)
4
by: Mike | last post by:
I have a multiuser access database to which I have split into fe & be. The system refreshes the links at each log-on between the fe & be automatically via code. PROBLEM: Locally it runs...
4
by: naveenmurthy | last post by:
Hello All, I have created a .mht file in following format. 1. The .mht file contains following htmls. a. MHTLinkingProblem.html b. Left.html c. Right.html d. Start.html
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.