mirror of
https://github.com/vanilla-wiiu/vanilla.git
synced 2025-01-22 08:11:47 -05:00
restore stdout after running udhcpc
This commit is contained in:
parent
6d014a06b5
commit
890442639e
1 changed files with 10 additions and 1 deletions
|
@ -687,8 +687,10 @@ die_and_free_socket:
|
||||||
|
|
||||||
int do_dhcp(const char *wireless_interface)
|
int do_dhcp(const char *wireless_interface)
|
||||||
{
|
{
|
||||||
|
int old_stdout = dup(fileno(stdout));
|
||||||
|
|
||||||
int dhcp_pipes[2];
|
int dhcp_pipes[2];
|
||||||
if (pipe(dhcp_pipes)) {
|
if (pipe2(dhcp_pipes, 0)) {
|
||||||
print_info("FAILED TO CREATE DHCP PIPE: %i", errno);
|
print_info("FAILED TO CREATE DHCP PIPE: %i", errno);
|
||||||
return VANILLA_ERROR;
|
return VANILLA_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -704,7 +706,12 @@ int do_dhcp(const char *wireless_interface)
|
||||||
"-f",
|
"-f",
|
||||||
"-s", "/dev/null",
|
"-s", "/dev/null",
|
||||||
NULL};
|
NULL};
|
||||||
|
|
||||||
int r = udhcpc_main(udhcpc_argv);
|
int r = udhcpc_main(udhcpc_argv);
|
||||||
|
|
||||||
|
// Restore old stdout fileno
|
||||||
|
dup2(old_stdout, fileno(stdout));
|
||||||
|
|
||||||
if (r) {
|
if (r) {
|
||||||
print_info("FAILED TO RUN DHCP ON %s", wireless_interface);
|
print_info("FAILED TO RUN DHCP ON %s", wireless_interface);
|
||||||
return VANILLA_ERROR;
|
return VANILLA_ERROR;
|
||||||
|
@ -712,6 +719,8 @@ int do_dhcp(const char *wireless_interface)
|
||||||
|
|
||||||
print_info("DHCP ESTABLISHED");
|
print_info("DHCP ESTABLISHED");
|
||||||
|
|
||||||
|
fflush(stdout);
|
||||||
|
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
read(dhcp_pipes[0], buf, sizeof(buf));
|
read(dhcp_pipes[0], buf, sizeof(buf));
|
||||||
print_info("DHCP OUTPUT: %s", buf);
|
print_info("DHCP OUTPUT: %s", buf);
|
||||||
|
|
Loading…
Reference in a new issue