copying files

I am spawning the “cp” command from a photon application to copy files from
the hard drive to floppy. Even if there is no space left on the floppy
Ptspawn returns successfully. Is there a way to pop up an error message if
there is no space left?

Thank you,
Shashank

Shashank <sbalijepalli@precitech.com> wrote:

I am spawning the “cp” command from a photon application to copy files from
the hard drive to floppy. Even if there is no space left on the floppy
Ptspawn returns successfully. Is there a way to pop up an error message if
there is no space left?

PtSpawn() returning success means that the program cp was successfully
loaded and started executing as a process.

From looking at the docs, if you also add a callback function for
PtSpawn, this gets passed a status field. It isn’t clear, but I
would be that this is the same status that waitpid() gives, and
then you can apply the WIFEXITED() and WEXITSATUS() macros to it
to determine if cp exited normally, and if so, whether it returned
an error or success.

It will return 0 on success, and > 0 if an error occurred – but
doing it this way, it is difficult to find out what error occurred.

If you wish to do it in a slightly less Photon-ish way, you might
think about doing a popen() on cp, and looking at the status of
its exit, and any messages it might print out – and either parsing
the messages or just displaying them directly in a text field.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

If I were to use popen, how can I get the exit status
of the child process?

Thanks,
Shashank

“David Gibbs” <dagibbs@qnx.com> wrote in message
news:ba36si$44f$1@nntp.qnx.com

Shashank <> sbalijepalli@precitech.com> > wrote:
I am spawning the “cp” command from a photon application to copy files
from
the hard drive to floppy. Even if there is no space left on the floppy
Ptspawn returns successfully. Is there a way to pop up an error message
if
there is no space left?

PtSpawn() returning success means that the program cp was successfully
loaded and started executing as a process.

From looking at the docs, if you also add a callback function for
PtSpawn, this gets passed a status field. It isn’t clear, but I
would be that this is the same status that waitpid() gives, and
then you can apply the WIFEXITED() and WEXITSATUS() macros to it
to determine if cp exited normally, and if so, whether it returned
an error or success.

It will return 0 on success, and > 0 if an error occurred – but
doing it this way, it is difficult to find out what error occurred.

If you wish to do it in a slightly less Photon-ish way, you might
think about doing a popen() on cp, and looking at the status of
its exit, and any messages it might print out – and either parsing
the messages or just displaying them directly in a text field.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Shashank <sbalijepalli@precitech.com> wrote:

If I were to use popen, how can I get the exit status
of the child process?

It’s the return value of pclose().