09-22-2005
toughguy, this sounds like homework... better tackle this on your own.. check man pages for popen and sort.
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hi,
Ho do I differentiate system call from library call?
for example if I am using chmod , how do I find out if it is a system call or library call?
Thanks
Muru (2 Replies)
Discussion started by: muru
2 Replies
2. Programming
How the c compiler differentiates the system calls and function calls? (1 Reply)
Discussion started by: rangaswamy
1 Replies
3. Linux
hi,
where can I find the detail information about the syscall in binary instructions of linux/mips.
for example, in linux/mips:
li v0, 4140
syscall
it's a syacall of "lseek" , but how can I find that which registers will be used in this syscall , and the meaning of the arguments in the... (2 Replies)
Discussion started by: zerocool_08
2 Replies
4. Programming
Hi All,
My application gets hang at the popen statement in Soalris 5.8. While debugging I found that it halts at _lwp_sema_wait. After googling I have added /usr/lib/lwp in the LD_LIBRARY_PATH and now it halts at lwp_park. Please help me what I need to do to solve this issue. The application runs... (6 Replies)
Discussion started by: Amiya Rath
6 Replies
5. Shell Programming and Scripting
Hi,
How to write a system calls in a script ?
> cd $HOME
> ls -ltr
thanks in advance.. (10 Replies)
Discussion started by: hegdeshashi
10 Replies
6. Programming
Hi
I'm studing the system call. I've written a small program that return the time spent in doing some operations. Now I'd like to write one that return the time spent in user mode of a process.
I'm reading that i should use the tms struct:
clock_t times(struct tms *buf);
struct tms {... (2 Replies)
Discussion started by: Dedalus
2 Replies
7. Programming
I have a cgi script which is called after certain time interval, which has this:
system ("ls -l /tmp/cgic* | grep -v \"cgicsave.env\" | awk '{print $5}'");
During the execution of this script,the output is 0 sometimes. But due to this the system call is not working at all and doesnt o/p... (2 Replies)
Discussion started by: xs2punit
2 Replies
8. Programming
in man system it talks about SIGCHLD will be blocked, and SIGINT and SIGQUIT will be ignored.
Does this signal stuff also happen in popen command?
(even though man popen says nothing about signals)
also if I am not using wait(&status) and I am using waitpid(pid, NULL, 0)
how would... (1 Reply)
Discussion started by: omega666
1 Replies
9. Programming
hi everyone
i wrote a system call and compiled the kernel succesfully...
my system call is in a file in the kernel folder named my_syscall1.c (kernel/my_syscall1.c)
the header file for this system call i added it in the folder include like this include/my_syscall1/my_syscall1.h
my problem is... (2 Replies)
Discussion started by: demis87
2 Replies
10. Shell Programming and Scripting
Trying to figure out a load issue with a webserver. I have traced a php script and noticed the following
connect(4, {sa_family=AF_INET, sin_port=htons(3306), sin_addr=inet_addr("XX.XX.XX.XX")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000035>
poll(, 1, 2000) = 1 () <0.000120>... (5 Replies)
Discussion started by: rajan007
5 Replies
popen(3) Library Functions Manual popen(3)
NAME
popen - Initiates a pipe to a process
LIBRARY
Standard C Library (libc.so, libc.a)
SYNOPSIS
#include <stdio.h>
FILE *popen (
const char *command,
const char *type );
STANDARDS
Interfaces documented on this reference page conform to industry standards as follows:
popen(): XPG4, XPG4-UNIX
Refer to the standards(5) reference page for more information about industry standards and associated tags.
PARAMETERS
Points to a null-terminated string containing a shell command line. Points to a null-terminated string containing an I/O mode.
DESCRIPTION
The popen() function creates a pipe between the calling program and a shell command to be executed. It returns a pointer to a FILE struc-
ture for the stream.
If the type parameter is the value r, the calling program can read from the standard output of the command by reading from the returned
file stream. If the type parameter is the value w, the calling program can write to the standard input of the command by writing to the
returned file stream.
Because open files are shared, a type r command can be used as an input filter and a type w command as an output filter.
NOTES
Programs using the popen() function to invoke an output filter should beware of possible deadlock caused by output data remaining in the
program's buffer. This can be avoided by either using the setbuf() function to ensure that the output stream is unbuffered, or by using
the fflush() function to ensure that all buffered data is flushed before calling the pclose() function. If the original processes and the
process started with the popen() function concurrently read or write a common file, neither should use buffered I/O. If they do, the
results are unpredictable.
RETURN VALUES
Upon successful completion, the popen() function returns a pointer to the FILE structure for the opened stream. In case of error because
files or processes could not be created, the popen() function returns a null pointer.
RELATED INFORMATION
Functions: exec(2), fork(2), fclose(3), fopen(3), pclose(3), pipe(2), setbuf(3)
Standards: standards(5) delim off
popen(3)