The man page of fork() says that the file descriptor are shared by
parent process & childern processes, so any operation of file
descriptor will affect them both.
But why the behavior of FILE doesn't like file descriptors?
This is my program, the result of operation of file descriptor is
ideal, but result of operation of FILE is amazing...
int fd=-1, pid;
FILE *fin=(FILE *)NULL;
fd=open("mem.tm p", O_RDWR);
fin=fopen("mem1 .tmp", "r");
pid=fork();
if(pid) {
printf("(parent )\n");
printf("(parent ) lseek(): %d\n", lseek(fd, 10, SEEK_SET));
fseek(fin, 10, SEEK_SET);
printf("(parent ) ftell(): %d\n", ftell(fin));
}
else {
printf("(child) \n");
printf("(child) \n");
printf("(child) ftell(): %d\n", ftell(fin));
} 3 2290
bite me if you can... wrote: The man page of fork() says that the file descriptor are shared by parent process & childern processes, so any operation of file
[snip]
....news:comp.u nix.programmer, where things like fork() are *on*-topic.
HTH,
--ag
--
Artie Gold -- Austin, Texas http://goldsays.blogspot.com
"You can't KISS* unless you MISS**"
[*-Keep it simple, stupid. **-Make it simple, stupid.]
"bite me if you can..." <cc*****@gmail. com> writes: The man page of fork() says
[...]
fork(), like mmap(), is not a standard C function. Try
comp.unix.progr ammer.
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
"bite me if you can..." <cc*****@gmail. com> wrote:
# The man page of fork() says that the file descriptor are shared by
# parent process & childern processes, so any operation of file
# descriptor will affect them both.
# But why the behavior of FILE doesn't like file descriptors?
FILEs aren't file descriptors. They have additional buffering
and other attributes. If you want to multitask, like fork or
threads, you need to check your system's documentation how these
interact with stdio.
--
SM Ryan http://www.rawbw.com/~wyrmwif/
I love the smell of commerce in the morning. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: C Gillespie |
last post by:
Dear All,
I have a function
def printHello():
fp = open('file','w')
fp.write('hello')
fp.close()
I would like to call that function using spawn or fork. My questions are:
|
by: CwK |
last post by:
How to use fork() system function to fork multi child process at the same
time ?
For example:
Run a program to fork 5 child process at the same time and the parent must
wait until all child exit.
The child do some thing like to read different file at the same time.
|
by: Gvs |
last post by:
Hi,
I'm just playing around with forking processes and was wondering how can you
keep a child alive as long as the parent is alive. To give an example here
is my code.
-----------------------------------------------------------------------
for(i=0; i<2; i++) {
if((pid = fork()) == -1) //run the fork command
|
by: ramu |
last post by:
Hi All,
We know that a c function never returns more than one value.
Then how come the fork() function returns two values? How it is
implemented?
Regards
|
by: vduber6er |
last post by:
Hi I want to have a wait page while the rest of the cgi does its
process, but it seems like the wait page waits till everything is
complete and never appears. I've tried forking twice already as
suggested in a faq, but it still doesnt seem to work. Below is what I
have done:
pid = fork()
if (pid == 0){
printf ("http://my.wait.page");
exit (100);
| |
by: JoeW |
last post by:
Now before I go into detail I just want to say that this is purely for
my own benefit and has no real world usage. I remember way back when
the tool for *nix systems called forkbomb was created. I recently
explained it to a friend of mine and at that time decided to see if I
could replicate it in C#. I have created an application that, to me at
least, mimics what fork would/should do on *nix/bsd systems. I know
that fork spawns a new...
|
by: ohaqqi |
last post by:
Hi guys,
I'm still working on my shell. I'm trying to implement a function typefile that will take a command line input as follows:
> type <file1>
This command will implement a catenation of file1, equal to the command cat <file1>
I need to use execvp() and fork() system calls to create a new process that will type/cat any text file. In my code below, the execvp() call in the function at the bottom gets me the following:
...
|
by: rohitsagar |
last post by:
I want to do fork from a program
Code is very simple, below is the code, it just execute a executable
called a.exe, I want to run a.exe 600 times.
#include<stdio.h>
#include<stdlib.h>
void main()
{
pid_t pid;
|
by: AK |
last post by:
Hi everyone,
Please check out this query that I have in :
http://groups.google.com/group/progav/browse_thread/thread/29057ec587dd46b3
(its a bit long, thats why I am not typing it again; please do check
that link)
and please do respond... I know there are quite a number of members of
progav in here... This is one query I need resolved asap... So, please
|
by: 3srt |
last post by:
Hello,
I created a simple 'server' script that will accept input from a cgi script. The server will handle multiple connections on the same port, also. In a nut shell, this 'server' script will take in variables, and fork off a process to sleep for a given amount of time, and then send the user an email (and perform other functions).
Here is my problem: I receive a confirmation e-mail once the connection has been made, but i do not...
|
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...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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...
|
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...
|
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...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |