suspend a process


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting suspend a process
# 8  
Old 06-03-2005
Example for using pipes

/***** File: pipe.c *****/
#include <stdio.h>
#include <string.h>
#include <sys/wait.h>

int main(int argc, char *argv[])
{ int p[2];
int i, pid, status;
char buffer[20];
pipe(p); /* setting up the pipe */
if ((pid = fork()) == 0)
/* in child */
{

write(p[1],"Write the status here");

}
else
/* in parent */
{
close(p[0]);
read(pip[0], buffer,20);

}

}


Here you will have the status in the buffer string.

Thanks
R Ramkumar
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Hibernate and Suspend

I have a C++ program which ends up getting run on every conceivable distro. What I can't do in C++, I can do by shelling out to the O/S. I am trying to find a portable way to send the system into hibernate and suspend modes. For users who have pm-utils, of course, I can use that, but I am trying... (4 Replies)
Discussion started by: BrandonShw
4 Replies

2. Solaris

Solaris 10 Suspend System

One of our Solaris 10 Guru's created a Solaris 10 image and he disabled the Suspend System option. How do I enable it again? example right click on the desktop the go to the bottom Suspend System in grayed out. Any help would be great. ---------- Post updated at 09:02 PM ----------... (1 Reply)
Discussion started by: deaconf19
1 Replies

3. Shell Programming and Scripting

temporarily suspend crontab

Issues: Cron jobs are running everyday at 8PM to hot backup database, archivelog, and some other files. Sometimes crontab scheduled backups need to be suspended for some other tasks randomly but doesn't happen all the time. Objective: I need to create simple script or command ( example :... (7 Replies)
Discussion started by: Paul.S
7 Replies

4. Shell Programming and Scripting

Suspend of crontab temprorarily

Hello Friends, I would like to find out if there is a way to suspend crontab script? I need to suspend the scheduling of crontab scripts in case of an alarm and when alarm ends need to start them again automaticaly, could you suggest me a method? one of participiant of the forum with name... (6 Replies)
Discussion started by: EAGL€
6 Replies

5. Shell Programming and Scripting

How to suspend a user account?

Hi, guys. I have two questions: I need to write a script, which can show all the non-suspended users on system, and suspend the selected user account. There are two things I am not sure: 1. How can I suspend user's account? What I think is: add a string to the encrypted password in shadow... (2 Replies)
Discussion started by: daikeyang
2 Replies

6. Solaris

Suspend in opensolaris

How does one enable the suspend to hard drive or ram and sleep features on a desktiop running Open Solaris? (2 Replies)
Discussion started by: FloridaBSD
2 Replies

7. Shell Programming and Scripting

Suspend Cron job temprory

Hi Is there any way to suspend cron job without ommitting crontab entries?? I have a no of entries in crontab, which runs daily.......... what if I want to suspend all process in cron one day . Is there any one line command for it ?? Please suggest Rergards Pankaj (4 Replies)
Discussion started by: pankajkrmishra
4 Replies

8. Shell Programming and Scripting

suspend/restart a process in shell script

Hi, I have a task that Im stuck on. I have an elementary script named 'myscript' that prints "the script is running" once a second. It runs for 27 seconds. I need to write a 2nd script that starts 'myscript' and takes a parameter '$1' for a number. my 2nd script then needs to pause myscript... (1 Reply)
Discussion started by: daneensign
1 Replies

9. UNIX for Advanced & Expert Users

Suspend to write file

We have a common directory , everyone can put file to it , but I found that there is a problem if the user continouosly write files to this directory while the another application is running at the same time , so I want temporaily "protect" the directory , no files can be write to it at a specific... (3 Replies)
Discussion started by: ust
3 Replies

10. UNIX for Dummies Questions & Answers

UNIX Process Suspend

Hi, I have this doubt.... When some program is running and if we press CTRL+Z...it is suspended... what should we do to continue its execution I know that KILL can be used to completely terminate the process....but is there any way to continue... Thanks (3 Replies)
Discussion started by: proton
3 Replies
Login or Register to Ask a Question
FORK(2) 						      BSD System Calls Manual							   FORK(2)

NAME
fork -- create a new process SYNOPSIS
#include <sys/types.h> #include <unistd.h> pid_t fork(void); DESCRIPTION
Fork() causes creation of a new process. The new process (child process) is an exact copy of the calling process (parent process) except for the following: o The child process has a unique process ID. o The child process has a different parent process ID (i.e., the process ID of the parent process). o The child process has its own copy of the parent's descriptors. These descriptors reference the same underlying objects, so that, for instance, file pointers in file objects are shared between the child and the parent, so that an lseek(2) on a descriptor in the child process can affect a subsequent read or write by the parent. This descriptor copying is also used by the shell to establish standard input and output for newly created processes as well as to set up pipes. o The child processes resource utilizations are set to 0; see setrlimit(2). RETURN VALUES
Upon successful completion, fork() returns a value of 0 to the child process and returns the process ID of the child process to the parent process. Otherwise, a value of -1 is returned to the parent process, no child process is created, and the global variable errno is set to indicate the error. ERRORS
Fork() will fail and no child process will be created if: [EAGAIN] The system-imposed limit on the total number of processes under execution would be exceeded. This limit is configuration- dependent. [EAGAIN] The system-imposed limit MAXUPRC (<sys/param.h>) on the total number of processes under execution by a single user would be exceeded. [ENOMEM] There is insufficient swap space for the new process. SEE ALSO
execve(2), wait(2) HISTORY
A fork() function call appeared in Version 6 AT&T UNIX. 4th Berkeley Distribution June 4, 1993 4th Berkeley Distribution