Sponsored Content
Top Forums UNIX for Dummies Questions & Answers error message when use fork with open file Post 302399112 by rosecomp on Friday 26th of February 2010 10:35:25 AM
Old 02-26-2010
error message when use fork with open file

I get this message when I write myshell.c program "VM pagefault:SIGSEGV bad add 0x0 err 0x4 nopage read myshell PM: ciredump signal 11 for 1725 /myshell memory fault (core dumped)"
Code:
/* RCS information: $Id: myshell.c,v 1.2 2006/04/05 22:46:33 elm Exp $ */
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
extern char **getline();
/*Run command with and without arguments*/
void runc(const char *n, char *av[]){
 pid_t pid;
 int status;
 pid=fork();
 if (pid == 0) {
  /* Child */
         execvp(n,av);
                perror("You print wrong command");
  exit(-1);
 }
 else {
  /* Parent */
  wait(&status);
 }
}
void out(const char *n, char *av[]){
   int fd;
 fd = open("outf", O_WRONLY|O_CREAT); 
 if (fd < 0) {
  fprintf(stderr, "Couldn't open file for writing.\n");
 }
 dup2(fd, 1);
 /*execvp("ls",args);*/
 /*{execvp(n,av);}*/
 runc(n,av);
 close(fd);
}
int main() {
  int i;
  char **args; 
  pid_t pid;
  int status;

  while(1) {
    printf("$ ");
    args = getline();
    for(i = 0; args[i] != NULL; i++) {
      printf("Argument %d: %s\n", i, args[i]);
    }
  
 /*Exit command to terminate shell */
 if (strcmp(args[0],"exit")==0)
  exit();
 /*Run command with and without arguments*/
 /*{runc(args[0],args);*/
 out(args[0],args);
  }
 return 0;
}


Last edited by pludi; 02-26-2010 at 11:48 AM.. Reason: code tags, please...
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

PCC-F-NOERRFILE, unable to open error message file, facility PR2

I am trying to build a tuxedo server which in turn depends on several Pro*C programs. I am doing it on HP-UX system. It looks to me that the ORACLE_HOME is set properly. But I am getting error message when trying to build. PCC-F-NOERRFILE, unable to open error message file, facility PR2 exit... (1 Reply)
Discussion started by: asutoshch
1 Replies

2. Programming

Message Queue with fork() help

hi all... ive been trying this program where i spawn 4 threads... and i am trying to use message queue to send msgs from 3 of the threads to the parent thread... but it doent seem to be working... ive almost pulled out my hair tryin to fix the prob :confused: another wierd thing... (1 Reply)
Discussion started by: strider
1 Replies

3. Shell Programming and Scripting

Fishing out error message within a log file

Hi all, i have a log file that captures success or failure messges when i run a daily job. here is a sample of my log. 20060312 start successful successful failure failure 20060312 end i need to write a subroutine that opens up the log daily after my job completes to examine the log... (2 Replies)
Discussion started by: new2ss
2 Replies

4. UNIX for Dummies Questions & Answers

Open a file in VI and I get the message below:

@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ (6 Replies)
Discussion started by: bobo
6 Replies

5. Solaris

Error Message: find: cannot open /: Stale NFS file handle

I am using the "find" command below and it respond with the error message " find: cannot open /: Stale NFS file handle" what does it mean? what can I do about it? Need advice, thanks. below are the command that I enter, the respond and the error message: root@ScripServer:/# find / -name... (1 Reply)
Discussion started by: ezsurf
1 Replies

6. Shell Programming and Scripting

PCC-F-NOERRFILE, unable to open error message file

