fork loop with recursive on success
parent
5f4aad7b19
commit
e41802ec85
8
sins.c
8
sins.c
|
@ -97,8 +97,6 @@ int reproduce(void *pic_address, size_t pic_size)
|
||||||
pic_mutated = ((unsigned char *)pic_address)[mutation_offset] & (mutation_value % 2);
|
pic_mutated = ((unsigned char *)pic_address)[mutation_offset] & (mutation_value % 2);
|
||||||
((char *)pic_address)[mutation_offset] = pic_mutated;
|
((char *)pic_address)[mutation_offset] = pic_mutated;
|
||||||
|
|
||||||
printf("%x\t%x\n", mutation_offset, pic_mutated);
|
|
||||||
|
|
||||||
memset(checksum, 0, SHA_SUM_LENGTH);
|
memset(checksum, 0, SHA_SUM_LENGTH);
|
||||||
SHA1((const unsigned char *)pic_address, pic_size, digest);
|
SHA1((const unsigned char *)pic_address, pic_size, digest);
|
||||||
|
|
||||||
|
@ -135,13 +133,19 @@ int main(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
int return_value = 1;
|
int return_value = 1;
|
||||||
char seed_path[SHA_SUM_LENGTH];
|
char seed_path[SHA_SUM_LENGTH];
|
||||||
|
pid_t scrap_process_id;
|
||||||
|
|
||||||
strncpy(seed_path, argv[1], SHA_SUM_LENGTH);
|
strncpy(seed_path, argv[1], SHA_SUM_LENGTH);
|
||||||
|
|
||||||
|
scrap_process_id = fork();
|
||||||
|
|
||||||
while (return_value)
|
while (return_value)
|
||||||
|
{
|
||||||
|
if(scrap_process_id == 0)
|
||||||
{
|
{
|
||||||
return_value = generation(seed_path);
|
return_value = generation(seed_path);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue