Subversion Repositories wimsdev

Rev

Rev 3718 | Rev 5333 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3718 Rev 3843
Line 98... Line 98...
98
void flushoutput(void)
98
void flushoutput(void)
99
{
99
{
100
    int l2;
100
    int l2;
101
    if(outptr<=outbuf) return;
101
    if(outptr<=outbuf) return;
102
    l2=outptr-outbuf;
102
    l2=outptr-outbuf;
103
    if(lastout_file!=-1) write(lastout_file,outbuf,l2);
103
    if(lastout_file!=-1) (void)write(lastout_file,outbuf,l2);
104
    else fwrite(outbuf,l2,1,stdout);
104
    else fwrite(outbuf,l2,1,stdout);
105
    outptr=outbuf;
105
    outptr=outbuf;
106
}
106
}
107
 
107
 
108
void internal_warn(char msg[])
108
void internal_warn(char msg[])
Line 427... Line 427...
427
    l2=sizeof(outbuf)-(outptr-outbuf);
427
    l2=sizeof(outbuf)-(outptr-outbuf);
428
    put: if(l<=l2) {
428
    put: if(l<=l2) {
429
        memmove(outptr,s,l); outptr+=l; return;
429
        memmove(outptr,s,l); outptr+=l; return;
430
    }
430
    }
431
    memmove(outptr,s,l2); s+=l2; l-=l2;
431
    memmove(outptr,s,l2); s+=l2; l-=l2;
432
    if(lastout_file!=-1) write(lastout_file,outbuf,sizeof(outbuf));
432
    if(lastout_file!=-1) (void)write(lastout_file,outbuf,sizeof(outbuf));
433
    else fwrite(outbuf,sizeof(outbuf),1,stdout);
433
    else fwrite(outbuf,sizeof(outbuf),1,stdout);
434
    outptr=outbuf; l2=sizeof(outbuf); goto put;
434
    outptr=outbuf; l2=sizeof(outbuf); goto put;
435
}
435
}
436
 
436
 
437
        /* Output with no var. */
437
        /* Output with no var. */
Line 890... Line 890...
890
    fflush(NULL);       /* flush all output streams before forking
890
    fflush(NULL);       /* flush all output streams before forking
891
                         * otherwise they will be doubled */
891
                         * otherwise they will be doubled */
892
    pid=fork(); if(pid==-1) return -1;
892
    pid=fork(); if(pid==-1) return -1;
893
    if(!pid) {  /* child */
893
    if(!pid) {  /* child */
894
        char buf[MAX_LINELEN+1]; int k;
894
        char buf[MAX_LINELEN+1]; int k;
895
        nice(10);       /* lower priority for children */
895
        (void)nice(10); /* lower priority for children */
896
        if(is_multiexec) {
896
        if(is_multiexec) {
897
            dup2(mxtab[multiexec_index].pipe_stdin[0],0);
897
            dup2(mxtab[multiexec_index].pipe_stdin[0],0);
898
            dup2(mxtab[multiexec_index].pipe_stdout[1],1);
898
            dup2(mxtab[multiexec_index].pipe_stdout[1],1);
899
            dup2(mxtab[multiexec_index].pipe_stderr[1],2);
899
            dup2(mxtab[multiexec_index].pipe_stderr[1],2);
900
        }
900
        }
901
        else {
901
        else {
902
            if(inf!=NULL) freopen(inf,"r",stdin);
902
            if(inf!=NULL) (void)freopen(inf,"r",stdin);
903
            if(outf!=NULL) freopen(outf,"w",stdout);
903
            if(outf!=NULL) (void)freopen(outf,"w",stdout);
904
            if(errf!=NULL) freopen(errf,"w",stderr);
904
            if(errf!=NULL) (void)freopen(errf,"w",stderr);
905
        }
905
        }
906
                /* This is to patch LinuxPPC uid wrapping
906
                /* This is to patch LinuxPPC uid wrapping
907
                 * for scripts */
907
                 * for scripts */
908
        t=0; if(strchr(cmdf,'/')) {
908
        t=0; if(strchr(cmdf,'/')) {
909
            int tf;
909
            int tf;
910
            char tbuf[16];
910
            char tbuf[16];
911
            tf=open(cmdf,O_RDONLY); read(tf,tbuf,8); close(tf);
911
            tf=open(cmdf,O_RDONLY); (void)read(tf,tbuf,8); close(tf);
912
            if(memcmp(tbuf+1,"ELF",3)!=0) t=1;
912
            if(memcmp(tbuf+1,"ELF",3)!=0) t=1;
913
        }
913
        }
914
        if(wrapexec==-1) {
914
        if(wrapexec==-1) {
915
            setreuid(getuid(),getuid());setregid(getgid(),getgid());
915
            setreuid(getuid(),getuid());setregid(getgid(),getgid());
916
        }
916
        }
Line 1049... Line 1049...
1049
        case 'a': fd=open(buf,O_WRONLY|O_CREAT|O_APPEND,S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); break;
1049
        case 'a': fd=open(buf,O_WRONLY|O_CREAT|O_APPEND,S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); break;
1050
        default : return;
1050
        default : return;
1051
    }
1051
    }
1052
    lastdatafile[0]=lastftest[0]=0;
1052
    lastdatafile[0]=lastftest[0]=0;
1053
    if(fd==-1) return;
1053
    if(fd==-1) return;
1054
    write(fd,content,strlen(content)); close(fd);
1054
    (void)write(fd,content,strlen(content)); close(fd);
1055
}
1055
}
1056
 
1056
 
1057
        /* system(), but with variable parms
1057
        /* system(), but with variable parms
1058
         * Uses sh to execute command. */
1058
         * Uses sh to execute command. */
1059
int call_sh(char *s,...)
1059
int call_sh(char *s,...)