barbieri pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=baa06ebf15c63577efaef4c81cd28e892bdd4c55

commit baa06ebf15c63577efaef4c81cd28e892bdd4c55
Author: Gustavo Sverzut Barbieri <barbi...@profusion.mobi>
Date:   Fri Sep 16 07:42:24 2016 -0300

    efl_io and efl_net examples: fix O_CLOEXEC on windows.
    
    use the efl_io_closer_close_on_exec_set() to use a simple boolean
    instead of a flag that may be undefined on some platforms, such as
    windows.
---
 src/examples/ecore/efl_io_copier_example.c       | 6 ++++--
 src/examples/ecore/efl_net_dialer_http_example.c | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/examples/ecore/efl_io_copier_example.c 
b/src/examples/ecore/efl_io_copier_example.c
index 689a743..2a2af78 100644
--- a/src/examples/ecore/efl_io_copier_example.c
+++ b/src/examples/ecore/efl_io_copier_example.c
@@ -504,7 +504,8 @@ main(int argc, char **argv)
         /* regular file, open with flags: read-only and close-on-exec */
         input = efl_add(EFL_IO_FILE_CLASS, NULL,
                         efl_file_set(efl_added, input_fname, NULL), /* 
mandatory */
-                        efl_io_file_flags_set(efl_added, O_RDONLY | 
O_CLOEXEC), /* recommended */
+                        efl_io_file_flags_set(efl_added, O_RDONLY), /* default 
*/
+                        efl_io_closer_close_on_exec_set(efl_added, EINA_TRUE), 
/* recommended, set *after* flags, or include O_CLOEXEC in flags -- be careful 
with _WIN32 that doesn't support it. */
                         efl_event_callback_array_add(efl_added, input_cbs(), 
NULL) /* optional */
                         );
         if (!input)
@@ -664,7 +665,8 @@ main(int argc, char **argv)
          */
         output = efl_add(EFL_IO_FILE_CLASS, NULL,
                          efl_file_set(efl_added, output_fname, NULL), /* 
mandatory */
-                         efl_io_file_flags_set(efl_added, O_WRONLY | O_CLOEXEC 
| O_CREAT | O_TRUNC), /* mandatory for write */
+                         efl_io_file_flags_set(efl_added, O_WRONLY | O_CREAT | 
O_TRUNC), /* mandatory for write */
+                         efl_io_closer_close_on_exec_set(efl_added, 
EINA_TRUE), /* recommended, set *after* flags, or include O_CLOEXEC in flags -- 
be careful with _WIN32 that doesn't support it. */
                          efl_io_file_mode_set(efl_added, 0644), /* mandatory 
for write */
                          efl_event_callback_array_add(efl_added, output_cbs(), 
NULL) /* optional */
                          );
diff --git a/src/examples/ecore/efl_net_dialer_http_example.c 
b/src/examples/ecore/efl_net_dialer_http_example.c
index de73869..81172a3 100644
--- a/src/examples/ecore/efl_net_dialer_http_example.c
+++ b/src/examples/ecore/efl_net_dialer_http_example.c
@@ -290,7 +290,8 @@ main(int argc, char **argv)
         input = efl_add(EFL_IO_FILE_CLASS, loop,
                         efl_name_set(efl_added, "input"),
                         efl_file_set(efl_added, input_fname, NULL),
-                        efl_io_file_flags_set(efl_added, O_RDONLY | O_CLOEXEC),
+                        efl_io_file_flags_set(efl_added, O_RDONLY),
+                        efl_io_closer_close_on_exec_set(efl_added, EINA_TRUE), 
/* recommended, set *after* flags, or include O_CLOEXEC in flags -- be careful 
with _WIN32 that doesn't support it. */
                         efl_event_callback_add(efl_added, 
EFL_IO_READER_EVENT_EOS, _eos, NULL));
      }
 
@@ -305,7 +306,8 @@ main(int argc, char **argv)
                          efl_name_set(efl_added, "output"),
                          efl_file_set(efl_added, output_fname, NULL),
                          efl_io_file_mode_set(efl_added, 0644),
-                         efl_io_file_flags_set(efl_added, O_WRONLY | O_CLOEXEC 
| O_TRUNC | O_CREAT));
+                         efl_io_file_flags_set(efl_added, O_WRONLY | O_TRUNC | 
O_CREAT),
+                         efl_io_closer_close_on_exec_set(efl_added, 
EINA_TRUE)); /* recommended, set *after* flags, or include O_CLOEXEC in flags 
-- be careful with _WIN32 that doesn't support it. */
      }
 
    primary_mode = _parse_primary_mode(primary_mode_str);

-- 


Reply via email to