Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 7072

gio - output differs for terminal (CLI) and execv() in C(++)

$
0
0

In regard to GLib/gio - g_volume_get_connected_drives returns NULL

On my Ubuntu 22.04, when running the command

/usr/bin/gio mount -l

I receive such similar output:

Drive(0): *HARDDRIVE*  Type: GProxyDrive (GProxyVolumeMonitorUDisks2)Volume(0): *WEBDAVMOUNT*  Type: GProxyVolume (GProxyVolumeMonitorUDisks2)

However, if I create and run the following program in C/C++

int main(int argc, char* argv[]){    char* const GIO_ARGUMENTS[] = {"/usr/bin/gio", "mount", "--list", NULL};    pid_t child_process;    child_process = fork();    int child_return_status = 0;    if(child_process == -1){        std::cout << "Error forking" << std::endl;        exit(EXIT_FAILURE);    }    else if(child_process == 0){        execv(GIO_ARGUMENTS[0], GIO_ARGUMENTS);        std::cout << "Child exiting" << std::endl;        exit(EXIT_SUCCESS);    }    else{        std::cout << "In parent waiting for child" << std::endl;        waitpid(WAIT_ANY, &child_return_status, WUNTRACED);        std::cout << "Parent exiting" << std::endl;        exit(EXIT_SUCCESS);    }}

I only receive this output (notice the Drive(0) part is missing):

Volume(0): *WEBDAVMOUNT*  Type: GProxyVolume (GProxyVolumeMonitorUDisks2)

Both the command line call and the executable run under my user, so there is no difference in context. Even if I attach another device (smartphone with file sharing option enabled) it does not show up. What is the cause for this and how to make gio display exactly as in the CLI?


Viewing all articles
Browse latest Browse all 7072

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>