When I use the pass directive to start up my application, I can't use a
pipe.  I can't even do 
fprintf(stderr, "message") <- this should ALWAYS work.

When I run my app at the command line, it works fine.  The pipe works and
the output file is created.  When I run it from the agent, the agent gets
the correct output, but the pipe doesn't work, and the output file IS NOT
created.

The following is the source code I am using

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define P_READ 0
#define P_WRITE 1

int main(int argc, char *argv[])
{
        int snmp_pipe[2];
        char buff[256];
        int result;
        
        pipe(snmp_pipe);
        result = fork();

        if(result == 0) /* child */
        {
                FILE *fp;
                int nbytes;
                nbytes = read(snmp_pipe[P_READ], buff, 256);
                buff[nbytes] = '\0';
                fp = fopen("blahfile", "w");
                fprintf(fp, "%s", buff);
                fclose(fp);
                return 0;
        }
        else /* parent */
        {
                write(snmp_pipe[P_WRITE], "hello\n", strlen("hello\n"));

                if(isGet(argv[1]))
                {
                        printf("%s\n", argv[2]);
                        printf("string\n");
                        printf("get request\n");
                }
                else if(isGetNext(argv[1]))
                {       
                        printf("%s\n", argv[2]);
                        printf("string\n");
                        printf("getnext request\n");
                }
        
                else if(isSet(argv[1]))
                {       
                        printf("%s\n", argv[2]);
                        printf("string\n");
                        printf("set request\n");
                }
        
                else
                {       
                        printf("%s\n", argv[2]);
                        printf("string\n");
                        printf("unknown type of request\n");
                }

                return 0;

        }

}

int isGet(char *param)
{
        if(!strcmp(param, "-g"))
                return 1;
        else
                return 0;
}
int isGetNext(char *param)
{
        if(!strcmp(param, "-n"))
                return 1;
        else
                return 0;
}
int isSet(char *param)
{
        if(!strcmp(param, "-s"))
                return 1;
        else
                return 0;
}


-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
_______________________________________________
Net-snmp-coders mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to