File: cmd-streaming.c

package info (click to toggle)
remctl 3.18-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,612 kB
  • sloc: ansic: 19,504; sh: 5,386; perl: 1,778; java: 740; makefile: 715; xml: 502; python: 430
file content (38 lines) | stat: -rw-r--r-- 867 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 * Small C program to output three lines, one to stdout, one to stderr, and
 * then one to stdout again.  Used to test remctl streaming support.
 *
 * Written by Russ Allbery <eagle@eyrie.org>
 * Copyright 2006
 *     The Board of Trustees of the Leland Stanford Junior University
 *
 * SPDX-License-Identifier: MIT
 */

#include <config.h>
#include <portable/system.h>

#ifdef HAVE_SYS_SELECT_H
#    include <sys/select.h>
#endif
#include <sys/time.h>

int
main(void)
{
    struct timeval tv;

    fprintf(stdout, "This is the first line\n");
    fflush(stdout);
    tv.tv_sec = 0;
    tv.tv_usec = 100000;
    select(0, NULL, NULL, NULL, &tv);
    fprintf(stderr, "This is the second line\n");
    fflush(stderr);
    tv.tv_sec = 0;
    tv.tv_usec = 100000;
    select(0, NULL, NULL, NULL, &tv);
    fprintf(stdout, "This is the third line\n");

    return 0;
}