#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
/*
TODO: definirajte argumenti vo nizata args koi oznachuvaat izvrshuvanje
na komandata ls koja se naogja na patekata /bin/ls so argument -l
*/
char *args[] = {"ls -l"};//niza so argumenti
printf("This program is about to run ls -l\n");
// TODO: zamenete go momentalniot proces so ls -l
int result
= system(args
[0]);// povik kon soodvetnata funkcija koja ke go zameni momentalniot proces so ls -l
if (result == -1)
{
printf("Error in replacing process", stderr
); }
/*
programata my_program ja sodrzhi samo naredbata
printf("Hello from my_program\n");
*/
char *args_new[] = {"my_program", NULL};
result = execv(args_new[0], args_new);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDx1bmlzdGQuaD4KI2luY2x1ZGUgPHN0ZGxpYi5oPgoKaW50IG1haW4oaW50IGFyZ2MsIGNoYXIgKmFyZ3ZbXSkKewogICAgLyoKICAgIFRPRE86IGRlZmluaXJhanRlIGFyZ3VtZW50aSB2byBuaXphdGEgYXJncyBrb2kgb3puYWNodXZhYXQgaXp2cnNodXZhbmplCiAgICBuYSBrb21hbmRhdGEgbHMga29qYSBzZSBuYW9namEgbmEgcGF0ZWthdGEgL2Jpbi9scyBzbyBhcmd1bWVudCAtbAogICAgKi8KCiAgICBjaGFyICphcmdzW10gPSB7ImxzIC1sIn07Ly9uaXphIHNvIGFyZ3VtZW50aQoKICAgIHByaW50ZigiVGhpcyBwcm9ncmFtIGlzIGFib3V0IHRvIHJ1biBscyAtbFxuIik7CgogICAgLy8gVE9ETzogemFtZW5ldGUgZ28gbW9tZW50YWxuaW90IHByb2NlcyBzbyBscyAtbAoKICAgIGludCByZXN1bHQgPSBzeXN0ZW0oYXJnc1swXSk7Ly8gcG92aWsga29uIHNvb2R2ZXRuYXRhIGZ1bmtjaWphIGtvamEga2UgZ28gemFtZW5pIG1vbWVudGFsbmlvdCBwcm9jZXMgc28gbHMgLWwKCiAgICBpZiAocmVzdWx0ID09IC0xKQogICAgew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