EDITIn the comments, you mentioned that you use the command as:
cat /dev/zero | ./namefile | cat >/dev/null
. /dev/zero - , . , . , , .
, ( ). GNU , , int POSIX.
, , , fputc printf (, , printf , ). fputc , , .
EDIT:
. , :
, . stdio (printf(), scanf(), ..), -. , printf() - - printf() stdio. ( Linux)
stdio, , , .
:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
int countbyte = 0;
int sigcount = 0;
static void sighandler(int signum)
{
sigcount = countbyte;
}
int main(void)
{
int c;
struct sigaction sigact;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = 0;
sigact.sa_handler = sighandler;
sigaction(SIGUSR1, &sigact, NULL);
while ((c = getc(stdin)) != EOF) {
countbyte++;
fputc(c, stdout);
}
if (sigcount != 0) {
printf("Interrupted after %d bytes\n", sigcount);
}
return 0;
}