Changeset 3378

Show
Ignore:
Timestamp:
06/19/08 10:33:10 (4 months ago)
Author:
dgollub
Message:

Replaced copy system() call by a hopefully more safe g_spawn_sync()
call.
Patch by Bernhard Walle

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tests/support.c

    r3376 r3378  
    630630osync_bool osync_testing_file_copy(const char *source, const char *dest) 
    631631{ 
    632         gchar *cmd; 
    633         int ret; 
    634  
    635         cmd = g_strdup_printf("cp %s %s", source, dest); 
    636         ret = system(cmd); 
    637         g_free(cmd); 
    638  
    639         return ret; 
     632        gboolean ret; 
     633        const char *argv[] = { "cp", source, dest, NULL }; 
     634        int exitstatus = -1; 
     635 
     636        ret = g_spawn_sync(NULL,                /* working directory */ 
     637                           (char **)argv,       /* arguments */ 
     638                           NULL,                /* environment */ 
     639                           G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL, 
     640                           NULL,                /* child setup function */ 
     641                           NULL,                /* user data for child setup func */ 
     642                           NULL,                /* stdin */ 
     643                           NULL,                /* stdout */ 
     644                           &exitstatus,         /* exit status */ 
     645                           NULL                 /* error function */ 
     646                        ); 
     647 
     648        return ret && WEXITSTATUS(exitstatus) == 0; 
    640649} 
    641650 
  • trunk/tests/support.h

    r3376 r3378  
    11#include <check.h> 
     2#include <sys/wait.h> 
    23 
    34#include <opensync/opensync.h>