tools/reorder/rseed.c
author Ting-Yuan Huang <thuang@mozilla.com>
Wed, 30 Oct 2013 15:21:52 -0400
changeset 152813 08826e162b8a57ae2776750028fccdc95cc916b9
parent 94484 f4157e8c410708d76703f19e4dfb61859bfe32d8
permissions -rw-r--r--
Bug 920992 - Specify alignments explicitly in assembly codes. r=derf

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/*

  A program that reads /dev/random to produce a seed for srand(3).

 */

#include <stdio.h>
#include <fcntl.h>

int
main(int argc, char *argv[])
{
    int fd, ok, seed = 0;

    fd = open("/dev/random", O_RDONLY);
    if (fd < 0) {
        perror("/dev/random");
        return 1;
    }

    ok = read(fd, &seed, sizeof seed);
    if (ok > 0)
        printf("%d\n", seed);
    else
        perror("/dev/random");

    close(fd);
    return 0;
}