plz clear my doubts


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers plz clear my doubts
# 1  
Old 03-13-2008
Question plz clear my doubts

hi


I am new to unix.I have searched some forums but couldnt get my answer.
i have created 6 processes and i want to write the process ids into a file which can be read in another program i am writing.Can someone plz send me the syntax for doing so.


I have a doubt regarding pipes.If a pipe is created before a fork then i know that the parent and child process can communicate via this pipe.My question is whether i can declare a pipe after i have created processes and communicate between them.Is it possible to declare a single pipe to use between 6 processes(between 2 at a time and again resuing the same pipe for commnicating between another two).

I apologize if my questions sound lame but i completely new to this.Plz answer.....
# 2  
Old 03-13-2008
I don't understand exactly what you're trying to do, but if you're writing a bash script, you can use the variable $$, which returns the process ID of the current process. If you run " echo $$ " from the command line it will always give you the process ID of your current bash session, but within a script it returns the process that script is running in. You can assign it to a variable or whatever.

If this doesn't help, please give a little more detail.

Thanks,
Shawn
# 3  
Old 03-13-2008
int main()
{
int count;
pid_t fork_result;


for( count = 0; count < 3; count++ )
{
fork_result = fork();
if( fork_result == 0 )
printf("\n%d\n",getpid());
}
return 0;
}

This is my program which creates 7 processes though i need only 6.I want to copy these process id into a file which can be asseced in another program.but i'm unable to find the format for it.

Can you plz answer my pipe question in the above post.
# 4  
Old 03-13-2008
You can redirect the output of your program to a file.

Code:
./program > file

Regards
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

CLEAR THESE Doubts Please ( bash scripts )

gnu.txt-----example file name 1. Display the 15th line of gnu.txt. 2. Display all lines of gnu.txt where the first and third fields are the same. 3. Display all lines of gnu.txt that have more than 100 fields. 4. Display the total number of lines in gnu.txt. 5. Display all lines in... (1 Reply)
Discussion started by: venkatesh B
1 Replies

2. HP-UX

Some doubts about resizing fs's in HP-UX

Hello, I'm new to HP-UX and I'm not sure about some concepts related to resizing fs's under this OS. First of all I'm only asking about resizing ONLINE, it means, without having to umount the fs nor rebooting, etc. Q1. I've read that in order to resize a fs online there are 2 requirements:... (3 Replies)
Discussion started by: asanchez
3 Replies

3. AIX

doubts on xcomd

Hi , How to check if a daemon process is running or not ? is the lssrc command the right option ? I want to check if xcomd daemon is running or not ? lssrc -a | grep xcomd is of no use. Though I am able to sense that xcomd is running there is no output from lssrc command. Do I... (2 Replies)
Discussion started by: BalajiUthira
2 Replies

4. AIX

Doubts on SMIT

Hi All, Have a few doubts on SMIT. 1. Is SMIT available in seperate packages if it is not installed by default with the AIX ? 2. how to check the smit version.. is there anything of that kind ? 3. what is the effect of smit.cat file ? 4. What are all the files present in /etc/objrepos/... (4 Replies)
Discussion started by: BalajiUthira
4 Replies

5. Shell Programming and Scripting

Doubts about variables

Hi, If I have a variable in a configuration file like this: BTS=53,1-2-3-6 export BTS As might get each of the variables in this parameter? "53" "1" "2" .... (3 Replies)
Discussion started by: danietepa
3 Replies

6. UNIX for Dummies Questions & Answers

Unix doubts

Hi All, 1. how and who calls .profile when you login 2. what is PPID and what means by PPID = 0 Thanks in Advance (2 Replies)
Discussion started by: ravi.sadani19
2 Replies

7. UNIX for Dummies Questions & Answers

Doubts on FIFO

Hi , I m beginner for Unix and i want to use FIFO in my 2 Scripts . I want 1 script to read data from FIFO and other will write into FIFO. Despite reading so many articles/posts i am still unable sunchronize my scripts. My doubts are 1> Do We require both scripts as daemons to use... (0 Replies)
Discussion started by: Akshay
0 Replies

8. UNIX for Dummies Questions & Answers

unix doubts

Write unix command to list or view auto links (0 Replies)
Discussion started by: ashishshah.engg
0 Replies

9. UNIX for Dummies Questions & Answers

plz Help How should I configure cc compiler output file plz help???

i.e configuration of C compiler :confused: (4 Replies)
Discussion started by: atiato
4 Replies
Login or Register to Ask a Question