use pa_fopen_cloexec() where applicable

This commit is contained in:
Lennart Poettering 2009-10-30 04:54:19 +01:00
parent 88b72958be
commit 168be3830a
14 changed files with 27 additions and 27 deletions

View file

@ -105,7 +105,7 @@ int pa__init(pa_module*m) {
* of log messages, particularly because if stdout and stderr are
* dup'ed they share the same O_NDELAY, too. */
if ((fd = open("/dev/tty", O_RDWR|O_CLOEXEC|O_NONBLOCK)) >= 0) {
if ((fd = pa_open_cloexec("/dev/tty", O_RDWR|O_NONBLOCK, 0)) >= 0) {
io = pa_iochannel_new(m->core->mainloop, fd, fd);
pa_log_debug("Managed to open /dev/tty.");
} else {

View file

@ -60,7 +60,7 @@ static void load(struct userdata *u) {
if (u->core->default_sink)
pa_log_info("Manually configured default sink, not overwriting.");
else if ((f = fopen(u->sink_filename, "r"))) {
else if ((f = pa_fopen_cloexec(u->sink_filename, "r"))) {
char ln[256] = "";
pa_sink *s;
@ -81,7 +81,7 @@ static void load(struct userdata *u) {
if (u->core->default_source)
pa_log_info("Manually configured default source, not overwriting.");
else if ((f = fopen(u->source_filename, "r"))) {
else if ((f = pa_fopen_cloexec(u->source_filename, "r"))) {
char ln[256] = "";
pa_source *s;
@ -108,7 +108,7 @@ static void save(struct userdata *u) {
return;
if (u->sink_filename) {
if ((f = fopen(u->sink_filename, "w"))) {
if ((f = pa_fopen_cloexec(u->sink_filename, "w"))) {
pa_sink *s = pa_namereg_get_default_sink(u->core);
fprintf(f, "%s\n", s ? s->name : "");
fclose(f);
@ -117,7 +117,7 @@ static void save(struct userdata *u) {
}
if (u->source_filename) {
if ((f = fopen(u->source_filename, "w"))) {
if ((f = pa_fopen_cloexec(u->source_filename, "w"))) {
pa_source *s = pa_namereg_get_default_source(u->core);
fprintf(f, "%s\n", s ? s->name : "");
fclose(f);

View file

@ -63,7 +63,7 @@ static int detect_alsa(pa_core *c, int just_one) {
FILE *f;
int n = 0, n_sink = 0, n_source = 0;
if (!(f = fopen("/proc/asound/devices", "r"))) {
if (!(f = pa_fopen_cloexec("/proc/asound/devices", "r"))) {
if (errno != ENOENT)
pa_log_error("open(\"/proc/asound/devices\") failed: %s", pa_cstrerror(errno));
@ -124,9 +124,9 @@ static int detect_oss(pa_core *c, int just_one) {
FILE *f;
int n = 0, b = 0;
if (!(f = fopen("/dev/sndstat", "r")) &&
!(f = fopen("/proc/sndstat", "r")) &&
!(f = fopen("/proc/asound/oss/sndstat", "r"))) {
if (!(f = pa_fopen_cloexec("/dev/sndstat", "r")) &&
!(f = pa_fopen_cloexec("/proc/sndstat", "r")) &&
!(f = pa_fopen_cloexec("/proc/asound/oss/sndstat", "r"))) {
if (errno != ENOENT)
pa_log_error("failed to open OSS sndstat device: %s", pa_cstrerror(errno));

View file

@ -85,7 +85,7 @@ static int load_rules(struct userdata *u, const char *filename) {
pa_assert(u);
if (filename)
f = fopen(fn = pa_xstrdup(filename), "r");
f = pa_fopen_cloexec(fn = pa_xstrdup(filename), "r");
else
f = pa_open_config_file(DEFAULT_MATCH_TABLE_FILE, DEFAULT_MATCH_TABLE_FILE_USER, NULL, &fn);

View file

@ -172,7 +172,7 @@ static pa_bool_t is_card_busy(const char *id) {
if (status_file)
fclose(status_file);
if (!(status_file = fopen(sub_status, "r"))) {
if (!(status_file = pa_fopen_cloexec(sub_status, "r"))) {
pa_log_warn("Failed to open %s: %s", sub_status, pa_cstrerror(errno));
continue;
}

View file

@ -349,9 +349,9 @@ int pa_oss_get_hw_description(const char *dev, char *name, size_t l) {
if ((n = get_device_number(dev)) < 0)
return -1;
if (!(f = fopen("/dev/sndstat", "r")) &&
!(f = fopen("/proc/sndstat", "r")) &&
!(f = fopen("/proc/asound/oss/sndstat", "r"))) {
if (!(f = pa_fopen_cloexec("/dev/sndstat", "r")) &&
!(f = pa_fopen_cloexec("/proc/sndstat", "r")) &&
!(f = pa_fopen_cloexec("/proc/asound/oss/sndstat", "r"))) {
if (errno != ENOENT)
pa_log_warn("failed to open OSS sndstat device: %s", pa_cstrerror(errno));