Sponsored Content
Top Forums Programming Problems with child comunicating with parent on fork() Post 302190175 by shamrock on Monday 28th of April 2008 11:46:25 PM
Old 04-29-2008
Explain what the code is doing. One basic thing wrong with your code is that you cannot mix local and remote communication calls in the same code. Calls made to pipe() can't be in the same code space as socket() calls.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

what are parent and child processes all about?

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

fork() with su (child with other user)

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

fork() and child processes

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

fork() and child processes

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

Fork() 1 Parent 3 Children

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

Child Killing Parent

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

To share fd between parent and child

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

Need help with deleting childīs parent and child subprocess

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

fork(), parent and child processes???

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

forking a child process and kill its parent to show that child process has init() as its parent

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
send(2) 							System Calls Manual							   send(2)

Name
       send, sendto, sendmsg - send a message from a socket

Syntax
       #include <sys/types.h>
       #include <sys/socket.h>

       cc = send(s, msg, len, flags)
       int cc, s;
       char *msg;
       int len, flags;

       cc = sendto(s, msg, len, flags, to, tolen)
       int cc, s;
       char *msg;
       int len, flags;
       struct sockaddr *to;
       int tolen;

       cc = sendmsg(s, msg, flags)
       int cc, s;
       struct msghdr msg[];
       int flags;

Description
       The  and system calls are used to transmit a message to another socket.	The system call may be used only when the socket is in a connected
       state, while the and system calls may be used at any time.

       The address of the target is given by to, with tolen specifying its size.  The length of the message is given by len.  If  the  message	is
       too  long  to  pass atomically through the underlying protocol, the error EMSGSIZE is returned, and the message is not transmitted.  If the
       address specified in the argument is a broadcast address, the SO_BROADCAST option must be set for broadcasting to succeed.

       No indication of failure to deliver is implicit in a Return values of -1 indicate some locally detected errors.

       If no messages space is available at the socket to hold the message to be transmitted, normally blocks, unless the socket has  been  placed
       in nonblocking I/O mode.  The call can be used to determine when it is possible to send more data.

       The flags parameter can be set to MSG_OOB to send out-of-band data on sockets that support this features (for example, SOCK_STREAM).

       See for a description of the msghdr structure.

       The call returns the number of characters sent, or -1 if an error occurred.

Diagnostics
       [EBADF]		   An invalid descriptor was specified.

       [EDESTADDRREQ]	   A required address was omitted from an operation on a socket.

       [EFAULT] 	   An invalid user space address was specified for a parameter.

       [EINVAL] 	   An invalid argument length for the message was specified.

       [EINTR]		   The send was interrupted by delivery of a signal.

       [ENOTCONN]	   The socket is not connected.

       [ENOTSOCK]	   The argument s is not a socket.

       [EMSGSIZE]	   The socket requires that messages be sent atomically, and the size of the message to be sent made this impossible.

       [EPIPE]		   A write on a pipe or socket for which there is no process to read the data.

       [EWOULDBLOCK]	   The socket is marked nonblocking, and the requested operation would block.

See Also
       recv(2), getsockopt(2), socket(2)

																	   send(2)
All times are GMT -4. The time now is 04:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy