11-18-2008
Quote:
Originally Posted by
shashi
I have a code which has four different process, each printing different message. I have provided it with user input (implemented using thread), depending on which the corresponding message from that process has to be printed.The code is shown below.when I run the pgm, it takes input such as 1,2,3........ through command prompt, and I get "bash command not found" Kindly help me to get output#include#define _REENTRANT#include#include int i; void DieWithError(char *errorMessage);int key;int z = 0;void *key_hit1 (void *arg){while(1){key = (int)getchar();switch(key){case 49
rintf("channel 1");z = 1;break;case 50
rintf("channel 2");z = 2;break;case 51
rintf("channel 3");z = 3;break;}}} int main() {pthread_t key_hit;int process,process1,process2,process3,process4;pthread_create(&key_hit,NULL,key_hit1,NULL);/////////////process = fork();if(process == 0){if( z == 1){for(i=0;i
This is unreadable, please format your code and use code tags to preserve the indents.
To use code tags you can select the code and press the '#' above the editing windows.
Regards
10 More Discussions You Might Find Interesting
1. Programming
Hi!
IN THE FOLLOWING PROGRAM THE VALUE OF j REMAINS UNCHANGED . WHY ? IF I WANT A VARIABLE VALUE TO CHANGE LIKE THIS , IS THERE ANY WAY TO DO IT ?
Or do we have to use shared memory variables?
main()
{
int return_pid, i, total;
int j=1;
total = TOTALRECS+1;
for... (2 Replies)
Discussion started by: AJAY BHATIA
2 Replies
2. UNIX for Dummies Questions & Answers
I need a help...
I have a HP Netserver LH 6000 U with Hardware Raid .
Sco 5.0.5 installed with Oracle database.
Total number of users, normally logged in are around 60 nos.
The system is very slow ( takes 6 hours for processing one Lakh bills) during the Billing process. Also it is... (1 Reply)
Discussion started by: saleeshpl
1 Replies
3. HP-UX
hi
today we came across error "can not fork new process" when i checked there were 400 ksh processes were running for that particular user ( due to kernel parameter setting no of processes were restricted to 400 ) and the reason for this was somebody executed shell script which had "*" ( only *... (3 Replies)
Discussion started by: zedex
3 Replies
4. UNIX for Dummies Questions & Answers
Hi,
Currently, I'm getting the foll error on an IBM AIX
/etc/profile: 0403-030 The fork function failed. Too many processes already exist.
How can i check the current no. of processes which can run simultaneously on an IBM AIX machine for oracle user and how can i change ?
Thanks
Vin (1 Reply)
Discussion started by: win_vin
1 Replies
5. Red Hat
hi all,
We are trying to run a process in the background and in the process we call fork ;and wait for the child process to finish .We find that the died = wait(&status); happens after 10 seconds randomly and sometimes completes in time (within 1 sec)
This behavior is seen only when the... (0 Replies)
Discussion started by: vishnu.priya
0 Replies
6. Programming
Assume you have such a piece of (more or less pseudo-)code:
if(fork() == 0) {// childprocess
chmod(someProgram, 00777);
exec(someProgram);
} else { // assume it never fails and this is the parent
chmod(someProgram, 00000); // should be executed as soon as possible after the... (5 Replies)
Discussion started by: disaster
5 Replies
7. Programming
Making a C program (process PP) that satisfies the following requirements:
1. Pp receives 3 ≤ N ≤ 10 arguments on the command line invocation, to interpret
as a whole and thus should be 1 ≤ Ni ≤ 4;
2. Pp initially will have to create N processes Pi children facing a range of life
to
... (1 Reply)
Discussion started by: loweherz
1 Replies
8. Programming
Hello All, I am stuck up in a program where the rand functions ends up giving all the same integers. Tried sleep, but the numbers turned out to be same... Can anyone help me out how to fix this issue ? I have called the srand once in the program, but I feel like when I call fork the child process... (5 Replies)
Discussion started by: manisum
5 Replies
9. Programming
Hello everyone, this is my first post.
I have a task to use a fork to create multiple processes and then use execlp to run another program to add 2 numbers.
The problem I am having is we are supposed to use the exit() call in the execlp to return the small integer. This is a bad way to... (3 Replies)
Discussion started by: Johnathan_1017
3 Replies
10. Shell Programming and Scripting
Hi,
I have a script that run every 10 minutes, from a specific timeframe of the day, for example 0500 - 1900.
The script is some sort of checker script for an application log file and check for errors and email us if there is error/s reported in the log.
At the moment, I schedule it... (1 Reply)
Discussion started by: newbie_01
1 Replies
LEARN ABOUT HPUX
pthread_atfork
pthread_atfork(3T) pthread_atfork(3T)
NAME
pthread_atfork() - register fork handlers.
SYNOPSIS
PARAMETERS
prepare This function is called before performing the
parent This function is called in the parent process after performing the
child This function is called in the child process after performing the
DESCRIPTION
The function allows an application to install fork handlers. These fork handlers will be called before and after a operation. These han-
dlers will be called in the context of the thread calling Similar to the handlers, the application does not need to do anything special for
these fork handlers to be called. They will be invoked by the system when a operation occurs.
The function is called before the operation in the parent process. The function is called after the operation in the parent process. The
function is called after the operation in the child process.
If a fork handler is not needed in one or more of these three places, the appropriate fork handler parameter may be set to NULL.
A process may install multiple fork handling functions. The and fork handlers will be called in the order in which they were installed
(i.e., The fork handlers will be called in the opposite order (i.e.,
RETURN VALUE
Upon successful completion, returns zero. Otherwise, an error number is returned to indicate the error (the variable is not set).
ERRORS
If any of the following occur, the function returns the corresponding error number:
[ENOMEM] There is insufficient table space to install the fork handlers.
AUTHOR
was derived from the IEEE POSIX P1003.1c standard.
SEE ALSO
fork(2), atexit(3).
STANDARDS CONFORMANCE
Pthread Library pthread_atfork(3T)