Hi, I was compiling few C programs in the unix server and getting the following error message rm: /home/a0xxx28/AVT/SEEDLIBRARYDB/LIB/*.a non-existent proc MODE=ANSI CODE=ANSI_C INCLUDE=/home/a0xxx28/PVT/SEEDLIBRARYDB/INCLUDE INCLUDE=/home/a0xxx28/PVT/SEEDLIBRARY/INCLUDE ... (1 Reply)
Discussion started by: kavithakuttyk
1 Replies

7. Solaris

Can't open boot_archive error message

Hello guys, Thanks for all your precious tips. I hope you can give me some advice again. This time I am having an issue with a SUN FIRE V240 (SOLARIS 10). The server doesn't boot, normally , first we had a file system error ====================+FIRST ERROR... (6 Replies)
Discussion started by: feg
6 Replies

8. UNIX for Dummies Questions & Answers

Cp problems, file exists but error message

Basically, I want to copy all files (F03*) in this directory and merge/paste them into a new file (called SMER_2.03.12.SPU), yet the error message is "no such file or directory." I listed what is in my working directory, and the files do exist, so I'm not sure what's going on. The code's at the... (8 Replies)
Discussion started by: ucsdee
8 Replies

9. UNIX for Dummies Questions & Answers

Fork resource unavailable error, max # filehandles open?

I wrote a perl program that simultaneously reads in data from 691 tar.gz files using zcat. I can run one instance of the program without any issues and the memory and swap sizes are negligible. However, when I attempt to run more than 1 I start to get fork: resource unavailable messages. Are... (6 Replies)
Discussion started by: aquinom85
6 Replies

10. Shell Programming and Scripting

When trying to open file Message:-Terminal too wide?

Hi, I am trying to open small size file only in vi editor on solaris or Linux machine but it giving message "Terminal too wide" and then I have to come out. As shown below:- -rwxr-x--- 1 rkycadm rkycprd 2445 Sep 12 04:06 $ vi file.txt Terminal too wide :q! ----------... (2 Replies)
Discussion started by: RahulJoshi
2 Replies
tapset::memory(3stap)													     tapset::memory(3stap)

NAME
tapset::memory - systemtap memory tapset DESCRIPTION
This family of probe points is used to probe memory-related events. vm_fault_contains Test return value for page fault reason See function::vm_fault_contains(3stap) for details. vm.pagefault Records that a page fault occurred See probe::vm.pagefault(3stap) for details. vm.pagefault.return Indicates what type of fault occurred See probe::vm.pagefault.return(3stap) for details. addr_to_node Returns which node a given address belongs to within a NUMA system See function::addr_to_node(3stap) for details. vm.write_shared Attempts at writing to a shared page See probe::vm.write_shared(3stap) for details. vm.write_shared_copy Page copy for shared page write See probe::vm.write_shared_copy(3stap) for details. vm.mmap Fires when an mmap is requested See probe::vm.mmap(3stap) for details. vm.munmap Fires when an munmap is requested See probe::vm.munmap(3stap) for details. vm.brk Fires when a brk is requested (i.e. the heap will be resized) See probe::vm.brk(3stap) for details. vm.oom_kill Fires when a thread is selected for termination by the OOM killer See probe::vm.oom_kill(3stap) for details. vm.kmalloc Fires when kmalloc is requested See probe::vm.kmalloc(3stap) for details. vm.kmem_cache_alloc Fires when kmem_cache_alloc is requested See probe::vm.kmem_cache_alloc(3stap) for details. vm.kmalloc_node Fires when kmalloc_node is requested See probe::vm.kmalloc_node(3stap) for details. vm.kmem_cache_alloc_node Fires when kmem_cache_alloc_node is requested See probe::vm.kmem_cache_alloc_node(3stap) for details. vm.kfree Fires when kfree is requested See probe::vm.kfree(3stap) for details. vm.kmem_cache_free Fires when kmem_cache_free is requested See probe::vm.kmem_cache_free(3stap) for details. SEE ALSO
function::vm_fault_contains(3stap), function::addr_to_node(3stap), probe::vm.pagefault(3stap), probe::vm.pagefault.return(3stap), probe::vm.write_shared(3stap), probe::vm.write_shared_copy(3stap), probe::vm.mmap(3stap), probe::vm.munmap(3stap), probe::vm.brk(3stap), probe::vm.oom_kill(3stap), probe::vm.kmalloc(3stap), probe::vm.kmem_cache_alloc(3stap), probe::vm.kmalloc_node(3stap), probe::vm.kmem_cache_alloc_node(3stap), probe::vm.kfree(3stap), probe::vm.kmem_cache_free(3stap), stap(1), stapprobes(3stap) IBM
--- tapset::memory(3stap)
All times are GMT -4. The time now is 05:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy