Source :

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <libgen.h>
#include <sys/types.h>
char *program;
struct task {
	int priority;
	char *name;
};
void foo() {
	system("/bin/sh");
	exit(EXIT_SUCCESS);
}
struct task *task_alloc() {
	struct task *task = malloc(sizeof(struct task));
	if (!task) {
		fprintf(stderr, "%s: error: out of memory\n", program);
		exit(EXIT_FAILURE);      
	}
	task->name = malloc(8 * sizeof(char));
	if (!task->name) {
		fprintf(stderr, "%s: error: out of memory\n", program);
		exit(EXIT_FAILURE);      
	}
	return task;
}
void task_free(struct task *task) {
	free(task->name);
	free(task);
}
void task_write(struct task *task, int priority, char* name) { 
	task->priority = priority;
	strcpy(task->name, name);
}
int main(int argc, char **argv) { 
	struct task* t[2];
	program = basename(argv[0]);
	if (argc < 3) {
		fprintf(stderr, "%s: error: missing argument(s)\n", program);
		exit(EXIT_FAILURE);
	}
	t[0] = task_alloc();
	t[1] = task_alloc();
	task_write(t[0], 1, argv[1]);
	task_write(t[1], 2, argv[2]);
	fprintf(stdout, "Tasks\n=====\n");
	for (int i=0; i<2; i++) {
		fprintf(stdout, "Task(%d)\n", i);
		fprintf(stdout, "priority: %d\n", t[i]->priority);
		fprintf(stdout, "name: %s\n\n", t[i]->name);
	}
	task_free(t[0]);
	task_free(t[1]);
	return EXIT_SUCCESS;
}