This is a discussion on system command returns 32512 within the AIX Operating System forums, part of the Unix Operating Systems category; --> Hi, I am executing a C program in AIX 4.3 machine. The program sends email with the body redirected ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, I am executing a C program in AIX 4.3 machine. The program sends email with the body redirected from a file. I use mailx command ( sendmail utility ) in AIX. The code has following lines: ######################## char *str = "mailx -s hi -c test@abc.com test2@abc.com < test.txt" rc = system(str); ######################### I execute this in a loop for many times. For example, if i execute it for 10 times then 1-2 mails are not sent. The return from system command for these 2-3 failed mails is 32512 I printed value of rc and it showed that rc=32512. The mailx command was not invoked. I saw in some groups, they have mentioned that the return 32512 is because the exec of the child process failed. I want to know the reason why the exec of the child process failed. I have verified that the number of processes is not exceding the system limit. Can anyone please tell me the root cause of this return 32512. Thanks and Regards Kiran Hiremath |
| |||
| In article <1137674999.453715.319480@f14g2000cwb.googlegroups .com>, kiranhiremath@gmail.com <kiranhiremath@gmail.com> wrote: > > I am executing a C program in AIX 4.3 machine. > > The program sends email with the body redirected from a file. > I use mailx command ( sendmail utility ) in AIX. > I printed value of rc and it showed that rc=32512. 32512 divided by 256 is 127... so it sounds like EOVERFLOW. (grep 127 /usr/include/errno.h) What is the size of file.txt? And the size of the target user's mailbox? Is there any entry in 'errpt' for the problem? Is the machine at 4.3.3 and fully patched? -Dan |
| |||
| Hi Dan, I checked the file size and it is just 90 bytes. And what is the entry 'errpt'. where can i find it. I could see that when the system caommand failed, the mailx command was not triggerred. The target mailbox has a very huge size. Also please not, some mailx commands which have a bigger file as a body are executed successfully. Also please let me know which are the patches which should be installed. What does the Error Number EOVERFLOW indicate? Thanks and Regards Kiran |
| |||
| In article <1137679296.217843.257350@f14g2000cwb.googlegroups .com>, kiranhiremath@gmail.com <kiranhiremath@gmail.com> wrote: > > I checked the file size and it is just 90 bytes. > And what is the entry 'errpt'. where can i find it. It's a command. For example: # /usr/sbin/errpt | more But may not be needed. > The target mailbox has a very huge size. Ahh! Is the target mailbox at least 2,147,483,648 bytes? If it is 2 GB or more, mailx will fail. I would guess maybe because mailx could be written to only handle signed 32-bit numbers for file I/O access, or related to non-big files JFS. So when the value is too big to fit in the off_t data type, you get the overflow error (errno number 127). Solution: reduce target user's mailbox size to less than 2 GB. -Dan |
| |||
| Hi Dan, The target user mailbox size is 50 MB. The system command forks a child process and then it calls the exec command. I think the exec command is failing. Can it be due to any memory error? For example current process memory usage. Do you have any idea on this? Thanks Kiran |
| |||
| In article <1137680269.009244.283360@g47g2000cwa.googlegroups .com>, kiranhiremath@gmail.com <kiranhiremath@gmail.com> wrote: > > The target user mailbox size is 50 MB. Ahh. Hmm. Guess that's not a problem, then. > The system command forks a child process and then it calls the exec > command. > I think the exec command is failing. > Can it be due to any memory error? For example current process memory > usage. # /usr/bin/errpt | grep VMM That will report if there were any virtual memory-related failures logged. -Dan |
| |||
| Hi Dan, Actaully my code is as follows: ################################################## ############## length = strlen(to) + strlen(from) + strlen(replyto) + strlen(cc) + strlen(subject); mailcommand = (char*)malloc(length + 128); strcpy(mailcommand,"mailx -s \'"); strcat(mailcommand,subject); strcat(mailcommand,"\' "); strcat(mailcommand,"-c \""); strcat(mailcommand,cc); strcat(mailcommand,"\" "); strcat(mailcommand,"-r \""); strcat(mailcommand,replyto); strcat(mailcommand,"\" "); strcat(mailcommand,"\""); strcat(mailcommand,to); strcat(mailcommand,"\""); strcat(mailcommand," "); strcat(mailcommand,"< "); strcat(mailcommand,tmpfilename); strcat(mailcommand,"\n"); system(mailcommand); free(mailcommand); ################################################## ##### The tmpfilename is the file which contains body. Do you think there is any memory leak or any such thing here ? Thanks and Regards Kiran |
| |||
| kiranhiremath@gmail.com wrote: > Actaully my code is as follows: > > ################################################## ############## > > length = strlen(to) + strlen(from) + strlen(replyto) + strlen(cc) + > strlen(subject); > mailcommand = (char*)malloc(length + 128); > > strcpy(mailcommand,"mailx -s \'"); > strcat(mailcommand,subject); > strcat(mailcommand,"\' "); > strcat(mailcommand,"-c \""); > strcat(mailcommand,cc); > strcat(mailcommand,"\" "); > strcat(mailcommand,"-r \""); > strcat(mailcommand,replyto); > strcat(mailcommand,"\" "); > strcat(mailcommand,"\""); > strcat(mailcommand,to); > strcat(mailcommand,"\""); > strcat(mailcommand," "); > > strcat(mailcommand,"< "); > strcat(mailcommand,tmpfilename); > strcat(mailcommand,"\n"); > > system(mailcommand); > > free(mailcommand); > > ################################################## ##### > The tmpfilename is the file which contains body. > > Do you think there is any memory leak or any such thing here ? I cannot see a memory leak. The '\n' at the end of the command is superfluous, but I don't think that is the problem (since you say it occurs only sometimes). Here's what the manual has to say about system(2) return values: Return Values Upon successful completion, the system subroutine returns the exit status of the shell. The exit status of the shell is returned in the same manner as a call to the wait or waitpid subroutine, using the structures in the sys/wait.h file. If the String parameter is a null pointer and a command processor is available, the system subroutine returns a nonzero value. If the fork subroutine fails or if the exit status of the shell cannot be obtained, the system subroutine returns a value of -1. If the exec l subroutine fails, the system subroutine returns a value of 127. In all cases, the errno global variable is set to indicate the error. What I would do in your place is change the code for debugging purposes: #include <errno.h> #include <string.h> #include <stdio.h> .... int rc; .... rc = system(mailcommand); printf("Executed command \"%s\", got return code %d, errno = %d (%s)\n", mailcommand, rc, errno, strerror(errno)); Then let it run and examine the output. Share your observations! Yours, Laurenz Albe |
| |||
| On Fri, 19 Jan 2006 kiranhiremath@gmail.com wrote: > Hi Dan, > Actaully my code is as follows: > > ################################################## ############## > > length = strlen(to) + strlen(from) + strlen(replyto) + strlen(cc) + > strlen(subject); > mailcommand = (char*)malloc(length + 128); > > You need to include a sizeof() operator in your call to malloc. Your current code assumes a character is one byte in size when most likely you're dealing with either 32 bytes or 64 bytes per char i.e. mailcommand = (char *)malloc(sizeof(char)*length+128) This may not be your actual problem, but sloppy code like that will come back and bite you at some point. Cheers JH |
| ||||
| Jeff Herrick <jherrick@igs.net> wrote: >> length = strlen(to) + strlen(from) + strlen(replyto) + strlen(cc) + >> strlen(subject); >> mailcommand = (char*)malloc(length + 128); > > You need to include a sizeof() operator in your call to malloc. Your > current code assumes a character is one byte in size when most > likely you're dealing with either 32 bytes or 64 bytes per char i.e. > > mailcommand = (char *)malloc(sizeof(char)*length+128) > > This may not be your actual problem, but sloppy code like that will > come back and bite you at some point. As far as I know, the ANSI standard requires sizeof(char) to be 1. Yours, Laurenz Albe |