#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
-#include <syslog.h>
#include <time.h>
#include <inttypes.h>
#include <scsi/scsi.h>
struct stat statbuf;
int err = 0;
- fd = open(devname, O_RDONLY | O_NONBLOCK);
+ fd = open(devname, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
if (fd < 0) {
log_debug("scsi_id: cannot open %s: %m", devname);
return 1;
int retval;
memzero(dev_scsi->serial, len);
- srand((unsigned int)getpid());
+ initialize_srand();
for (cnt = 20; cnt > 0; cnt--) {
struct timespec duration;
- fd = open(devname, O_RDONLY | O_NONBLOCK);
+ fd = open(devname, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
if (fd >= 0 || errno != EBUSY)
break;
duration.tv_sec = 0;