133 |
cfg_foreach(gn_cfg_info, section, device_script_cfgfunc); |
cfg_foreach(gn_cfg_info, section, device_script_cfgfunc); |
134 |
errno = 0; |
errno = 0; |
135 |
if (dup2(fd, 0) != 0 || dup2(fd, 1) != 1 || close(fd)) { |
if (dup2(fd, 0) != 0 || dup2(fd, 1) != 1 || close(fd)) { |
136 |
fprintf(stderr, _("device_script(\"%s\"): file descriptor prepare: %s\n"), scriptname, strerror(errno)); |
fprintf(stderr, _("device_script(\"%s\"): file descriptor preparation failure: %s\n"), scriptname, strerror(errno)); |
137 |
_exit(-1); |
_exit(-1); |
138 |
} |
} |
139 |
/* FIXME: close all open descriptors - how to track them? |
/* FIXME: close all open descriptors - how to track them? |
140 |
*/ |
*/ |
141 |
execl("/bin/sh", "sh", "-c", scriptname, NULL); |
execl("/bin/sh", "sh", "-c", scriptname, NULL); |
142 |
fprintf(stderr, _("device_script(\"%s\"): execute script: %s\n"), scriptname, strerror(errno)); |
fprintf(stderr, _("device_script(\"%s\"): script exection failure: %s\n"), scriptname, strerror(errno)); |
143 |
_exit(-1); |
_exit(-1); |
144 |
/* NOTREACHED */ |
/* NOTREACHED */ |
145 |
|
|
146 |
default: |
default: |
147 |
if (pid == waitpid(pid, &status, 0 /* options */) && WIFEXITED(status) && !WEXITSTATUS(status)) |
if (pid == waitpid(pid, &status, 0 /* options */) && WIFEXITED(status) && !WEXITSTATUS(status)) |
148 |
return 0; |
return 0; |
149 |
fprintf(stderr, _("device_script(\"%s\"): child script failure: %s, exit code=%d\n"), scriptname, |
fprintf(stderr, _("device_script(\"%s\"): child script execution failure: %s, exit code=%d\n"), scriptname, |
150 |
(WIFEXITED(status) ? _("normal exit") : _("abnormal exit")), |
(WIFEXITED(status) ? _("normal exit") : _("abnormal exit")), |
151 |
(WIFEXITED(status) ? WEXITSTATUS(status) : -1)); |
(WIFEXITED(status) ? WEXITSTATUS(status) : -1)); |
152 |
errno = EIO; |
errno = EIO; |
174 |
|
|
175 |
retcode = tcgetattr(fd, &serial_termios); |
retcode = tcgetattr(fd, &serial_termios); |
176 |
if (retcode == -1) { |
if (retcode == -1) { |
177 |
perror("Gnokii serial_open:tcgetattr"); |
perror("Gnokii serial_open: tcgetattr"); |
178 |
/* Don't call serial_close since serial_termios is not valid */ |
/* Don't call serial_close since serial_termios is not valid */ |
179 |
close(fd); |
close(fd); |
180 |
return -1; |
return -1; |
189 |
/* handle config file disconnect_script: |
/* handle config file disconnect_script: |
190 |
*/ |
*/ |
191 |
if (device_script(fd, "disconnect_script", state) == -1) |
if (device_script(fd, "disconnect_script", state) == -1) |
192 |
fprintf(stderr, _("Gnokii serial_close: disconnect_script\n")); |
dprintf("Gnokii serial_close: disconnect_script\n"); |
193 |
|
|
194 |
if (fd >= 0) { |
if (fd >= 0) { |
195 |
#if 1 /* HACK */ |
#if 1 /* HACK */ |
277 |
/* handle config file connect_script: |
/* handle config file connect_script: |
278 |
*/ |
*/ |
279 |
if (device_script(fd, "connect_script", state) == -1) { |
if (device_script(fd, "connect_script", state) == -1) { |
280 |
fprintf(stderr,"Gnokii serial_opendevice: connect_script\n"); |
dprintf("Gnokii serial_opendevice: connect_script\n"); |
281 |
serial_close(fd, state); |
serial_close(fd, state); |
282 |
return -1; |
return -1; |
283 |
} |
} |
446 |
|
|
447 |
#ifndef TIOCMGET |
#ifndef TIOCMGET |
448 |
if (state->config.require_dcd) |
if (state->config.require_dcd) |
449 |
fprintf(stderr, _("WARNING: global/require_dcd argument was set but it is not supported on this system!\n")); |
dprintf("WARNING: global/require_dcd argument was set but it is not supported on this system!\n"); |
450 |
#endif |
#endif |
451 |
|
|
452 |
if (state->config.require_dcd) |
if (state->config.require_dcd) |