Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct process {
- char ID[30];
- int pid;
- };
- typedef struct process Process;
- int main (int argc,char*argv[]){
- int fdin, fdout, ret1, ret2, i, j, v;
- int n = 0;
- int* vPID;
- Process* p;
- Process temp;
- p = (Process*)malloc(30*(sizeof(Process)));
- if(fdin = open("entradaR.txt",O_RDONLY,0666) ==-1){
- printf("Error open()\n");
- return -1;
- }
- if(fdout = open("saidaR.txt",O_CREAT|O_TRUNC|O_WRONLY,0666) ==-1){
- printf("Error open()\n");
- return -1;
- }
- if(ret1 = dup2(fdin,0) == -1){
- printf("Erro dup2(fdin,0) \n");
- return -2;
- }
- if(ret2 = dup2(fdout,1) == -1){
- printf("Erro dup2(fdout,1) \n");
- return -3;
- }
- printf("%d", n);
- while(scanf("Process to execute: %s [^\n]", &p[n].ID ) != EOF){
- //printf("%d", n);
- //printf("%s \n", p[n].ID);
- n++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement