Thread: Call a program & still capture cmds

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    3

    Question Call a program & still capture cmds

    I have a program which runs steps, calls another program, and runs more steps if the program call was successful. The program I call is (and needs to remain) interactive, so I used system(). The child program allows the user to abort the process at any time by hitting <esc> <esc> 1. Unfortunately, the program exits with a 0 (OK) status when this is happens.

    Is there a way to capture the abort sequence within the parent program?


    Not the actual code...but this should give the basic idea.

    while(scanf(file_in, "%s", buffer))
    printf("file_out, "%s\n", buffer);

    if(system(run_program)!=0)
    return;

    while(scanf(new_file, "%s", buffer)
    printf(report, "%s\n", buffer);

  2. #2
    Registered User
    Join Date
    Jul 2003
    Posts
    3
    Unix (Dec-alpha) with the cc compiler.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    It would be better to just use one program and spawn a child, rather than calling system. 'system' just returns the value of that call itself, not the return value of whatever program/call you make.

    On a side note, according to the man pages, system ignores interrupts.

    A spawned child process would be a better idea. Of course, if that isn't an option, you may end up having to actually be calling a shell script instead of an executable, and then have it do something based on the retrun value of whatever program you're running.

    I don't think you'll have much luck with just system on its own. However, I'm far from a Unix guru, so there may be a way around it.

    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Registered User
    Join Date
    Jul 2003
    Posts
    3
    Thanks...I'll check into spawning...

    (I don't have Xterm...I am stuck in a single window world)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help calling function is asm
    By brietje698 in forum C++ Programming
    Replies: 24
    Last Post: 12-06-2007, 04:48 PM
  2. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  3. making a phone call in a program
    By jverkoey in forum C++ Programming
    Replies: 1
    Last Post: 03-18-2004, 05:09 PM
  4. Middle button mouse capture in another program
    By Gayak in forum Windows Programming
    Replies: 5
    Last Post: 06-13-2002, 05:00 PM
  5. Pls help me to do this project in C I need source code
    By sureshmenon74 in forum C Programming
    Replies: 4
    Last Post: 10-04-2001, 06:57 AM