05-05-2008
You can. I guess Shamrock may have meant that you may run into data arrival issues in single threaded/process oriented code with blocking descriptors.
To avoid this you can either use non-blocking I/O, or polling, or both.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I don't follow what these are...
this is what my text says...
"When a process is started, a duplicate of that process is created. This new process is called the child and the process that created it is called the parent. The child process then replaces the copy for the code the parent... (1 Reply)
Discussion started by: xyyz
1 Replies
2. Programming
Hi all, i need to execute a program from within my c++ code. This is no problem. system(), fork(), execxy(). But now i want to able to execute the program as another user as the parent process.
The whole thing is on solaris. I should be possible for both, users with no shell and no password... (1 Reply)
Discussion started by: heck
1 Replies
3. Programming
Hello,
How many child processes are actually created when running this code ?
#include <signal.h>
#include <stdio.h>
int main () {
int i ;
setpgrp () ;
for (i = 0; i < 10; i++) {
if (fork () == 0) {
if ( i & 1 ) setpgrp () ;
printf ("Child id: %2d, group: %2d\n", getpid(),... (0 Replies)
Discussion started by: green_dot
0 Replies
4. Shell Programming and Scripting
Hello,
How many child processes are actually created when running this code ?
#include <signal.h>
#include <stdio.h>
int main () {
int i ;
setpgrp () ;
for (i = 0; i < 10; i++) {
if (fork () == 0) {
if ( i & 1 ) setpgrp () ;
printf ("Child id: %2d, group: %2d\n",... (1 Reply)
Discussion started by: green_dot
1 Replies
5. UNIX for Advanced & Expert Users
Hi, as I understand fork(), it makes a copy of the parent which becomes a child. But is there anyway to make three children for that one parent. So in other words, if I look up the getppid() of the children, I want them to have the same value??
Thanks in advance to any help! (1 Reply)
Discussion started by: MS_CC
1 Replies
6. UNIX for Advanced & Expert Users
Hi all,
I am writing a script which calls other third party scripts that perform numerous actions. I have no control over these scripts.
My problem is, one of these scripts seems to execute and do what it is meant to do, but my calling / parent script always exits at that point. I need to... (4 Replies)
Discussion started by: mark007
4 Replies
7. Programming
i used function fork().
so i made two process.
parent process accepted socket fd and writing to shared memory.
then now. how can child process share parent's socket fd?
is this possible?
Thanks in advance (1 Reply)
Discussion started by: andrew.paul
1 Replies
8. Homework & Coursework Questions
1. The problem statement, all variables and given/known data:
I need to make an program that in a loop creates one parent and five children with fork(). The problem i'm trying to solve is how to delete the parent and child of the childīs process.
2. Relevant commands, code, scripts,... (0 Replies)
Discussion started by: WhiteFace
0 Replies
9. Programming
Hi friends,
I have a small question regarding unix system call fork, I hope you will solve my problem. Here is the small program
$ cat fork1.c
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
int main()
{
int pid;
int x = 0;
x = x + 1;
pid = fork();
if(pid < 0)
{... (2 Replies)
Discussion started by: gabam
2 Replies
10. Shell Programming and Scripting
Hi everyone
i am very new to linux , working on bash shell.
I am trying to solve the given problem
1. Create a process and then create children using fork
2. Check the Status of the application for successful running.
3. Kill all the process(threads) except parent and first child... (2 Replies)
Discussion started by: vizz_k
2 Replies
chpoll(9E) Driver Entry Points chpoll(9E)
NAME
chpoll - poll entry point for a non-STREAMS character driver
SYNOPSIS
#include <sys/types.h>
#include <sys/poll.h>
#include <sys/ddi.h>
#include <sys/sunddi.h>
int prefixchpoll(dev_t dev, short events, int anyyet, short *reventsp, struct pollhead **phpp);
INTERFACE LEVEL
This entry point is optional. Architecture independent level 1 (DDI/DKI).
PARAMETERS
dev The device number for the device to be polled.
events The events that may occur. Valid events are:
POLLIN
Data other than high priority data may be read without blocking.
POLLOUT
Normal data may be written without blocking.
POLLPRI
High priority data may be received without blocking.
POLLHUP
A device hangup has occurred.
POLLERR
An error has occurred on the device.
POLLRDNORM
Normal data (priority band = 0) may be read without blocking.
POLLRDBAND
Data from a non-zero priority band may be read without blocking
POLLWRNORM
The same as POLLOUT.
POLLWRBAND
Priority data (priority band > 0) may be written.
anyyet A flag that is non-zero if any other file descriptors in the pollfd array have events pending. The poll(2) system call
takes a pointer to an array of pollfd structures as one of its arguments. See the poll(2) reference page for more details.
reventsp A pointer to a bitmask of the returned events satisfied.
phpp A pointer to a pointer to a pollhead structure.
DESCRIPTION
The chpoll() entry point routine is used by non-STREAMS character device drivers that wish to support polling. The driver must implement
the polling discipline itself. The following rules must be followed when implementing the polling discipline:
1. Implement the following algorithm when the chpoll() entry point is called:
if (events_are_satisfied_now) {
*reventsp = mask_of_satisfied_events;
} else {
*reventsp = 0;
if (!anyyet)
*phpp = &my_local_pollhead_structure;
}
return(0);
2. Allocate an instance of the pollhead structure. This instance may be tied to the per-minor data structure defined by the driver. The
pollhead structure should be treated as a ``black box'' by the driver. None of its fields should be referenced. However, the size of
this structure is guaranteed to remain the same across releases.
3. Call the pollwakeup() function whenever an event of type events listed above occur. This function can be called with multiple events at
one time. The driver must not hold any mutex across the call to pollwakeup(9F) that is acquired in its chpoll() entry point, or a dead-
lock may result.
RETURN VALUES
chpoll() should return 0 for success, or the appropriate error number.
SEE ALSO
poll(2), nochpoll(9F), pollwakeup(9F)
Writing Device Drivers
SunOS 5.10 8 Nov 2001 chpoll(9E)