12-28-2011
1. printf's are buffered, try giving a fflush(stdout) after the printf
2. 2nd printf will not print for obvious reason i.e. execl will replace the current process image with a new one.
It is always good to have a return value for the main().
HTH
--ahamed
PS : Wrong thread to post C/C++ questions. Mod's might move it.
This User Gave Thanks to ahamed101 For This Post:
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. Programming
Hi,
Is it possible to check the Existence/read/write of stdin,stdout,stderr using access() call like for the files we do.
Ex: fd=access("./hi.txt",F_OK)
Similarly I wanna check stdin/tdout/stderr using access() call
I tried using fd=access(stdout,F_OK);
But the result is -1.
I... (3 Replies)
Discussion started by: ramkrix
3 Replies
4. 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
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
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
9. 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
10. Homework & Coursework Questions
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
"Your a7.c program should use printf to print a nice message. (You can decide what to say.) Then the process... (9 Replies)
Discussion started by: miniviking10
9 Replies
LEARN ABOUT REDHAT
setvbuf
SETBUF(3) Linux Programmer's Manual SETBUF(3)
NAME
setbuf, setbuffer, setlinebuf, setvbuf - stream buffering operations
SYNOPSIS
#include <stdio.h>
void setbuf(FILE *stream, char *buf);
void setbuffer(FILE *stream, char *buf, size_tsize);
void setlinebuf(FILE *stream);
int setvbuf(FILE *stream, char *buf, int mode , size_t size);
DESCRIPTION
The three types of buffering available are unbuffered, block buffered, and line buffered. When an output stream is unbuffered, information
appears on the destination file or terminal as soon as written; when it is block buffered many characters are saved up and written as a
block; when it is line buffered characters are saved up until a newline is output or input is read from any stream attached to a terminal
device (typically stdin). The function fflush(3) may be used to force the block out early. (See fclose(3).) Normally all files are block
buffered. When the first I/O operation occurs on a file, malloc(3) is called, and a buffer is obtained. If a stream refers to a terminal
(as stdout normally does) it is line buffered. The standard error stream stderr is always unbuffered by default.
The setvbuf function may be used on any open stream to change its buffer. The mode parameter must be one of the following three macros:
_IONBF unbuffered
_IOLBF line buffered
_IOFBF fully buffered
Except for unbuffered files, the buf argument should point to a buffer at least size bytes long; this buffer will be used instead of the
current buffer. If the argument buf is NULL, only the mode is affected; a new buffer will be allocated on the next read or write opera-
tion. The setvbuf function may only be used after opening a stream and before any other operations have been performed on it.
The other three calls are, in effect, simply aliases for calls to setvbuf. The setbuf function is exactly equivalent to the call
setvbuf(stream, buf, buf ? _IOFBF : _IONBF, BUFSIZ);
The setbuffer function is the same, except that the size of the buffer is up to the caller, rather than being determined by the default
BUFSIZ. The setlinebuf function is exactly equivalent to the call:
setvbuf(stream, (char *)NULL, _IOLBF, 0);
RETURN VALUE
The function setvbuf returns 0 on success. It can return any value on failure, but returns nonzero when mode is invalid or the request
cannot be honoured. It may set errno on failure. The other functions are void.
CONFORMING TO
The setbuf and setvbuf functions conform to ANSI X3.159-1989 (``ANSI C'').
BUGS
The setbuffer and setlinebuf functions are not portable to versions of BSD before 4.2BSD, and are available under Linux since libc 4.5.21.
On 4.2BSD and 4.3BSD systems, setbuf always uses a suboptimal buffer size and should be avoided.
You must make sure that both buf and the space it points to still exist by the time stream is closed, which also happens at program termi-
nation.
For example, the following is illegal:
#include <stdio.h>
int main()
{
char buf[BUFSIZ];
setbuf(stdin, buf);
printf("Hello, world!
");
return 0;
}
SEE ALSO
fclose(3), fflush(3), fopen(3), fread(3), malloc(3), printf(3), puts(3)
Linux 2001-06-09 SETBUF(3)