Author: sandervanderburg
Date: Fri Oct 15 22:49:55 2010
New Revision: 24312
URL: https://svn.nixos.org/websvn/nix/?rev=24312&sc=1
Log:
Removed some explicit calls to wait/WEXITSTATUS, which can be performed by the
wait_to_finish function
Modified:
disnix/disnix/trunk/src/activate/main.c
disnix/disnix/trunk/src/build/build.c
disnix/disnix/trunk/src/collect-garbage/collect-garbage.c
Modified: disnix/disnix/trunk/src/activate/main.c
==============================================================================
--- disnix/disnix/trunk/src/activate/main.c Fri Oct 15 22:33:31 2010
(r24311)
+++ disnix/disnix/trunk/src/activate/main.c Fri Oct 15 22:49:55 2010
(r24312)
@@ -345,11 +345,12 @@
/* Wait until every lock is released */
for(i = 0; i < running_processes; i++)
{
- wait(&status);
-
- if(WEXITSTATUS(status) != 0)
+ status = wait_to_finish(0);
+
+ /* If a process fails, change the exit status */
+ if(status != 0)
{
- fprintf(stderr, "Failed to release the lock!\n");
+ g_printerr("Failed to release the lock!\n");
exit_status = FALSE;
}
}
@@ -385,13 +386,12 @@
/* Wait until every lock is acquired */
for(i = 0; i < try_array->len; i++)
{
- wait(&status);
+ status = wait_to_finish(0);
- if(WEXITSTATUS(status) == 0)
- g_array_append_val(lock_array, g_array_index(try_array,
DistributionItem*, i));
- else
+ /* If a process fails, change the exit status */
+ if(status != 0)
{
- fprintf(stderr, "Failed to acquire a lock!\n");
+ g_printerr("Failed to acquire a lock!\n");
exit_status = FALSE;
}
}
Modified: disnix/disnix/trunk/src/build/build.c
==============================================================================
--- disnix/disnix/trunk/src/build/build.c Fri Oct 15 22:33:31 2010
(r24311)
+++ disnix/disnix/trunk/src/build/build.c Fri Oct 15 22:49:55 2010
(r24312)
@@ -22,8 +22,6 @@
#include <client-interface.h>
#include <unistd.h>
-#include <sys/types.h>
-#include <sys/wait.h>
#define BUFFER_SIZE 4096
@@ -110,12 +108,14 @@
/* Check statusses of the running processes */
for(i = 0; i < running_processes; i++)
{
- /* Wait until a realise process is finished */
- wait(&status);
-
- /* If one of the processes fail, change the exit status */
- if(WEXITSTATUS(status) != 0)
- exit_status = WEXITSTATUS(status);
+ status = wait_to_finish(0);
+
+ /* If one of the processes fail, change the exit status */
+ if(status != 0)
+ {
+ g_printerr("Error with executing realise process!\n");
+ exit_status = status;
+ }
}
/* Cleanup */
Modified: disnix/disnix/trunk/src/collect-garbage/collect-garbage.c
==============================================================================
--- disnix/disnix/trunk/src/collect-garbage/collect-garbage.c Fri Oct 15
22:33:31 2010 (r24311)
+++ disnix/disnix/trunk/src/collect-garbage/collect-garbage.c Fri Oct 15
22:49:55 2010 (r24312)
@@ -18,10 +18,6 @@
*/
#include "collect-garbage.h"
-
-#include <sys/types.h>
-#include <sys/wait.h>
-
#include <infrastructure.h>
#include <client-interface.h>
@@ -35,21 +31,21 @@
if(target_array != NULL)
{
unsigned int i, running_processes = 0;
- int status;
/* Spawn garbage collection processes */
for(i = 0; i < target_array->len; i++)
{
gchar *target = g_array_index(target_array, gchar*, i);
-
+ int pid;
+
g_printerr("Collecting garbage on: %s\n", target);
- status = exec_collect_garbage(interface, target, delete_old);
+ pid = exec_collect_garbage(interface, target, delete_old);
/* If an operation failed, change the exit status */
- if(status == -1)
+ if(pid == -1)
{
- g_printerr("Error executing garbage collection operation!\n");
- exit_status = status;
+ g_printerr("Error forking garbage collection operation!\n");
+ exit_status = -1;
}
else
running_processes++;
@@ -58,12 +54,14 @@
/* Check statusses of the running processes */
for(i = 0; i < running_processes; i++)
{
- /* Wait until a garbage collector processes is finished */
- wait(&status);
+ int status = wait_to_finish(0);
/* If one of the processes fail, change the exit status */
- if(WEXITSTATUS(status) != 0)
- exit_status = WEXITSTATUS(status);
+ if(status != 0)
+ {
+ g_printerr("Error executing garbage collection operation!\n");
+ exit_status = status;
+ }
}
/* Delete the target array from memory */
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits