fork
, exec
, and wait
Q. We tried running gimp
in the EL building on Sun
workstation but for some reason, it gave us a "FATAL" error message. Is
there a certain syntax to invoke GIMP
?
A. There is no special syntax to invoking gimp
. To
invoke gimp
from a command line, you can just type:
% gimpTo invoke
gimp
on a particular file from a command line, you
can just type:
% gimp file1(or whatever the name of the file is that you want to edit with
gimp
).
Similarly, you can just invoke gimp
from within your code
using exec
, just as you would with any other program.
If you could be more specific about what the error message said and under what circumstances it happened, I could give a more specific answer to what your problem is.
Q. I have a question regarding gimp
? Each time I execute
gimp
, I get this message on the bash
screen
"ld.so.1: /usr/local/lib/gimp/1.0/plug-ins/aa: fatal: libaa.so.1: open failed: No such file or directory wire_read: unexpected EOF(plug-in crashed?)"
However, even when this message appears, the gimp
program
does load and execute. For the create a new picture part it works fine
except for the same message pops up each time I run the gimp
part. I don't know how to correct this problem? And since the
gimp
still executes even with this message, is this something
to worry about?
A. This is an error with the gimp
installation on some
of the machines. It means that some of the functionality will probably be
missing from gimp
when the user runs it. (It is probably
right that a plug-in crashed -- whatever functionality was provided by that
plug-in won't be there.)
Don't worry about this problem for your second project -- it isn't
caused by your code or set-up. As long as you get gimp
running well enough to do some editing of files, that is enough.
However, when you have problems like this on the system, you should
report them to Jim Summers (send email to jsummers
or
jsummers@cs.ou.edu
), so that he can find out about them and
fix them.
Q. As our group memebers are working on the project we got stuff where
it says on the project "...if PIC_EDIT
isn't set,
gimp
" what does this exactly mean. Do we need to set
PIC_EDIT
using putenv(const char*)
and also how
are we supposed to invoke a piceditor, is there a particular function for
that? We have been working on this for several hours, but could not figure
out.
A. Your program (PicShare
) should not set the
PIC_EDIT
environment variable. Instead, your program should
check to see if PIC_EDIT
has already been set in its
environment. There are two basic possibilities. One is that
PIC_EDIT
has been set, the other is that it hasn't.
If PIC_EDIT
has been set, your program should try to use
whatever value PIC_EDIT
has been set to. So, if
PIC_EDIT
has been set to gimp
then your program
should try to run gimp
, if PIC_EDIT
has been set
to xv
then your program should try to run xv
, if
PIC_EDIT
has been set to xpaint
then then your
program should try to run xpaint
, if PIC_EDIT
has
been set to asLKUGkjb2
then then your program should try to
run asLKUGkjb2
. (Note that your program will fail to run some
of these programs, because they are not installed on the system, because
they are not actual programs, or because the user doesn't have the program
in his or her path, etc. This is fine. Your program should TRY to use the
value in PIC_EDIT
. If PIC_EDIT
is set to a value
of a real program that is installed on the system in the users path, etc.,
then your program should succeed in running PIC_EDIT
.
Otherwise, it is fine for your program to fail.)
If PIC_EDIT
has not been set, your program should use
gimp
. (Again, if gimp
is installed on the system
in the users path, etc., then your program should succeed in running
gimp
. Otherwise, it is fine for your program to fail.)
All of this means two things. One is that your program will want to
check the value of the variable PIC_EDIT
in its environment.
Two is that in order to test your program, you will want to try setting the
value of PIC_EDIT
outside your program, then running
your program. We have discussed in class (and the textbook also talks
about) ways to do these things.
As for invoking a picture editor, there is no special function to do this,
but there are family of system calls, any of which can be used to invoke
another program -- exec
.
Q. Im not quite sure how to copy blank.jpg to the file that the user wants to create....does it have anything to do with the open(...) call discussed in class?
A. You can copy the file any way you want. You can use the POSIX I/O
system calls that we just covered, the ANSI C Standard I/O routines that we
covered near the beginning of the semester, or you could have your program
fork off a child that executes the cp
command.
Q. Can you give me a hint on copying blank.jpg to the user specified
jpg file? The "cp
" command did not work inside code, but it
worked as a shell command. Why is this?
A. The cp
command worked fine for me inside code. If
you are constructing filenames using the C string functions, perhaps you
aren't using them correctly. Please see the second FAQ for this
assignment.