popen_exec.c fails to compile

Locked
mhanu
Posts: 3
Joined: Thu Mar 08, 2018 10:41 am

popen_exec.c fails to compile

Post by mhanu »

Hi,

I tried to compile ember 2.0 but I get the following error:

popen_exec.c: in function »pclose_exec«:
popen_exec.c:280:13: error: storage size of »pstat« isn’t known
union wait pstat;
^~~~~
make[4]: *** [Makefile.full:187: popen_exec.o] error 1


Marcel
david
Hughes Tech Staff
Posts: 25
Joined: Mon Feb 13, 2017 4:55 am

Re: popen_exec.c fails to compile

Post by david »

Hi

We know it compiles on the platforms we use and test against. Can you provide some details of the platform you are using? (operating system distro, version etc).



Thanks

David
...
mhanu
Posts: 3
Joined: Thu Mar 08, 2018 10:41 am

Re: popen_exec.c fails to compile

Post by mhanu »

Hi

I tried to compile it on two different systems.

System 1
- Raspberry Pi Zero W
- No distribution: Linux From Scratch (http://www.linuxfromscratch.org/lfs/view/development/) and PiLFS (http://intestinate.com/pilfs/)
- Linux Kernel 4.9.78
- gcc version 7.2.0

System 2
- Debian 9.3 (64bit)
- Linux Kernel 4.9.0-6-amd64
- gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1)

Thanks

Marcel
david
Hughes Tech Staff
Posts: 25
Joined: Mon Feb 13, 2017 4:55 am

Re: popen_exec.c fails to compile

Post by david »

Hi

We develop and test against Centos6, Centos7, and Ubuntu14. I'll see if we can spin up a Debian9 box to replicate your issue. The deb manpage shows that waitpid() needs to include sys/types.h and sys/wait.h which are both already being included.


Thanks

David
...
mhanu
Posts: 3
Joined: Thu Mar 08, 2018 10:41 am

Re: popen_exec.c fails to compile

Post by mhanu »

Hi

I did a quick and maybe dirty patch to make it work. Could you please review the patch?

Code: Select all

--- a/popen_exec.c      2017-02-13 01:38:03.000000000 +0100
+++ b/popen_exec.c      2018-04-02 10:53:40.454237203 +0200
@@ -277,7 +277,8 @@
 {
        register int fdes;
        sigset_t omask, nmask;
-       union wait pstat;
+       //union wait pstat;
+       int pstat;
        register int pid;

        /*
@@ -294,11 +295,12 @@
        sigaddset(&nmask, SIGHUP);
        (void) sigprocmask(SIG_BLOCK, &nmask, &omask);
        do {
-               pid = waitpid(pids[fdes], (int *) &pstat, 0);
+               pid = waitpid(pids[fdes], &pstat, 0);
        } while (pid == -1 && errno == EINTR);
        (void) sigprocmask(SIG_SETMASK, &omask, NULL);
        pids[fdes] = 0;
-       return (pid == -1 ? -1 : pstat.w_status);
+       //return (pid == -1 ? -1 : pstat.w_status);
+       return (pid == -1 ? -1 : WEXITSTATUS(pstat));
 }
 
Marcel
david
Hughes Tech Staff
Posts: 25
Joined: Mon Feb 13, 2017 4:55 am

Re: popen_exec.c fails to compile

Post by david »

Hi

That's fine and in fact looks exactly like what we have now. Our code is flagged for a new release which should happen some time this week.



Thanks

David
...
Locked